数数:消耗来源
This commit is contained in:
@@ -4,7 +4,7 @@ import { HeroModel, HeroType, } from '../db/Hero';
|
||||
import { ItemModel } from '../db/Item';
|
||||
import { EquipModel, RandSe, Holes, RandMain, equipUpdate } from './../db/Equip';
|
||||
import { gameData, getQuenchByQualityAndGrade, getQuenchGradeByValue } from './data';
|
||||
import { RANDOM_SE_COUNT, ITID, CURRENCY_BY_TYPE, CURRENCY_TYPE, ROLE_SELECT, FIGURE_UNLOCK_CONDITION, CONSUME_TYPE, HERO_SYSTEM_TYPE, TASK_TYPE } from '../consts';
|
||||
import { RANDOM_SE_COUNT, ITID, CURRENCY_BY_TYPE, CURRENCY_TYPE, ROLE_SELECT, FIGURE_UNLOCK_CONDITION, CONSUME_TYPE, HERO_SYSTEM_TYPE, TASK_TYPE, ITEM_CHANGE_REASON } from '../consts';
|
||||
import { getRandValueByMinMax, getRandEelm } from './util';
|
||||
|
||||
import { findWhere } from 'underscore';
|
||||
@@ -61,26 +61,26 @@ export async function addSkin(roleId: string, roleName: string, skinId: number,
|
||||
}
|
||||
}
|
||||
|
||||
export async function addBags(roleId: string, roleName: string, datas: { id: number, count: number }[]) {
|
||||
export async function addBags(roleId: string, roleName: string, datas: { id: number, count: number }[], reason: number) {
|
||||
let items: { id: number, count: number }[] = [];
|
||||
for(let data of datas) {
|
||||
let item = await addBag(roleId, roleName, data);
|
||||
let item = await addBag(roleId, roleName, data, reason);
|
||||
items.push(item)
|
||||
}
|
||||
return { items }
|
||||
}
|
||||
|
||||
export async function addBag(roleId: string, roleName: string, data: { id: number, count: number }) {
|
||||
export async function addBag(roleId: string, roleName: string, data: { id: number, count: number }, reason: number) {
|
||||
let { id, count } = data;
|
||||
let { name: itemName, itid, hid } = gameData.goods.get(id);
|
||||
let { type } = ITID.get(itid);
|
||||
|
||||
let item = await ItemModel.increaseItem(roleId, id, count, { roleId, roleName, itemName, id, type, hid });
|
||||
return { id: item.id, count: item.count };
|
||||
return { id: item.id, count: item.count, inc: count, reason };
|
||||
}
|
||||
|
||||
|
||||
export async function addEquips(roleId: string, roleName: string, weapons: { id: number, hid?: number }[]) {
|
||||
export async function addEquips(roleId: string, roleName: string, weapons: { id: number, hid?: number }[], reason: number) {
|
||||
let equipInfos: equipUpdate[] = [];
|
||||
for(let weapon of weapons) {
|
||||
let info = await getAddEquipInfo(roleId, roleName, weapon);
|
||||
@@ -95,7 +95,9 @@ export async function addEquips(roleId: string, roleName: string, weapons: { id:
|
||||
pushMessages = [...pushMessages, ...pushMessage];
|
||||
}
|
||||
|
||||
return { equips, pushMessages }
|
||||
return { equips: equips.map(equip => {
|
||||
return { ...equip, inc: 1, reason }
|
||||
}), pushMessages }
|
||||
}
|
||||
|
||||
export async function getAddEquipInfo(roleId: string, roleName: string, weapon: { id: number, hid?: number }) {
|
||||
@@ -197,20 +199,26 @@ export function getHonourObject(count: number) {
|
||||
for (let { type, paramHid, paramFavourLv, paramSkinId, paramWinStreakNum } of conditions) {
|
||||
let canUnLockList = gameData.figureCondition.get(type);
|
||||
if (canUnLockList) {
|
||||
let reason = 0;
|
||||
|
||||
for (let { id, params, gid } of canUnLockList) {
|
||||
let flag = false; // 是否达成条件
|
||||
if (type == FIGURE_UNLOCK_CONDITION.GET_HERO) {
|
||||
let [hid] = params;
|
||||
if (paramHid == hid) flag = true;
|
||||
reason = ITEM_CHANGE_REASON.GET_HERO_UNLOCK_FIGURE;
|
||||
} else if (type == FIGURE_UNLOCK_CONDITION.HERO_FAVOR) {
|
||||
let [hid, favourLv] = params;
|
||||
if (paramHid == hid && paramFavourLv >= favourLv) flag = true;
|
||||
reason = ITEM_CHANGE_REASON.HERO_FAVOR_UNLOCK_FIGURE;
|
||||
} else if (type == FIGURE_UNLOCK_CONDITION.GET_SKIN) {
|
||||
let [id] = params;
|
||||
if (paramSkinId == id) flag = true;
|
||||
reason = ITEM_CHANGE_REASON.ADD_SKIN_UNLOCK_FIGURE;
|
||||
} else if (type == FIGURE_UNLOCK_CONDITION.PVP_WIN_SERIES) {
|
||||
let [winStreakNum] = params;
|
||||
if (paramWinStreakNum >= winStreakNum) flag = true;
|
||||
reason = ITEM_CHANGE_REASON.PVP_SERIES_UNLOCK_FIGURE;
|
||||
}
|
||||
if (!flag) continue;
|
||||
let dicGood = gameData.goods.get(gid);
|
||||
@@ -219,13 +227,13 @@ export function getHonourObject(count: number) {
|
||||
if (!dicItid) continue;
|
||||
|
||||
if (dicItid.type == CONSUME_TYPE.HEAD) {
|
||||
let figure = unlockSingleFigure(heads, gid, false, id);
|
||||
let figure = unlockSingleFigure(heads, gid, reason, false, id);
|
||||
if (figure && figure.unlocked) figureInfo.heads.push(figure);
|
||||
} else if (dicItid.type == CONSUME_TYPE.FRAME) {
|
||||
let figure = unlockSingleFigure(frames, gid, false, id);
|
||||
let figure = unlockSingleFigure(frames, gid, reason, false, id);
|
||||
if (figure && figure.unlocked) figureInfo.frames.push(figure);
|
||||
} else if (dicItid.type == CONSUME_TYPE.SPINE) {
|
||||
let figure = unlockSingleFigure(spines, gid, false, id);
|
||||
let figure = unlockSingleFigure(spines, gid, reason, false, id);
|
||||
if (figure && figure.unlocked) figureInfo.spines.push(figure);
|
||||
} else {
|
||||
continue;
|
||||
@@ -255,7 +263,7 @@ export async function unlockFigure(roleId: string, conditions: { type: number, p
|
||||
|
||||
|
||||
// 直接获得形象/相框
|
||||
export async function addFigure(roleId: string, ids: number[]) {
|
||||
export async function addFigure(roleId: string, ids: number[], reason: number) {
|
||||
let role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
|
||||
|
||||
if (!role) return false;
|
||||
@@ -269,13 +277,13 @@ export async function addFigure(roleId: string, ids: number[]) {
|
||||
if (!dicItid) continue;
|
||||
|
||||
if (dicItid.type == CONSUME_TYPE.HEAD) {
|
||||
let figure = unlockSingleFigure(heads, gid, true);
|
||||
let figure = unlockSingleFigure(heads, gid, reason, true);
|
||||
if (figure && figure.unlocked) figureInfo.heads.push(figure);
|
||||
} else if (dicItid.type == CONSUME_TYPE.FRAME) {
|
||||
let figure = unlockSingleFigure(frames, gid, true);
|
||||
let figure = unlockSingleFigure(frames, gid, reason, true);
|
||||
if (figure && figure.unlocked) figureInfo.frames.push(figure);
|
||||
} else if (dicItid.type == CONSUME_TYPE.SPINE) {
|
||||
let figure = unlockSingleFigure(spines, gid, true);
|
||||
let figure = unlockSingleFigure(spines, gid, reason, true);
|
||||
if (figure && figure.unlocked) figureInfo.spines.push(figure);
|
||||
} else {
|
||||
continue;
|
||||
@@ -293,7 +301,7 @@ export async function addFigure(roleId: string, ids: number[]) {
|
||||
* @param unlockDirect 是否不计算解锁条件直接解锁
|
||||
* @param conditionId 条件id
|
||||
*/
|
||||
function unlockSingleFigure(dbFigures: Figure[], id: number, unlockDirect = false, conditionId?: number) {
|
||||
function unlockSingleFigure(dbFigures: Figure[], id: number, reason: number, unlockDirect = false, conditionId?: number) {
|
||||
let figure = dbFigures.find(cur => cur.id == id);
|
||||
if (!figure) {
|
||||
figure = new Figure(id, false);
|
||||
@@ -325,6 +333,8 @@ function unlockSingleFigure(dbFigures: Figure[], id: number, unlockDirect = fals
|
||||
}
|
||||
}
|
||||
|
||||
figure.inc = 1;
|
||||
figure.reason = reason;
|
||||
return figure
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DEFAULT_HERO_LV, FIGURE_UNLOCK_CONDITION, LINEUP_NUM, REDIS_KEY, STATUS, TASK_TYPE } from "../consts";
|
||||
import { DEFAULT_HERO_LV, FIGURE_UNLOCK_CONDITION, ITEM_CHANGE_REASON, LINEUP_NUM, REDIS_KEY, STATUS, TASK_TYPE } from "../consts";
|
||||
import { SkinModel } from "../db/Skin";
|
||||
import { DEFAULT_HEROES, HERO_SYSTEM_TYPE } from "../consts";
|
||||
import { HeroModel, HeroSkin, HeroType, HeroUpdate } from "../db/Hero";
|
||||
@@ -261,12 +261,13 @@ export class CreateHeroes extends UpdateHeroes {
|
||||
private taskPushMessage: TaskListReturn[] = [];
|
||||
private activityTaskPushMessage = [];
|
||||
private figureInfos: { heads: Figure[], frames: Figure[], spines: Figure[] }[] = [];
|
||||
private skinPushMessages: { heros: {skins: HeroSkin[], hid: number}[], skins: {id: number, hid: number }[]} = { heros: [], skins: [] };
|
||||
private skinPushMessages: { heros: {skins: HeroSkin[], hid: number}[], skins: {id: number, hid: number, inc: number, reason: number }[]} = { heros: [], skins: [] };
|
||||
|
||||
private async getSkinsOfThisHero(hid: number, initSkinInfo: SkinUpdate, isInit: boolean) {
|
||||
let allSkins = isInit? []: await SkinModel.findbyRoleAndHid(this.roleId, hid);
|
||||
let skin = await SkinModel.insertSkins(this.roleId, this.roleName, [initSkinInfo]);
|
||||
this.skinPushMessages.skins.push(...skin);
|
||||
let skinInfos = skin.map(cur => ({ id: cur.id, hid, inc: 1, reason: ITEM_CHANGE_REASON.GET_HERO_UNLOCK_SKIN}))
|
||||
this.skinPushMessages.skins.push(...skinInfos);
|
||||
if(skin) allSkins.push(...skin);
|
||||
let skins: { id: number, skin: string, enable: boolean, skinId: number }[] = [];
|
||||
for(let skin of allSkins) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { HeroModel, HeroType } from '../db/Hero';
|
||||
const csprng = require('csprng');
|
||||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, ROBOT_SYS_TYPE, } from '../consts';
|
||||
import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON, WAR_TYPE } from '../consts';
|
||||
|
||||
import { findIndex } from 'underscore';
|
||||
import { getTimeFunM } from './timeUtil';
|
||||
@@ -679,4 +679,51 @@ export async function checkWhiteList(tel: string, ip: string, auth: number) {
|
||||
if(!!result) return true;
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export function getReasonByWarType(warType: number) {
|
||||
switch(warType) {
|
||||
case WAR_TYPE.NORMAL:
|
||||
return ITEM_CHANGE_REASON.NORMAL_BATTLE_END;
|
||||
case WAR_TYPE.VESTIGE:
|
||||
return ITEM_CHANGE_REASON.VESTIGE_BATTLE_END;
|
||||
case WAR_TYPE.EVENT:
|
||||
return ITEM_CHANGE_REASON.EVENT_BATTLE_END;
|
||||
case WAR_TYPE.DAILY:
|
||||
return ITEM_CHANGE_REASON.DAILY_BATTLE_END;
|
||||
case WAR_TYPE.EXPEDITION:
|
||||
return ITEM_CHANGE_REASON.EXPEDITION_BATTLE_END;
|
||||
case WAR_TYPE.MYSTERY:
|
||||
return ITEM_CHANGE_REASON.MYSTERY_BATTLE_END;
|
||||
case WAR_TYPE.WARLOARDS:
|
||||
return ITEM_CHANGE_REASON.WARLOARDS_BATTLE_END;
|
||||
case WAR_TYPE.TOWER:
|
||||
return ITEM_CHANGE_REASON.TOWER_BATTLE_END;
|
||||
case WAR_TYPE.PVP:
|
||||
return ITEM_CHANGE_REASON.PVP_BATTLE_END;
|
||||
// case WAR_TYPE.GUILD_ACTIVITY:
|
||||
// return ITEM_CHANGE_REASON.GUILD_ACTIVITY_BATTLE_END;
|
||||
case WAR_TYPE.GUILD_TRAIN:
|
||||
return ITEM_CHANGE_REASON.TRAIN_BATTLE_END;
|
||||
case WAR_TYPE.MAIN_ELITE:
|
||||
return ITEM_CHANGE_REASON.MAIN_ELITE_BATTLE_END;
|
||||
// case WAR_TYPE.MYSTERY_ELITE:
|
||||
// return ITEM_CHANGE_REASON.MYSTERY_ELITE_BATTLE_END;
|
||||
case WAR_TYPE.BRANCH:
|
||||
return ITEM_CHANGE_REASON.BRANCH_BATTLE_END;
|
||||
case WAR_TYPE.ACT_TREASURE_HUNT:
|
||||
return ITEM_CHANGE_REASON.ACT_TREASURE_HUNT_BATTLE_END;
|
||||
case WAR_TYPE.ACT_SELF_SHOP:
|
||||
return ITEM_CHANGE_REASON.ACT_SELF_SHOP_BATTLE_END;
|
||||
case WAR_TYPE.ACT_DAILY_GK:
|
||||
return ITEM_CHANGE_REASON.ACT_DAILY_GK_BATTLE_END;
|
||||
case WAR_TYPE.ACT_NEW_HERO_GK:
|
||||
return ITEM_CHANGE_REASON.ACT_NEW_HERO_GK_BATTLE_END;
|
||||
case WAR_TYPE.TRY:
|
||||
return ITEM_CHANGE_REASON.TRY_BATTLE_END;
|
||||
case WAR_TYPE.BOSS:
|
||||
return ITEM_CHANGE_REASON.BOSS_BATTLE_END;
|
||||
default:
|
||||
return ITEM_CHANGE_REASON.NORMAL_BATTLE_END;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user