形象:设置头像相框形象
This commit is contained in:
+47
-15
@@ -2,7 +2,8 @@ import { prop, mongoose, Ref } from '@typegoose/typegoose';
|
||||
import { DicWarJson } from '../pubUtils/dictionary/DicWarJson';
|
||||
import { Attribute } from './roleField/attribute';
|
||||
import Hero, { HeroType } from '../db/Hero';
|
||||
import { FIGURE } from '../pubUtils/dicParam';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { nowSeconds, getBeforeDaySeconds } from '../pubUtils/timeUtil';
|
||||
|
||||
// 从玩家数据中覆盖warjson的部分字段
|
||||
export class PvpHeroInfo {
|
||||
@@ -202,20 +203,51 @@ export class Teraph {
|
||||
luk: number;
|
||||
}
|
||||
|
||||
export class Head {
|
||||
@prop({ required: true, default: FIGURE.DEFAULT_HEAD })
|
||||
export class Figure {
|
||||
@prop({ required: true, default: 0 })
|
||||
id: number; // 头像id
|
||||
@prop({ required: true, default: false })
|
||||
enable: boolean; // 是否启用
|
||||
@prop({ required: true })
|
||||
time: number; // 到期时间
|
||||
}
|
||||
enable: boolean = false; // 是否启用
|
||||
@prop({ required: false, default: 0 })
|
||||
time?: number; // 到期时间
|
||||
@prop({ required: true, default: [] })
|
||||
unlockedType: number[] = []; // 当前已经解锁了的type
|
||||
|
||||
export class Frame {
|
||||
@prop({ required: true, default: FIGURE.DEFAULT_FRAME })
|
||||
id: number; // 相框id
|
||||
@prop({ required: true, default: false })
|
||||
enable: boolean; // 是否启用
|
||||
@prop({ required: true })
|
||||
time: number; // 到期时间
|
||||
}
|
||||
public get status () { // 虚拟字段status,当前头像是否已经解锁
|
||||
let dicGoods = gameData.goods.get(this.id);
|
||||
if(!dicGoods) return false;
|
||||
|
||||
let hasUnlockedAll = true;
|
||||
for(let {type} of dicGoods.condition) {
|
||||
if(!this.unlockedType.includes(type)) {
|
||||
hasUnlockedAll = false; break;
|
||||
}
|
||||
}
|
||||
if(!hasUnlockedAll) return true;
|
||||
|
||||
if(dicGoods.timeLimit) { // 超时
|
||||
if(this.time < nowSeconds()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
constructor(id: number, unlockedType?: number[]) {
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
if(dicGoods) {
|
||||
this.id = id;
|
||||
if(!unlockedType) unlockedType = dicGoods.condition.map(cur => cur.type);
|
||||
this.unlockedType = unlockedType;
|
||||
|
||||
let hasUnlockedAll = true;
|
||||
for(let {type} of dicGoods.condition) {
|
||||
if(!this.unlockedType.includes(type)) {
|
||||
hasUnlockedAll = false; break;
|
||||
}
|
||||
}
|
||||
if(hasUnlockedAll && dicGoods.timeLimit) {
|
||||
this.time = getBeforeDaySeconds(-1 * dicGoods.timeLimit); // timeLimit天以后
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user