形象:解锁头像相框形象

This commit is contained in:
luying
2021-03-11 19:29:51 +08:00
parent e888ab916d
commit 95f4221217
13 changed files with 145 additions and 65 deletions
+10 -32
View File
@@ -208,46 +208,24 @@ export class Figure {
id: number; // 头像id
@prop({ required: true, default: false })
enable: boolean = false; // 是否启用
@prop({ required: false, default: 0 })
@prop({ required: false })
time?: number; // 到期时间
@prop({ required: true, default: [] })
unlockedType: number[] = []; // 当前已经解锁了的type
@prop({ required: true, default: false })
unlocked: boolean = false; // 是否已解锁
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;
}
if(!this.unlocked) return this.unlocked; // 未解锁
if(this.time && 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天以后
}
}
constructor(id: number, unlocked: boolean, time?: number, enable = false) {
this.id = id;
this.unlocked = unlocked;
if(time) this.time = time;
this.enable = enable;
}
}