关卡添加消耗品结算,奇遇的坐标改为点id
This commit is contained in:
@@ -129,14 +129,14 @@ export async function refreshEvent(num: number, roleId: string, roleName: string
|
||||
|
||||
let index = Math.floor(Math.random() * randomList.length);
|
||||
let dic = randomList[index];
|
||||
let position = randomPosition(dic.position);
|
||||
let point = randomPosition(dic.movePointArray);
|
||||
let question = dic.eventType == EVENT_TYPE.QUIZ?randomQuestion(EVENT_QUIZ_NUM): undefined;
|
||||
let eventCode = genCode(8);
|
||||
let data = await EventRecordModel.saveEventRecord(eventCode, {
|
||||
roleId, refTime: t, eventId: dic.eventID,
|
||||
roleName, turn, type: dic.eventType, battleId: dic.warId||0, quality: dic.quality,
|
||||
status: EVENT_RECORD_STATUS.WAITING,
|
||||
position, question
|
||||
point, question
|
||||
});
|
||||
event.push(data);
|
||||
randomList.splice(index, 1);
|
||||
@@ -148,14 +148,14 @@ export async function refreshEvent(num: number, roleId: string, roleName: string
|
||||
let {dic} = getRandomWithWeight(randomList);
|
||||
console.log(JSON.stringify(dic))
|
||||
// if(!dic) break;
|
||||
let position = randomPosition(dic.position);
|
||||
let point = randomPosition(dic.movePointArray);
|
||||
let eventCode = genCode(8);
|
||||
let question = dic.eventType == EVENT_TYPE.QUIZ?randomQuestion(EVENT_QUIZ_NUM): [];
|
||||
let data = await EventRecordModel.saveEventRecord(eventCode, {
|
||||
roleId, refTime: t, eventId: dic.eventID,
|
||||
roleName, type: dic.eventType, battleId: dic.warId||0, quality: dic.quality,
|
||||
status: EVENT_RECORD_STATUS.WAITING,
|
||||
position, question
|
||||
point, question
|
||||
});
|
||||
event.push(data)
|
||||
}
|
||||
@@ -165,7 +165,7 @@ export async function refreshEvent(num: number, roleId: string, roleName: string
|
||||
}
|
||||
|
||||
function randomPosition(positionStr: string) {
|
||||
let positionArr = decodeStr('position', positionStr);
|
||||
let positionArr = decodeStr('point', positionStr, '&');
|
||||
let index = Math.floor(Math.random() * positionArr.length);
|
||||
return positionArr[index]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { GOOD_TYPE } from './../consts/consts';
|
||||
import { EquipModel } from './../db/Equip';
|
||||
import { ItemModel } from './../db/Item';
|
||||
import { ScriptItemModel } from './../db/ScriptItem';
|
||||
import { CounterModel } from './../db/Counter';
|
||||
import { decodeStr } from '../pubUtils/util';
|
||||
import { getGoodById } from '../pubUtils/gamedata';
|
||||
@@ -18,11 +20,20 @@ export async function handleReward(roleId: string, roleName: string, rewards: Ar
|
||||
let returnGoods = new Array();
|
||||
for(let goods of rewards) {
|
||||
let goodInfo = getGoodById(goods.gid);
|
||||
let result = new Array<any>()
|
||||
if(goodInfo.goodType == GOOD_TYPE.EQUIP) { // 装备
|
||||
let result = await rewardWeapons(roleId, roleName, goodInfo, {id: goods.gid, cnt: goods.count });
|
||||
for(let obj of result) {
|
||||
returnGoods.push({dropType: goods.type, times: goods.times, ...obj})
|
||||
}
|
||||
result = await rewardWeapons(roleId, roleName, goodInfo, {id: goods.gid, cnt: goods.count });
|
||||
} else if(goodInfo.goodType == GOOD_TYPE.ITEM) { // 消耗品
|
||||
result = await rewardItems(roleId, roleName, goodInfo, {id: goods.gid, cnt: goods.count });
|
||||
} else if(goodInfo.goodType == GOOD_TYPE.SCRIPT_ITEM) { // 剧情物品
|
||||
result = await rewardScriptItems(roleId, roleName, goodInfo, {id: goods.gid, cnt: goods.count });
|
||||
} else if (goodInfo.goodType == GOOD_TYPE.HERO_SOUL) { // 武将碎片
|
||||
|
||||
} else { // 货币
|
||||
|
||||
}
|
||||
for(let obj of result) {
|
||||
returnGoods.push({dropType: goods.type, times: goods.times, ...obj})
|
||||
}
|
||||
}
|
||||
return returnGoods;
|
||||
@@ -48,4 +59,62 @@ async function rewardWeapons (roleId: string, roleName: string, dicGood: any, w
|
||||
weaponsData.push(equip);
|
||||
}
|
||||
return weaponsData;
|
||||
}
|
||||
|
||||
// 消耗品
|
||||
async function rewardItems (roleId: string, roleName: string, dicGood: any, data: {id:number,cnt:number }) {
|
||||
|
||||
let goods = new Array();
|
||||
let itemcount = data.cnt;
|
||||
let itemid = data.id;
|
||||
|
||||
let item = await ItemModel.findbyItemid(itemid, roleId);
|
||||
if(item) {
|
||||
let result = await ItemModel.changeItemCount(item.seqId, itemcount);
|
||||
goods.push(result);
|
||||
} else {
|
||||
const seqId = await CounterModel.getNewCounter('itemid')||-1;
|
||||
const itemInfo = {
|
||||
roleId,
|
||||
roleName: roleName,
|
||||
itemid,
|
||||
itemName: dicGood.name,
|
||||
seqId,
|
||||
count: itemcount,
|
||||
type: dicGood.goodType
|
||||
}
|
||||
let result = await ItemModel.createItem(itemInfo);
|
||||
goods.push(result);
|
||||
}
|
||||
|
||||
return goods;
|
||||
}
|
||||
|
||||
// 剧情道具
|
||||
async function rewardScriptItems (roleId: string, roleName: string, dicGood: any, data: {id:number,cnt:number }) {
|
||||
|
||||
let goods = [];
|
||||
let itemcount = data.cnt;
|
||||
let itemid = data.id;
|
||||
|
||||
let item = await ScriptItemModel.findbyItemid(itemid, roleId);
|
||||
if(item) {
|
||||
let result = await ScriptItemModel.changeItemCount(item.seqId, itemcount);
|
||||
goods.push(result);
|
||||
} else {
|
||||
const seqId = await CounterModel.getNewCounter('scriptitemid')||-1;
|
||||
const itemInfo = {
|
||||
roleId,
|
||||
roleName: roleName,
|
||||
itemid,
|
||||
itemName: dicGood.name,
|
||||
seqId,
|
||||
count: itemcount,
|
||||
type: dicGood.goodType
|
||||
}
|
||||
let result = await ScriptItemModel.createItem(itemInfo);
|
||||
goods.push(result);
|
||||
}
|
||||
|
||||
return goods;
|
||||
}
|
||||
@@ -97,7 +97,6 @@ export class WarReward {
|
||||
this.handleConditionReward(num);
|
||||
await this.handleRandomReward(num);
|
||||
|
||||
console.log(this.rewards)
|
||||
let returnGoods = await handleReward(this.roleId, this.roleName, this.rewards);
|
||||
return returnGoods;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user