添加藏宝图按体力掉落
This commit is contained in:
+22
-1
@@ -64,7 +64,13 @@ const itid_array = [
|
||||
{ id: 23, name: '消耗类物品(材料类)', goodType: GOOD_TYPE.CONSUMES, field: "consumeGoods" },
|
||||
{ id: 24, name: '消耗类物品(宝箱类)', goodType: GOOD_TYPE.CONSUMES, field: "consumeGoods" },
|
||||
{ id: 26, name: '武将碎片', goodType: GOOD_TYPE.CONSUMES, field: "souls" },
|
||||
{ id: 27, name: '货币', goodType: GOOD_TYPE.CONSUMES, field: "currency", isCurrency: true }
|
||||
{ id: 27, name: '货币', goodType: GOOD_TYPE.CONSUMES, field: "currency", isCurrency: true },
|
||||
{ id: 28, name: '藏宝图', goodType: GOOD_TYPE.CONSUMES, field: "consumeGoods" },
|
||||
{ id: 29, name: '礼器', goodType: GOOD_TYPE.EQUIP },
|
||||
{ id: 30, name: '宝甲', goodType: GOOD_TYPE.EQUIP },
|
||||
{ id: 31, name: '名驹', goodType: GOOD_TYPE.EQUIP },
|
||||
{ id: 32, name: '典籍', goodType: GOOD_TYPE.EQUIP },
|
||||
{ id: 33, name: '神兵', goodType: GOOD_TYPE.EQUIP }
|
||||
];
|
||||
|
||||
export const ITID = new Map<number, {id: number, name: string, goodType: number, field?: string, isCurrency?: boolean}>();
|
||||
@@ -104,6 +110,21 @@ export const WAR_TYPE = {
|
||||
MYSTERY_ELITE: 13 // 秘境精英
|
||||
};
|
||||
|
||||
// 藏宝图掉落参数
|
||||
export const BLUEPRT_CONST = {
|
||||
REFRESH_TIME: 5, // 每天几点刷新
|
||||
DAILY_CNT: 5, // 每天最多掉落多少张
|
||||
PER_AP: 15 // 每多少体力掉落1张藏宝图
|
||||
};
|
||||
|
||||
// 藏宝图概率
|
||||
export const BLUEPRT_CHANCE = [
|
||||
{min: 20, max: 40, chance: "1&100"},
|
||||
{min: 41, max: 60, chance: "1&70|2&30"},
|
||||
{min: 61, max: 80, chance: "2&70|3&30"},
|
||||
{min: 81, max: 100, chance: "2&60|3&40"}
|
||||
];
|
||||
|
||||
// 事件,是否开启保存随机记录方式
|
||||
export const EVENT_RANDOM_TYPE_ONE_OPEN = false;
|
||||
// 奇遇事件每次刷新几个
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
||||
|
||||
/**
|
||||
* 藏宝图掉落记录
|
||||
*/
|
||||
@index({ roleId: 1, battleId: 1 })
|
||||
|
||||
export default class BattleBlueprtDrop extends BaseModel {
|
||||
@prop({ required: true })
|
||||
roleId: string; // 角色 id
|
||||
@prop({ required: true })
|
||||
refTime: Date; // 刷新日期
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
getNum: number; // 获取次数,当curCostAp超过ap重置
|
||||
@prop({ required: true })
|
||||
curCostAp: number; // 这一轮消耗的ap,单独设置出了以防以后修改PER_AP
|
||||
@prop({ required: true, default: 0 })
|
||||
getSum: number; // 获取道具的全部次数
|
||||
@prop({ required: true })
|
||||
costAp: number; // 当天消耗的ap
|
||||
|
||||
public static async findByTime(roleId: string, refTime: Date, lean = true) {
|
||||
const result = await BattleBlueprtDropModel.findOneAndUpdate({ roleId, refTime }, {}, {new: true, upsert: true}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateByTime(roleId: string, refTime: Date, params: {getNum: number, curCostAp: number, getSum: number, costAp: number}, lean = true) {
|
||||
const result = await BattleBlueprtDropModel.findOneAndUpdate({roleId, refTime}, {$set: params}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async deleteAccount(roleId: string, lean = true) {
|
||||
let result = await BattleBlueprtDropModel.deleteMany({roleId}).lean(lean);
|
||||
return result||{};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export const BattleBlueprtDropModel = getModelForClass(BattleBlueprtDrop);
|
||||
@@ -2,6 +2,7 @@ import fs = require('fs');
|
||||
import path = require('path');
|
||||
import { ABI_TYPE } from '../consts/abilityConst';
|
||||
import { decodeIdCntArrayStr } from './util';
|
||||
import { IT_TYPE } from '../consts/consts';
|
||||
|
||||
let gamedata = {};
|
||||
const wars = ['dic_zyz_gk_main', 'dic_zyz_gk_mainElite', 'dic_zyz_gk_daily', 'dic_zyz_gk_event', 'dic_zyz_gk_tower', 'dic_zyz_gk_expedition', 'dic_zyz_gk_dungeon','dic_zyz_gk_dungeonElite']; // 关卡相关的表
|
||||
@@ -19,6 +20,8 @@ const expeditionInfo = new Map<number, any> ();
|
||||
const comBtlInfo = new Map<number, {quality: number, name: string, assistanceTime: number, assistanceLevel: number}>();
|
||||
const btlBossHp = new Map<number, number>();
|
||||
const blueprtBossHp = new Map<number, number>();
|
||||
const goodInfo = new Map<number, any>();
|
||||
const blueprt = new Map<number, Array<number>>();
|
||||
|
||||
function parseWarData() {
|
||||
let result = null;
|
||||
@@ -190,6 +193,21 @@ function parseComBtlData() {
|
||||
});
|
||||
}
|
||||
|
||||
function parseGood() {
|
||||
const file = 'dic_goods';
|
||||
const data = gamedata['jsons'][file] || [];
|
||||
data.forEach(elem => {
|
||||
if (elem && elem.good_id) {
|
||||
goodInfo.set(elem.good_id, elem);
|
||||
if(elem.itid == IT_TYPE.BLUEPRT) {
|
||||
let arr = blueprt.get(elem.quality)||new Array();
|
||||
arr.push(elem.good_id);
|
||||
blueprt.set(elem.quality, arr);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initData (folder: string) {
|
||||
if(!gamedata.hasOwnProperty(folder)) {
|
||||
gamedata[folder] = {};
|
||||
@@ -227,6 +245,7 @@ function parseData() {
|
||||
parseOlySeidList();
|
||||
parseExpedition();
|
||||
parseComBtlData();
|
||||
parseGood();
|
||||
}
|
||||
|
||||
initData('jsons'); // 加载一般json
|
||||
@@ -258,10 +277,11 @@ export function getTowerDataByLv(lv: number) {
|
||||
}
|
||||
|
||||
export function getGoodById(gid) {
|
||||
let goodsInfo = gamedata['jsons']['dic_goods']||[];
|
||||
return goodsInfo.find(cur => {
|
||||
return cur.good_id == gid
|
||||
});
|
||||
return goodInfo.get(gid);
|
||||
}
|
||||
|
||||
export function getBluePrtByQuality(quality: number) {
|
||||
return blueprt.get(quality)|| new Array<number>();
|
||||
}
|
||||
|
||||
export function getTaskById(tid: number) {
|
||||
|
||||
@@ -98,6 +98,12 @@ const moment = require('moment');
|
||||
result = { type: parseInt(type), param: parseInt(param), cnt: parseInt(cnt) };
|
||||
break;
|
||||
}
|
||||
case 'possibility': {
|
||||
let [id, weight] = arr;
|
||||
if(isNaN(id) || isNaN(weight)) throw new Error('data table format wrong');
|
||||
result = { id: parseInt(id), weight: parseInt(weight) };
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
@@ -163,6 +169,10 @@ export function decodeIdCntArrayStr(str: string, multi: number) {
|
||||
return ce;
|
||||
}
|
||||
|
||||
export function getRandomByLen(arr: Array<any>) {
|
||||
let len = arr.length;
|
||||
return arr[Math.floor(Math.random() * len)]
|
||||
}
|
||||
|
||||
export function getRandomWithWeight(randomList: any) {
|
||||
let len = randomList.reduce((pre, cur) => {
|
||||
|
||||
Reference in New Issue
Block a user