活动:上上签按次数重置
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { ActivityModelType } from '../../db/Activity';
|
import { ActivityModelType } from '../../db/Activity';
|
||||||
import { ActivityRechargeMoneyModelType } from '../../db/ActivityRechargeMoney';
|
import { ActivityRechargeMoneyModelType } from '../../db/ActivityRechargeMoney';
|
||||||
|
import { getZeroPointD } from '../../pubUtils/timeUtil';
|
||||||
import { getRandEelmWithWeight, getRandSingleEelm } from '../../pubUtils/util';
|
import { getRandEelmWithWeight, getRandSingleEelm } from '../../pubUtils/util';
|
||||||
import { ActivityBase } from './activityField';
|
import { ActivityBase } from './activityField';
|
||||||
|
|
||||||
@@ -29,6 +30,8 @@ export class RechargeMoneyPool {
|
|||||||
quality: number; // 物品的品级
|
quality: number; // 物品的品级
|
||||||
|
|
||||||
hasGet: boolean = false; // 是否已经获取过了
|
hasGet: boolean = false; // 是否已经获取过了
|
||||||
|
getNumBeforeToday: number = 0; // 获取次数
|
||||||
|
getNumToday: number = 0;
|
||||||
|
|
||||||
constructor(data: RechargeMoneyPoolInDb) {
|
constructor(data: RechargeMoneyPoolInDb) {
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
@@ -37,8 +40,21 @@ export class RechargeMoneyPool {
|
|||||||
this.quality = data.quality;
|
this.quality = data.quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
setHasGet(hasGet: boolean) {
|
setRecord(record: ActivityRechargeMoneyModelType) {
|
||||||
this.hasGet = hasGet;
|
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);
|
let result = getRandSingleEelm(elems);
|
||||||
result.setHasGet(true);
|
result.setHasGet();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +122,21 @@ export class RechargeMoneyData extends ActivityBase {
|
|||||||
}
|
}
|
||||||
if(record.poolId) {
|
if(record.poolId) {
|
||||||
let pool = this.findItemFromPool(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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user