活动:上上签按次数重置

This commit is contained in:
luying
2022-05-27 17:28:18 +08:00
parent 1024f4d34d
commit 3737c888fd

View File

@@ -1,5 +1,6 @@
import { ActivityModelType } from '../../db/Activity';
import { ActivityRechargeMoneyModelType } from '../../db/ActivityRechargeMoney';
import { getZeroPointD } from '../../pubUtils/timeUtil';
import { getRandEelmWithWeight, getRandSingleEelm } from '../../pubUtils/util';
import { ActivityBase } from './activityField';
@@ -29,6 +30,8 @@ export class RechargeMoneyPool {
quality: number; // 物品的品级
hasGet: boolean = false; // 是否已经获取过了
getNumBeforeToday: number = 0; // 获取次数
getNumToday: number = 0;
constructor(data: RechargeMoneyPoolInDb) {
this.id = data.id;
@@ -37,8 +40,21 @@ export class RechargeMoneyPool {
this.quality = data.quality;
}
setHasGet(hasGet: boolean) {
this.hasGet = hasGet;
setRecord(record: ActivityRechargeMoneyModelType) {
this.hasGet = true;
if(record.rewardTime < getZeroPointD()) {
this.getNumBeforeToday ++;
} else {
this.getNumToday ++;
}
}
unsetHasGet() {
this.hasGet = false;
}
setHasGet() {
this.hasGet = true;
}
}
@@ -89,7 +105,7 @@ export class RechargeMoneyData extends ActivityBase {
}
}
let result = getRandSingleEelm(elems);
result.setHasGet(true);
result.setHasGet();
return result;
}
@@ -106,7 +122,21 @@ export class RechargeMoneyData extends ActivityBase {
}
if(record.poolId) {
let pool = this.findItemFromPool(record.poolId);
if(pool) pool.setHasGet(true);
if(pool) {
pool.setRecord(record);
}
}
}
this.resetPool();
}
private resetPool() {
let beforeNums = this.pool.map(cur => cur.getNumBeforeToday);
let min = Math.min(...beforeNums);
let max = Math.max(...beforeNums);
if(max != 0 && max == min) { // 当所有奖池都抽过一遍的时候,第二天五点,重置
for(let item of this.pool) {
if(item.getNumToday <= 0) item.unsetHasGet();
}
}
}