远征结算和宝箱领取

This commit is contained in:
luying
2020-10-14 20:17:05 +08:00
parent 57d60be3a2
commit 2b1575516f
11 changed files with 1819 additions and 116 deletions
@@ -1,8 +1,10 @@
import { ActionPointModel } from '../../../db/ActionPoint';
import { BattleDropModel } from '../../../db/BattleDrop';
import { ExpeditionPointModel } from '../../../db/ExpeditionPoint';
import { RoleModel } from '../../../db/Role';
import { getWarById, getWarJsons } from '../../../util/gamedata';
import { getWarById, getWarJsons, getGamedata } from '../../../util/gamedata';
import { decodeStr, Reward } from '../../../util/util';
import { ACTION_POIN, BATTLE_REWARD_TYPE, WAR_JSON_ATTRIBUTE_TYPE } from '../../../consts/consts';
@@ -121,6 +123,8 @@ export class WarReward {
public async saveReward(num: number) {
this.rewards = new Array();
let warType = this.warInfo.warType;
await this.handleFixReward(num);
await this.handleConditionReward(num);
await this.handleRandomReward(num);
@@ -141,7 +145,7 @@ export async function matchPlayers(scale: number, range: number, myCe: number ,e
return false
}
export async function matchRobots(scale: number, myCe: number, robotCe: number, warJsonIndex:any, role, enemyObj: {enemyFrom: number, enemyId: string, enemies: Array<any> }) {
export async function matchRobots(scale: number, myCe: number, robotCe: number, warJsonIndex:any, lv: number, enemyObj: {enemyFrom: number, enemyId: string, enemies: Array<any> }) {
let {json: dicWarJson, fileName } = getWarJsons(warJsonIndex);
if(dicWarJson) {
enemyObj.enemyFrom = 2;
@@ -152,8 +156,9 @@ export async function matchRobots(scale: number, myCe: number, robotCe: number,
let attribute = decodeWarJsonAttribute(enemy.attribute); // 格式:{'hp':1000, ...}
for(let value in attribute) {
attribute[value] *= ratio;
attribute[value] = Math.round(attribute[value]);
}
enemyObj.enemies.push({...enemy, attribute, lv: role.lv});
enemyObj.enemies.push({...enemy, attribute, lv});
}
return true
@@ -172,4 +177,37 @@ export function decodeWarJsonAttribute(attribute) {
}
}
return obj
}
export async function getPointRewardStatus(roleId: string) {
let role = await RoleModel.findByRoleId(roleId);
let {expeditionPoint} = role;
let dicExpeditionPoint = getGamedata('dic_expedition_point');
let pointRewards = {
expeditionPoint,
rewards: dicExpeditionPoint.map(cur => {
return { point: cur.point, received: false }
})
};
let pointStatusInDatabase = await ExpeditionPointModel.getExpeditionPoint(roleId);
if(pointStatusInDatabase) {
let { rewards = [] } = pointStatusInDatabase;
pointRewards.rewards.forEach(cur => {
let obj = rewards.find(ccur => ccur.point == cur.point);
if(obj) cur.received = obj.received;
});
}
return pointRewards
}
export async function getCEScaleAndRange(roleId: string, curDicExpedition: any) {
// 匹配,判断是不是新手期
const role = await RoleModel.findByRoleId(roleId);
let now = new Date();
let today = now.setHours(0,0,0,0);
let isNew = today - role.createdAt.getTime() <= 3*24*60*60*1000;
let scale = isNew?curDicExpedition.CEScaleNew:curDicExpedition.CEScale;
let range = isNew?curDicExpedition.CERangeNew:curDicExpedition.CERange;
return {scale, range, lv: role.lv}
}