任务:埋点30/70

This commit is contained in:
luying
2021-04-18 11:21:04 +08:00
parent bc07e1ea31
commit 9f4f346447
38 changed files with 1088 additions and 692 deletions

View File

@@ -3,7 +3,8 @@
*/
import { ActionPointModel } from '../db/ActionPoint';
import { ACTION_POIN } from '../consts';
import { ACTION_POIN, TASK_TYPE } from '../consts';
import { checkTask } from './taskService';
export async function getAp(now: number, roleId: string) {
let dataAp = await ActionPointModel.getAp(roleId);
@@ -29,7 +30,7 @@ export async function getAp(now: number, roleId: string) {
}
}
export async function setAp(now: number, roleId: string, changeAp: number) {
export async function setAp(now: number, roleId: string, sid: string, changeAp: number) {
let ApResult = await getAp(now, roleId);
let { ap, maxAp, refTime, apRemainTime, isOver } = ApResult; // 更新ap
ap += changeAp;
@@ -41,5 +42,9 @@ export async function setAp(now: number, roleId: string, changeAp: number) {
await ActionPointModel.saveAp(roleId, ap, refTime);
if(isOver && ap < maxAp) apRemainTime = Math.floor(ACTION_POIN.PER / 1000); // 特殊处理
if(changeAp < 0) {
await checkTask(roleId, sid, TASK_TYPE.BATTLE_COST_AP, -1 * changeAp, true, {});
}
return {ap, maxAp, refTime, apRemainTime}
}