战力:获取显示数据
This commit is contained in:
@@ -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
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
Reference in New Issue
Block a user