战力:获取显示数据

This commit is contained in:
luying
2022-03-30 14:22:46 +08:00
parent ef731fc979
commit 9adbd08d3c
33 changed files with 205 additions and 1689 deletions
+2 -3
View File
@@ -31,6 +31,7 @@ export enum HERO_SYSTEM_TYPE {
JEWEL_QUENCH = 28, // 天晶石淬炼
REBIRTH = 29, // 武将重生
TALENT = 30, // 天赋
ROLE_LV = 31, // 玩家等级
};
// 武将上限
@@ -47,10 +48,8 @@ export const JOB_TYPE = {
MAGIC: 2
}
// 武将战力放大系数
export const HERO_CE_RATIO = 100;
// 次级属性放大系数
export const HERO_SUB_ATTR_RATIO = 1000 * 100;
export const HERO_SUB_ATTR_RATIO = 1000;
export const HERO_INITIAL_QUALITY = {
BLUE: 1,
+3 -3
View File
@@ -14,14 +14,14 @@ export enum ROLE_SELECT {
COM_BATTLE = 'lv head frame spine heads frames spines topLineupCe',
GET_HEADS = 'heads head frames frame spines spine',
// 排行榜基础数据
RANK = 'roleId roleName lv vLv head frame spine heads frames spines title guildName ce isReducedCe topLineup towerLv towerUpTime topLineupCe heroNum updatedAt heroNumUpdatedAt dungeonWarId dungeonUpdatedAt dungeonHeroes mainWarId mainUpdatedAt mainEliteWarId mainEliteUpdatedAt showLineup hasGuild',
RANK = 'roleId roleName lv vLv head frame spine heads frames spines title guildName ce topLineup towerLv towerUpTime topLineupCe heroNum updatedAt heroNumUpdatedAt dungeonWarId dungeonUpdatedAt dungeonHeroes mainWarId mainUpdatedAt mainEliteWarId mainEliteUpdatedAt showLineup hasGuild',
};
export enum HERO_SELECT {
ENTRY = '-_id -attr',
HERO_DETAIL = 'roleId roleName hid hName ce isReducedCe lv star colorStar quality job skins attr ePlace skinId',
HERO_DETAIL = 'roleId roleName hid hName ce lv star colorStar quality job skins attr ePlace skinId',
// 排行榜中lineup字段
RANK_LINEUP = 'seqId roleId hid star colorStar lv quality job ce isReducedCe updatedAt skinId'
RANK_LINEUP = 'seqId roleId hid star colorStar lv quality job ce updatedAt skinId'
}
export enum EQUIP_SELECT {
+1 -5
View File
@@ -3,7 +3,6 @@ import { index, getModelForClass, prop, DocumentType, Ref, mongoose } from '@typ
import Role, { RoleType } from './Role';
import { GUILD_STRUCTURE, GUILD_STATUS, GUILD_PER_PAGE, GUILD_SELECT, REDIS_KEY, SHOP_REFRESH_TYPE } from '../consts';
import { getZeroPoint, getZeroPointD, nowSeconds } from '../pubUtils/timeUtil';
import { reduceCe } from '../pubUtils/util';
import { gameData } from '../pubUtils/data';
import { SearchGuildParam } from '../domain/backEndField/search';
@@ -77,12 +76,9 @@ export default class Guild extends BaseModel {
@prop({ required: true, default: new Date(), select: false })
refTimeDaily: Date;
@prop({ required: true, default: 0, get: (val:number) => reduceCe(val), set: (val: number) => val })
@prop({ required: true, default: 0 })
guildCe: number; // 总战力
@prop({ required: false, set: (val: boolean) => val, get: () => true })
isReducedCe: boolean; // 如果战力没有缩过就会返回false,缩过了就会返回true
@prop({ required: true, type: String, default: [], select: false })
members: string[]; // 军团成员的roleId,用于增加战力的时候加入总战力
+2 -50
View File
@@ -1,56 +1,12 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, Ref, mongoose, DocumentType } from '@typegoose/typegoose';
// import Equip, { } from './Equip';
import { CounterModel } from './Counter';
import { COUNTER, DEFAULT_HERO_LV, HERO_CE_RATIO } from '../consts';
import { reduceCe } from '../pubUtils/util';
import { DEFAULT_HERO_LV } from '../consts';
import Skin, { SkinUpdate } from './Skin';
import { SearchHeroParam } from '../domain/backEndField/search';
import { Reward } from '../domain/battleField/pvp';
import { gameData, getHeroExpByLv, getHeroInitTalent } from '../pubUtils/data';
type CeAttrUpdate = Partial<CeAttrData>;
export class CeAttrData {
@prop({ required: true })
id: number = 0;
@prop({ required: true })
base: number = 0;
@prop({ required: true })
ratioUp: number = 0;
@prop({ required: true })
fixUp: number = 0;
@prop({ required: true })
equipUp: number = 0;
constructor(id: number) {
this.id = id;
}
public copyFromHero(data: CeAttrData) {
this.base = data.base;
this.ratioUp = data.ratioUp;
this.fixUp = data.fixUp;
this.equipUp = data.equipUp;
}
public updateAttr(update: { inc?: CeAttrUpdate, set?: CeAttrUpdate }) {
if(update.inc) {
let { base, equipUp, fixUp, ratioUp } = update.inc;
if(base != undefined) this.base += base * HERO_CE_RATIO;
if(equipUp != undefined) this.equipUp += equipUp * HERO_CE_RATIO;
if(fixUp != undefined) this.fixUp += fixUp * HERO_CE_RATIO;
if(ratioUp != undefined) this.ratioUp += ratioUp;
}
if(update.set) {
let { base, equipUp, fixUp, ratioUp } = update.set;
if(base != undefined) this.base = base * HERO_CE_RATIO;
if(equipUp != undefined) this.equipUp = equipUp * HERO_CE_RATIO;
if(fixUp != undefined) this.fixUp = fixUp * HERO_CE_RATIO;
if(ratioUp != undefined) this.ratioUp = ratioUp;
}
}
}
/**
* 英雄表
*/
@@ -162,12 +118,8 @@ export default class Hero extends BaseModel {
exp: number; // 经验值
@prop({ required: true, default: 1 })
lv: number; // 武将等级
@prop({ required: true, default: 0, set: (val: number) => val, get: (val: number) => reduceCe(val) })
@prop({ required: true, default: 0 })
ce: number; // 武将战力
@prop({ required: false, set: (val: boolean) => val, get: () => true })
isReducedCe: boolean; // 如果战力没有缩过就会返回false,缩过了就会返回true
@prop({ required: true, type: CeAttrData, default: [], _id: false })
attr: CeAttrData[]; // 影响战力的属性
@prop({ required: true, default: 1 })
star: number; // 星级
+4 -36
View File
@@ -1,42 +1,14 @@
import { ROLE_TERAPH, ROLE_SELECT, ABI_TYPE, HERO_CE_RATIO, BLOCK_TYPE } from './../consts';
import { ROLE_TERAPH, ROLE_SELECT, ABI_TYPE, BLOCK_TYPE } from './../consts';
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, Ref, mongoose } from '@typegoose/typegoose';
import User from './User';
import { shouldRefresh, reduceCe } from '../pubUtils/util';
import { shouldRefresh } from '../pubUtils/util';
import { nowSeconds, getTimeFunD } from '../pubUtils/timeUtil';
import { Figure } from '../domain/dbGeneral';
import * as dicParam from '../pubUtils/dicParam';
import Hero from './Hero';
import { SearchRoleParam } from '../domain/backEndField/search';
type CeAttrUpdate = Partial<CeAttrDataRole>;
// role表属性格式
export class CeAttrDataRole {
@prop({ required: true })
id: number = 0;
@prop({ required: true })
ratioUp: number = 0;
@prop({ required: true })
fixUp: number = 0;
constructor(id: number) {
this.id = id;
}
public updateAttr(update: { inc?: CeAttrUpdate, set?: CeAttrUpdate }) {
if(update.inc) {
let { fixUp, ratioUp } = update.inc;
if(fixUp != undefined) this.fixUp += fixUp * HERO_CE_RATIO;
if(ratioUp != undefined) this.ratioUp += ratioUp;
}
if(update.set) {
let { fixUp, ratioUp } = update.set;
if(fixUp != undefined) this.fixUp = fixUp * HERO_CE_RATIO;
if(ratioUp != undefined) this.ratioUp = ratioUp;
}
}
}
export class TopHero {
@prop({ required: true })
hid: number; // 武将id
@@ -185,16 +157,12 @@ export default class Role extends BaseModel {
exp: number; // 经验值
@prop({ required: true, default: 1 })
lv: number; // 主公等级
@prop({ required: true, default: 0, set: (val: number) => val, get: (val: number) => reduceCe(val) })
@prop({ required: true, default: 0 })
ce: number; // 总战力
@prop({ required: true, type: CeAttrDataRole, default: [], _id: false })
attr: CeAttrDataRole[]; // 总战力
@prop({ required: true, default: 0, set: (val: number) => val, get: (val: number) => reduceCe(val) })
@prop({ required: true, default: 0 })
topLineupCe: number; // 最强x人战力
@prop({ required: true, type: TopHero, default: [], _id: false })
topLineup: Array<TopHero>; // 总战力
@prop({ required: false, set: (val: boolean) => val, get: () => true })
isReducedCe: boolean; // 如果战力没有缩过就会返回false,缩过了就会返回true
@prop({ required: true, default: 100 })
gold: number; // 总金币
+25 -1
View File
@@ -45,7 +45,7 @@ export class SchoolAttr {
}
// 名将谱加成
class ScrollAttr {
export class ScrollAttr {
@prop({ required: true })
hid: number; // 武将id
@prop({ required: true })
@@ -54,6 +54,24 @@ class ScrollAttr {
value: number; // 百家学宫有多个武将,单独拎出来方便计算,计算之后结果存到globaAttrs的global1
}
// 属性结果
export class SingleAttribute {
@prop({ required: true })
id: number; // 属性id
@prop({ required: true })
val: number; // 值
@prop({ required: true })
str: string; // 公式
}
export class Attribute {
@prop({ required: true })
hid: number;
@prop({ required: true, type: SingleAttribute, _id: false })
attrs: SingleAttribute[]; // 属性id
}
/**
* 属性表
*/
@@ -66,6 +84,9 @@ export default class RoleCe extends BaseModel {
@prop({ required: true })
roleId: string; // 角色 id
@prop({ required: true })
roleLv: number; // 玩家等级
@prop({ required: true, type: AttrCell, _id: false })
globalAttrs: AttrCell[]
@@ -81,6 +102,9 @@ export default class RoleCe extends BaseModel {
@prop({ required: true, type: ScrollAttr, _id: false })
scrollAttrs: ScrollAttr[];
@prop({ required: true, type: Attribute, _id: false })
attributes: Attribute[];
public static async findByRoleId(roleId: string) {
let result: RoleCeType = await RoleCeModel.findOne({ roleId }).lean();
return result;
+7 -2
View File
@@ -65,10 +65,15 @@ export default class User extends BaseModel {
guestTime: number; // 游客体验时间
// 防沉迷相关
@prop({ required: false, default: false })
@prop({ required: false, default: true })
hasAuthenticated: boolean; // 是否是已认证
@prop({ required: false })
@prop({ required: false, default: '1990-01-01' })
birthday: string; // 生日年月
// 暂时不使用内部防沉迷
// @prop({ required: false, default: false })
// hasAuthenticated: boolean; // 是否是已认证
// @prop({ required: false })
// birthday: string; // 生日年月
@prop({ required: false })
pi: string; // 已通过实名认证用户唯一标识
@prop({ required: false, default: 0 })
+1 -1
View File
@@ -4,7 +4,7 @@ import { DungeonFirstType } from '../../db/DungeonFirst';
class DungeonUserInfo extends RankParam {
roleId: string;
constructor(roleId: string, userInfo: RankParam) {
super(userInfo, false);
super(userInfo);
this.roleId = roleId;
}
}
+4 -24
View File
@@ -1,7 +1,6 @@
import { EXTERIOR } from "../pubUtils/dicParam";
import { WoodenHorse } from "./battleField/guildActivity";
import { RoleUpdate, RoleType } from "../db/Role";
import { reduceCe } from "../pubUtils/util";
import { GuildUpdateParam } from "../db/Guild";
import { HeroUpdate, } from "../db/Hero";
import { getSeconds } from "../pubUtils/timeUtil";
@@ -38,7 +37,7 @@ export class RankParam {
@prop({ required: true })
updatedAt?: number = 0;
constructor(role: RoleUpdate|RankParam, fromDb: boolean) {
constructor(role: RoleUpdate|RankParam) {
if(role.roleName) this.roleName = role.roleName;
if(role.lv) this.lv = role.lv;
if(role.head) this.head = role.head;
@@ -46,13 +45,7 @@ export class RankParam {
if(role.spine) this.spine = role.spine;
if(role.title) this.title = role.title;
if(role.guildName) this.guildName = role.guildName||"";
if(role.ce) {
if(fromDb && !(<RoleUpdate>role).isReducedCe) {
this.ce = reduceCe(role.ce);
} else {
this.ce = role.ce;
}
}
if(role.ce) this.ce = role.ce;
if(role.updatedAt) {
if(typeof role.updatedAt == 'number') {
this.updatedAt = role.updatedAt;
@@ -178,27 +171,14 @@ export class GuildRankParam {
@prop({ required: true })
guildCe: number;
constructor(guild: GuildUpdateParam, fromDb: boolean) {
constructor(guild: GuildUpdateParam) {
this.icon = guild.icon;
this.name = guild.name;
this.lv = guild.lv;
let leader = <RoleType>guild.leader;
let _leader = new GuildLeader(leader);
this.leader = _leader;
// console.log('*****', guild.isReducedCe, guild.guildCe, reduceCe(guild.guildCe))
if(guild.isReducedCe) {
this.guildCe = guild.guildCe;
} else {
this.guildCe = reduceCe(guild.guildCe);
}
if(fromDb && !(<GuildUpdateParam>guild).isReducedCe) {
this.guildCe = reduceCe(guild.guildCe);
} else {
this.guildCe = guild.guildCe;
}
this.guildCe = guild.guildCe;
this.memberCnt = guild.memberCnt;
}
}
+18 -62
View File
@@ -1,8 +1,6 @@
import { HERO_CE_RATIO, getAtrrNameById, ABI_TYPE_MAIN } from '../../consts';
import { CeAttrDataRole } from '../../db/Role';
import { CeAttrData } from '../../db/Hero';
import { getAtrrNameById, ABI_TYPE_MAIN } from '../../consts';
import { gameData } from '../../pubUtils/data';
import { decodeArrayListStr, reduceCe } from '../../pubUtils/util';
import { decodeArrayListStr } from '../../pubUtils/util';
import { ATTRIBUTE } from '../../pubUtils/dicParam';
export class AttributeCal {
@@ -14,34 +12,12 @@ export class AttributeCal {
this.lv = lv;
}
public setByDbData(roleAttrs: CeAttrDataRole[], heroAttrs: CeAttrData[]) {
for(let { id, fixUp: roleFix, ratioUp: roleRatio } of roleAttrs) {
let heroAttr = heroAttrs.find(heroAttr => heroAttr.id == id);
if(heroAttr) {
let { fixUp: heroFix, base: heroBase, ratioUp: heroRatio, equipUp: heroEquip } = heroAttr;
let value = this.calAttrValue(roleFix, roleRatio, heroBase, heroFix, heroRatio, heroEquip);
this.attrs.set(id, value);
} else {
let value = this.calAttrValue(roleFix, roleRatio, 0, 0, 0, 0);
this.attrs.set(id, value);
}
}
for(let { id, base: heroBase, fixUp: heroFix, ratioUp: heroRatio, equipUp: heroEquip } of heroAttrs) {
let roleAttr = roleAttrs.find(roleAttr => roleAttr.id == id);
if(!roleAttr) {
let value = this.calAttrValue(0, 0, heroBase, heroFix, heroRatio, heroEquip);
this.attrs.set(id, value);
}
}
}
public setByWarJson(attributes: {id: number, val: number}[], ratio: number = 1) {
for(let {id, val} of attributes) {
if(ABI_TYPE_MAIN.includes(id)) {
this.attrs.set(id, Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO));
this.attrs.set(id, Math.floor(val * ratio));
} else {
this.attrs.set(id, Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO));
this.attrs.set(id, Math.floor(val));
}
}
}
@@ -49,58 +25,42 @@ export class AttributeCal {
public setByMap( attributes: Map<number, number>, ratio: number = 1 ) {
for(let [id, val] of attributes) {
if(ABI_TYPE_MAIN.includes(id)) {
this.attrs.set(id, Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO));
this.attrs.set(id, Math.floor(val * ratio));
} else {
this.attrs.set(id, Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO));
this.attrs.set(id, Math.floor(val));
}
}
}
private calAttrValue(roleFix: number = 0, roleRatio: number = 0, heroBase: number = 0, heroFix: number = 0, heroRatio: number = 0, heroEquip: number = 0) {
return (heroFix + heroEquip + roleFix) * HERO_CE_RATIO + heroBase * ( HERO_CE_RATIO + heroRatio + roleRatio );
}
// private getRealAttrToMap() {
// let newMap = new Map<number, number>();
// for(let [id, val] of this.attrs) {
// if(ABI_TYPE_MAIN.includes(id)) { // 主属性
// newMap.set(id, val / HERO_CE_RATIO / HERO_CE_RATIO);
// } else {
// newMap.set(id, val / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO);
// }
// }
// return newMap;
// }
private getReduceAttrMap() {
private getAttrMap() {
let newMap = new Map<number, number>();
for(let [id, val] of this.attrs) {
newMap.set(id, reduceCe(val));
newMap.set(id, val);
}
return newMap
}
public getReduceAttributes() {
public getAttributes() {
let attrs = new Attribute();
attrs.setByMap(this.getReduceAttrMap());
attrs.setByMap(this.getAttrMap());
return attrs;
}
public getReduceAttributesToArr() {
public getAttributesToArr() {
let arr: {id: number, val: number}[] = [];
for(let [id, val] of this.getReduceAttrMap()) {
for(let [id, val] of this.getAttrMap()) {
arr.push({ id, val });
}
return arr;
}
public getReduceAttributesToString() {
let arr = this.getReduceAttributesToArr();
public getAttributesToString() {
let arr = this.getAttributesToArr();
return arr.map(cur => `${cur.id}&${cur.val}`).join('|');
}
public getReduceMainAttributes() {
let attribute = this.getReduceAttributes();
public getMainAttributes() {
let attribute = this.getAttributes();
return attribute.getMainAttr();
}
@@ -126,12 +86,8 @@ export class AttributeCal {
return Math.floor(ce);
}
public calSubAttrCeAndReduce() {
return Math.floor(this.calCe(3) / HERO_CE_RATIO / HERO_CE_RATIO);
}
public calCelAndReduce() {
return Math.floor(this.calCe() / HERO_CE_RATIO / HERO_CE_RATIO);
public calSubAttrCe() {
return Math.floor(this.calCe(3));
}
}
+1 -6
View File
@@ -1,7 +1,6 @@
import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Talent } from '../../db/Hero';
import { gameData } from '../../pubUtils/data';
import { reduceCe } from '../../pubUtils/util';
export interface CreateHeroParam extends HeroUpdate {
hid: number;
count: number;
@@ -73,11 +72,7 @@ export class HeroParam {
this.hName = hero.hName;
this.exp = hero.exp;
this.lv = hero.lv;
if(hero.isReducedCe) {
this.ce = hero.ce;
} else {
this.ce = reduceCe(hero.ce);
}
this.ce = hero.ce;
this.star = hero.star;
this.starStage = hero.starStage;
this.colorStar = hero.colorStar;
+1 -1
View File
@@ -335,7 +335,7 @@ export function getBossHpByWarId(warId: number) {
if (relation === 2) {
let newAttr = new AttributeCal();
newAttr.setByWarJson(attribute, 1);
let attrJson = newAttr.getReduceAttributes();
let attrJson = newAttr.getAttributes();
const hp = attrJson.hp || 0;
if (hp > 0) {
@@ -1,5 +1,5 @@
// 装备强化表
import { readFileAndParse, parseGoodStr, decodeArrayListStr } from '../util'
import { readFileAndParse, decodeArrayListStr } from '../util'
import { FILENAME } from '../../consts'
export interface DicEquipStrengthAttr {
File diff suppressed because it is too large Load Diff
+1 -16
View File
@@ -1,21 +1,17 @@
import { STATUS } from './../consts/statusCode';
import { HeroModel, HeroType } from '../db/Hero';
import { isNumber } from 'underscore';
const csprng = require('csprng');
import fs = require('fs');
import path = require('path');
import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON, WAR_TYPE, LINEUP_NUM } from '../consts';
import { ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON, WAR_TYPE } from '../consts';
import { findIndex } from 'underscore';
import { getTimeFunM } from './timeUtil';
import { Floor } from '../domain/activityField/gachaField';
import { WhiteListModel } from '../db/RegionWhiteList';
import { RewardInter } from './interface';
import { RoleType } from '../db/Role';
import { RoleCeModel } from '../db/RoleCe';
import { CalCe } from '../services/role/calCe';
const randomName = require("chinese-random-name");
const moment = require('moment');
const crypto = require('crypto');
@@ -564,17 +560,6 @@ export function mergeSameGoods(goods: Array<{ id: number, count: number }>) {
return resGoods;
}
export function returnHeroCeRatio(hero: HeroType) {
let ce = reduceCe(hero.ce);
return Object.assign(hero, { ce });
}
// 缩小战力
export function reduceCe(ce: number = 0) {
return Math.floor(ce / HERO_CE_RATIO / HERO_CE_RATIO)
}
// 获取全部属性
export function getAllAttrStage() {
let attrs = new Array<number>(); // 有升级的属性 1-hp 2-atk 3-def 4-mdef 5-agi 6-luk