活动:新将抽卡添加固定奖励

This commit is contained in:
qiaoxin
2021-06-24 15:49:40 +08:00
parent 51b96a6853
commit d906392764
6 changed files with 37 additions and 14 deletions
@@ -56,20 +56,19 @@ export class ActivityMonopolyHandler {
const roleName = session.get('roleName'); const roleName = session.get('roleName');
let moveStep = 0; let moveStep = 0;
if (step >= 1 && step <= 6) {//指定 if (step >= 1 && step <= 6) {//指定,天机骰子
//检查资源 //检查资源
let consumeResult = await handleCost(roleId, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count: 1 }]); let consumeResult = await handleCost(roleId, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.SPECIAL_DICE), count: 1 }]);
if (!consumeResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH); if (!consumeResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH);
moveStep = step; moveStep = step;
} else { } else {//普通骰子
//检查资源 //检查资源
let consumeResult = await handleCost(roleId, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count: 1 }]); let consumeResult = await handleCost(roleId, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.NORMAL_DICE), count: 1 }]);
if (!consumeResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH); if (!consumeResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH);
moveStep = random(5) + 1; moveStep = random(5) + 1;
} }
let playerData = await getPlayerMonopolyData(activityId, serverId, roleId) let playerData = await getPlayerMonopolyData(activityId, serverId, roleId)
let playerMonopolyData: ActivityMonopolyModelType = await ActivityMonopolyModel.findData(serverId, activityId, roleId);
let oldPosition = playerData.curPosition; let oldPosition = playerData.curPosition;
let newPosition = nextPosition(oldPosition, moveStep, playerData.list.length); let newPosition = nextPosition(oldPosition, moveStep, playerData.list.length);
await ActivityMonopolyModel.updatePosition(serverId, activityId, roleId, newPosition, 1) await ActivityMonopolyModel.updatePosition(serverId, activityId, roleId, newPosition, 1)
@@ -3,7 +3,6 @@ import { getRandEelmWithWeight, resResult } from '../../../pubUtils/util';
import { STATUS } from '../../../consts'; import { STATUS } from '../../../consts';
import { getPlayerNewHeroGachaData } from '../../../services/activity/newHeroGachaService'; import { getPlayerNewHeroGachaData } from '../../../services/activity/newHeroGachaService';
import { RoleModel } from '../../../db/Role'; import { RoleModel } from '../../../db/Role';
import { gameData } from '../../../pubUtils/data';
import { HeroModel } from '../../../db/Hero'; import { HeroModel } from '../../../db/Hero';
import { RewardInter } from '../../../pubUtils/interface'; import { RewardInter } from '../../../pubUtils/interface';
import { CreateHeroParam } from '../../../domain/roleField/hero'; import { CreateHeroParam } from '../../../domain/roleField/hero';
@@ -12,7 +11,8 @@ import { getResultFromContentIdNewHeroActivity } from '../../../services/activit
import { transPiece } from '../../../pubUtils/itemUtils'; import { transPiece } from '../../../pubUtils/itemUtils';
import { addItems, createHeroes, handleCost } from '../../../services/rewardService'; import { addItems, createHeroes, handleCost } from '../../../services/rewardService';
import { ActivityNewHeroGachaModel } from '../../../db/ActivityNewHeroGacha'; import { ActivityNewHeroGachaModel } from '../../../db/ActivityNewHeroGacha';
// import { NewHeroGachaItem } from '../../../domain/activityField/newHeroGachaField'; import { addReward, stringToRewardParam } from '../../../services/activity/giftPackageService';
import { RewardParam } from '../../../domain/activityField/rewardField';
export default function (app: Application) { export default function (app: Application) {
@@ -120,10 +120,14 @@ export class NewHeroGachaHandler {
// 给东西 // 给东西
let { heroes } = await createHeroes(roleId, roleName, sid, serverId, funcs, heroInfo); let { heroes } = await createHeroes(roleId, roleName, sid, serverId, funcs, heroInfo);
await addItems(roleId, roleName, sid, items); await addItems(roleId, roleName, sid, items);
//固定奖励
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.commonReward);
let newRewardParamArr: Array<RewardParam> = rewardParamArr.map(obj => { return { id: obj.id, type: obj.type, count: obj.count * count } });
let commonResult = await addReward(roleId, roleName, sid, serverId, funcs, newRewardParamArr)
return resResult(STATUS.SUCCESS, { return resResult(STATUS.SUCCESS, {
hid, activityId, count, hid, activityId, count, randomReward: { heroes, result: resultList }, commonReward: commonResult
heroes, result: resultList
}); });
} }
@@ -93,7 +93,18 @@ export async function addReward(roleId: string, roleName: string, sid: string, s
goods = goods.concat(heroResult.goods) goods = goods.concat(heroResult.goods)
addHeros = addHeros.concat(heroResult.heroes); addHeros = addHeros.concat(heroResult.heroes);
} }
return { goods, addHeros }
let newGoods: RewardInter[] = [];
for (let item of goods) {
let index = newGoods.findIndex(obj => { return obj.id == item.id });
if (index != -1) {
newGoods[index].count += item.count;
} else {
newGoods.push({ id: item.id, count: item.count })
}
}
return { goods: newGoods, addHeros }
} }
//表中的奖励数据(包括礼包)转换成具体对应奖励物品的实例 //表中的奖励数据(包括礼包)转换成具体对应奖励物品的实例
+1 -1
View File
@@ -51,7 +51,7 @@ export enum ACTIVITY_TYPE {
COMMON_SIGN_IN = 36, //通用签到 COMMON_SIGN_IN = 36, //通用签到
NEW_HERO_GIFTS = 37, //新将好礼(很多红包,用积分兑换一遍结束) NEW_HERO_GIFTS = 37, //新将好礼(很多红包,用积分兑换一遍结束)
NEW_HERO_GK = 38, //新将演绎 (配置N个武将,每个武将有X个关卡;活动期间,*天(时间自定义)开启每个武将对应的一个关卡,只有第一次通关会获得奖励) NEW_HERO_GK = 38, //新将演绎 (配置N个武将,每个武将有X个关卡;活动期间,*天(时间自定义)开启每个武将对应的一个关卡,只有第一次通关会获得奖励)
NEW_HERO_GACHA = 39, //新将擢迁(新武将抽取) NEW_HERO_GACHA = 39, //新将擢迁(新武将抽卡)
} }
/** /**
+10 -3
View File
@@ -33,6 +33,7 @@ export const CONSUME_TYPE = {
SPINE: 13, // 形象 SPINE: 13, // 形象
GIFT_PACKAGE: 14, // 礼包 GIFT_PACKAGE: 14, // 礼包
AP: 15, // 回复体力道具 AP: 15, // 回复体力道具
DICE: 16, // 骰子
}; };
export enum ROLE_TERAPH { export enum ROLE_TERAPH {
@@ -144,7 +145,9 @@ const itid_array = [
{ id: 51, name: '相框', table: 'role', type: CONSUME_TYPE.FRAME }, { id: 51, name: '相框', table: 'role', type: CONSUME_TYPE.FRAME },
{ id: 52, name: '玩家形象', table: 'role', type: CONSUME_TYPE.SPINE }, { id: 52, name: '玩家形象', table: 'role', type: CONSUME_TYPE.SPINE },
{ id: 55, name: '回复体力道具', table: 'item', type: CONSUME_TYPE.AP }, { id: 55, name: '回复体力道具', table: 'item', type: CONSUME_TYPE.AP },
{ id: 56, name: '普通骰子', table: 'item', type: CONSUME_TYPE.DICE },
{ id: 57, name: '天机骰子', table: 'item', type: CONSUME_TYPE.DICE },
]; ];
export const ITID = new Map<number, { id: number, name: string, table: string, type?: number, isCurrency?: boolean, equipJewel?: number }>(); export const ITID = new Map<number, { id: number, name: string, table: string, type?: number, isCurrency?: boolean, equipJewel?: number }>();
@@ -162,7 +165,9 @@ export const CURRENCY_TYPE = {
FRIEND_POINT: "friendPoint", FRIEND_POINT: "friendPoint",
HONOUR: "honour", HONOUR: "honour",
SKIN_COIN: "skinCoin", SKIN_COIN: "skinCoin",
DUNGEON: "dungeon" DUNGEON: "dungeon",
NORMAL_DICE: "normalDice",
SPECIAL_DICE: "specialDice"
} }
@@ -180,7 +185,9 @@ const currencyArr = [
{ "gid": 40004, "name": "秘境币", "type": CURRENCY_TYPE.DUNGEON_POINT }, { "gid": 40004, "name": "秘境币", "type": CURRENCY_TYPE.DUNGEON_POINT },
{ "gid": 40005, "name": "功勋", "type": CURRENCY_TYPE.HONOUR }, { "gid": 40005, "name": "功勋", "type": CURRENCY_TYPE.HONOUR },
{ "gid": 40006, "name": "蜀锦", "type": CURRENCY_TYPE.SKIN_COIN }, { "gid": 40006, "name": "蜀锦", "type": CURRENCY_TYPE.SKIN_COIN },
{ "gid": 40007, "name": "秘境币", "type": CURRENCY_TYPE.DUNGEON } { "gid": 40007, "name": "秘境币", "type": CURRENCY_TYPE.DUNGEON },
{ "gid": 72011, "name": "普通骰子", "type": CURRENCY_TYPE.NORMAL_DICE },
{ "gid": 72021, "name": "天机骰子", "type": CURRENCY_TYPE.SPECIAL_DICE }
]; ];
export const CURRENCY = new Map<number, { gid: number, name: string, type: string }>(); export const CURRENCY = new Map<number, { gid: number, name: string, type: string }>();
export const CURRENCY_BY_TYPE = new Map<string, number>(); export const CURRENCY_BY_TYPE = new Map<string, number>();
@@ -14,11 +14,13 @@ export class NewHeroGachaItem {
cost: RewardInter[];//每次抽卡消耗资源 cost: RewardInter[];//每次抽卡消耗资源
floorReward: number = 0;//保底奖励,percent下标+1 floorReward: number = 0;//保底奖励,percent下标+1
percent: { id: number, weight: number, goodId: number }[];//奖品百分比 contentId & percent & id(英雄hid,物品id) percent: { id: number, weight: number, goodId: number }[];//奖品百分比 contentId & percent & id(英雄hid,物品id)
commonReward: string = "";//固定奖 格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
constructor(data: any) { constructor(data: any) {
this.hid = data.hid; this.hid = data.hid;
this.name = data.name; this.name = data.name;
this.floorCount = data.floorCount; this.floorCount = data.floorCount;
this.commonReward = data.commonReward;
this.cost = parseGoodStr(data.cost); this.cost = parseGoodStr(data.cost);
this.percent = []; this.percent = [];
this.floorReward = data.floorReward - 1; this.floorReward = data.floorReward - 1;