合成藏宝图,消耗品单独开表

This commit is contained in:
luying
2020-11-25 20:31:42 +08:00
parent 3f3c716dc6
commit 169ba8cea7
17 changed files with 282 additions and 215 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ export async function initRank(serverId: number) {
let ranks = await RoleModel.getRank('tower', serverId, ['roleId', 'roleName', 'towerLv', 'lv', 'vLv']);
for(let {towerLv, roleId, roleName, lv, vLv, towerUpTime} of ranks) {
console.log(roleId);
// console.log(roleId);
await redisZadd(getKeyName(REDIS_KEY.TOWER_RANK, serverId), encodeScoreWithTime(towerLv, towerUpTime?towerUpTime.getTime():0), roleId);
await redisUserInfoAdd(roleId, {roleName, lv, vLv, guildName:"", head: "zhaoyun"});
}
+15 -12
View File
@@ -5,6 +5,7 @@ import { decodeStr } from '../pubUtils/util';
import { getGoodById } from '../pubUtils/gamedata';
import { RoleModel } from '../db/Role';
import { setAp } from './actionPointService';
import { ItemModel } from '../db/Item';
export async function handleFixedReward(roleId: string, roleName: string, rewardStr: string, multi: number) {
let reward = decodeStr('fixReward', rewardStr);
@@ -15,7 +16,7 @@ export async function handleFixedReward(roleId: string, roleName: string, reward
return result;
}
export async function handleReward(roleId: string, roleName: string, rewards: Array<{type: number, gid: number, count: number, times: number}>) {
export async function handleReward(roleId: string, roleName: string, rewards: Array<{type?: number, gid: number, count: number, times?: number}>) {
let returnGoods = new Array(), getGold = 0, getCoin = 0, getAp = 0;
for(let goods of rewards) {
@@ -24,11 +25,11 @@ export async function handleReward(roleId: string, roleName: string, rewards: Ar
if(goodInfo.goodType == GOOD_TYPE.EQUIP) { // 装备
result = await rewardWeapons(roleId, roleName, goodInfo, {id: goods.gid, cnt: goods.count });
} else if(goodInfo.goodType == GOOD_TYPE.CONSUMES|| goodInfo.goodType == GOOD_TYPE.SCRIPT) { // 消耗品
let {field, isCurrency} = ITID.get(goodInfo.itid);
let {type, isCurrency} = ITID.get(goodInfo.itid);
if(isCurrency) { // 货币
result = await rewardCurrency(roleId, goodInfo, {id: goods.gid, cnt: goods.count });
} else {
result = await rewardItems(roleId, goodInfo, field, {id: goods.gid, cnt: goods.count });
result = await rewardItems(roleId, roleName, goodInfo, type, {id: goods.gid, cnt: goods.count });
}
}
@@ -76,20 +77,22 @@ async function rewardWeapons (roleId: string, roleName: string, dicGood: any, w
}
// 消耗品
async function rewardItems (roleId: string, dicGood: any, field: string, data: {id:number,cnt:number }) {
async function rewardItems (roleId: string, roleName: string, dicGood: any, type: number, data: {id:number,cnt:number }) {
let goods = new Array();
let {id, cnt} = data;
let result = await RoleModel.addItems(roleId, field, id, cnt);
let result = await ItemModel.increaseItem(roleId, id, cnt, {roleId, roleName, itemName: dicGood.name, id, type, hid: dicGood.hid||0});
goods.push({
id: id,
name: dicGood.name,
count: cnt,
type: dicGood.goodType,
isCurrency: false
});
if(result) {
goods.push({
id: id,
name: dicGood.name,
count: cnt,
type: dicGood.goodType,
isCurrency: false
});
}
return goods;
}
+6 -5
View File
@@ -4,9 +4,9 @@
*/
import { BattleDropModel } from '../db/BattleDrop';
import { getWarById, getBluePrtByQuality } from '../pubUtils/gamedata';
import { getWarById, getBluePrtByQuality, getGamedata } from '../pubUtils/gamedata';
import { decodeStr, getRefTime, getRandomWithWeight, getRandomByLen } from '../pubUtils/util';
import { BATTLE_REWARD_TYPE, BLUEPRT_CONST, BLUEPRT_CHANCE } from '../consts/consts';
import { BATTLE_REWARD_TYPE, BLUEPRT_CONST } from '../consts/consts';
import { handleReward } from './rewardService';
import { BattleBlueprtDropModel } from '../db/BattleBlueprtDrop'
import { RoleModel } from '../db/Role';
@@ -127,7 +127,6 @@ export class WarReward {
}
private async handlerBlueprtReward(num: number) {
const refTime = getRefTime(new Date(), BLUEPRT_CONST.REFRESH_TIME);
const battleBlueprtDrop = await BattleBlueprtDropModel.findByTime(this.roleId, refTime);
if(battleBlueprtDrop) {
@@ -164,10 +163,12 @@ export class WarReward {
private async randomBlueprt() {
const { lv } = await RoleModel.findByRoleId(this.roleId);
const result = BLUEPRT_CHANCE.find(cur => {return cur.min <= lv && cur.max >= lv});
const dicPossibility = getGamedata('dic_blueprt_possibility');
const result = dicPossibility.find(cur => {return cur.min <= lv && cur.max >= lv});
if(result) {
const dicOdds = decodeStr('possibility', result.chance);
const dicOdds = decodeStr('possibility', result.possibility);
const {dic: {id}} = getRandomWithWeight(dicOdds);
const blueprtList = getBluePrtByQuality(id);