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