抽卡:添加抽卡接口
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
export const IT_TYPE = {
|
||||
BLUEPRT: 28,
|
||||
EQUIP_PIECE: 3,
|
||||
EQUIP: 2,
|
||||
HERO_PIECE: 7,
|
||||
BLUEPRT: 28,
|
||||
EQUIP_PIECE: 40,
|
||||
HERO_PIECE: 25,
|
||||
PAPER: 41,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -680,5 +680,12 @@ export const GACHA_TO_FLOOR = new Map([
|
||||
|
||||
// 抽卡里的卡池道具类型
|
||||
export enum GACHA_CONTENT_TYPE {
|
||||
HERO = 1, // 武将 param为武将品质
|
||||
HERO_PIECE = 2, // 武将碎片 武将品质
|
||||
BLUEPRT = 3, // 藏宝图 藏宝图品质
|
||||
JEWEL = 4, // 宝石 宝石等级
|
||||
TERAPH_MATERIAL = 5, // 强化神像用的材料 材料物品id
|
||||
SUIT_PAPER = 6, // 套装图纸
|
||||
}
|
||||
|
||||
}
|
||||
export const GACHA_OCCUPY_HID = 99; // 抽卡里占位的武将
|
||||
@@ -315,13 +315,15 @@ export const STATUS = {
|
||||
HERO_NOT_MAX: { code: 30904, simStr: '该武将未升满星' },
|
||||
|
||||
// 任务相关 31001-31100
|
||||
TASK_NOT_REACH_CONDITION: { code: 30900, simStr: '任务不满足条件' },
|
||||
TASK_HAS_RECEIVED: { code: 30901, simStr: '奖励已领取' },
|
||||
TASK_NOT_ALL_RECEIVED: { code: 30902, simStr: '任务未领取完' },
|
||||
TASK_ACTIVE_NOT_ENOUGH: { code: 30903, simStr: '活跃不足' },
|
||||
TASK_POINT_NOT_ENOUGH: { code: 30904, simStr: '积分不足' },
|
||||
TASK_BOX_HAS_RECEIVED: { code: 30905, simStr: '奖励已领取' },
|
||||
|
||||
TASK_NOT_REACH_CONDITION: { code: 31001, simStr: '任务不满足条件' },
|
||||
TASK_HAS_RECEIVED: { code: 31002, simStr: '奖励已领取' },
|
||||
TASK_NOT_ALL_RECEIVED: { code: 31003, simStr: '任务未领取完' },
|
||||
TASK_ACTIVE_NOT_ENOUGH: { code: 31004, simStr: '活跃不足' },
|
||||
TASK_POINT_NOT_ENOUGH: { code: 31005, simStr: '积分不足' },
|
||||
TASK_BOX_HAS_RECEIVED: { code: 31006, simStr: '奖励已领取' },
|
||||
// 抽卡相关 31101-31200
|
||||
GACHA_COST_NOT_ENOUGH: { code: 31101, simStr: '招募券不足' },
|
||||
GACHA_NOT_ASSIGN: { code: 31102, simStr: '请选择武将' },
|
||||
// 社交相关状态 40000 - 49999
|
||||
SYS_CHANNEL_AUTH_NOT_ENOUGH: { code: 40000, simStr: '无法在系统频道发送消息' },
|
||||
UPDATE_PRIVATE_MSG_READ_TIME_ERR: { code: 40001, simStr: '更新私聊阅读时间失败' },
|
||||
|
||||
@@ -1,9 +1,39 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
import { getCurWeekDate, getTodayZeroDate } from '../pubUtils/timeUtil';
|
||||
import { Floor, Hope, Turntable } from '../domain/activityField/gachaField';
|
||||
import { getTodayZeroDate } from '../pubUtils/timeUtil';
|
||||
import { REFRESH_HOUR } from '../consts';
|
||||
|
||||
class Floor {
|
||||
@prop({ required: true })
|
||||
id: number; // 保底类型 1-紫将保底 2-金将保底 3-指定将保底
|
||||
@prop({ required: true })
|
||||
count: number; // 抽卡次数
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 心愿单
|
||||
* @memberof UserGacha
|
||||
*/
|
||||
class Hope {
|
||||
@prop({ required: true })
|
||||
id: number; // 位置
|
||||
@prop({ required: true })
|
||||
hid: number; // 武将id
|
||||
@prop({ required: true })
|
||||
hasGet: boolean; // 是否得到
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 转盘记录
|
||||
* @memberof UserGacha
|
||||
*/
|
||||
class Turntable {
|
||||
@prop({ required: true })
|
||||
quality: number; // 品质
|
||||
@prop({ required: true })
|
||||
hasGet: boolean; // 是否得到
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家抽卡表
|
||||
**/
|
||||
@@ -19,12 +49,12 @@ export default class UserGacha extends BaseModel {
|
||||
gachaId: number; // 抽卡id 1-元宝 2-友情 3-指定 4-限时
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
aid: number; // 限时抽卡对应活动id
|
||||
activityId: number; // 限时抽卡对应活动id
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
count: number; // 已抽卡次数
|
||||
|
||||
@prop({ required: true, type: (() => Floor)(), default: [] })
|
||||
@prop({ required: true, type: Floor, default: [], _id: false })
|
||||
floor: Floor[]; // 已抽卡次数
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
@@ -33,13 +63,16 @@ export default class UserGacha extends BaseModel {
|
||||
@prop({ required: true, default: () => { return getTodayZeroDate(REFRESH_HOUR) } })
|
||||
refFreeTime: Date; // 免费次数刷新时间
|
||||
|
||||
@prop({ required: true, type: (() => Hope)(), default: [] })
|
||||
@prop({ required: true, type: () => Hope, default: [], _id: false })
|
||||
hope: Hope[]; // 心愿单
|
||||
|
||||
@prop({ required: true, default: () => { return getTodayZeroDate(REFRESH_HOUR) } })
|
||||
refHopeTime: Date; // 心愿单刷新时间
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
point: number; // 积分
|
||||
|
||||
@prop({ required: true, type: (() => Turntable)(), default: [] })
|
||||
@prop({ required: true, type: Turntable, default: [], _id: false })
|
||||
turntable: Turntable[]; // 转盘
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
@@ -50,13 +83,31 @@ export default class UserGacha extends BaseModel {
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async findByRole(roleId: string, gachaId: number, activityId: number = 0) {
|
||||
const doc = new UserGachaModel();
|
||||
const update = Object.assign(doc.toJSON(), { roleId, gachaId, activityId });
|
||||
delete update._id;
|
||||
let rec: UserGachaType = await UserGachaModel.findOneAndUpdate({ roleId, gachaId, activityId }, { $setOnInsert: update }, { new: true, upsert: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async updateInfo(roleId: string, gachaId: number, activityId: number, update: UserGachaParam) {
|
||||
let rec: UserGachaType = await UserGachaModel.findOneAndUpdate({ roleId, gachaId, activityId }, { $set: update }, { new: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async refreshFreeCount(roleId: string, gachaId: number, aid: number, refFreeTime: Date) {
|
||||
let rec: UserGachaType = await UserGachaModel.findOneAndUpdate({ roleId, gachaId, aid }, { $set: { freeCount: 0, refFreeTime } }, { new: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async refreshHopeCount(roleId: string, gachaId: number, aid: number, refHopeTime: Date) {
|
||||
let rec: UserGachaType = await UserGachaModel.findOneAndUpdate({ roleId, gachaId, aid }, { $set: { 'hope.$.hasGet': false, refHopeTime } }, { new: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
}
|
||||
|
||||
export const UserGachaModel = getModelForClass(UserGacha);
|
||||
|
||||
export interface UserGachaType extends Pick<DocumentType<UserGacha>, keyof UserGacha> { }
|
||||
export type UserGachaParam = Partial<UserGachaType>;
|
||||
export type UserGachaParam = Partial<UserGachaType>;
|
||||
|
||||
42
shared/db/UserGachaRec.ts
Normal file
42
shared/db/UserGachaRec.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
import { GachaResult } from '../domain/activityField/gachaField';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
|
||||
/**
|
||||
* 玩家抽卡表
|
||||
**/
|
||||
@modelOptions({ schemaOptions: { id: false } })
|
||||
@index({ code: 1 })
|
||||
|
||||
export default class UserGachaRec extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
code: string; // 玩家id
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 玩家id
|
||||
|
||||
@prop({ required: true })
|
||||
gachaId: number; // 抽卡id 1-元宝 2-友情 3-指定 4-限时
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
activityId: number; // 限时抽卡对应活动id
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
count: number; // 抽卡次数
|
||||
|
||||
@prop({ required: true, type: GachaResult, default: [], _id: false })
|
||||
result: GachaResult[]; // 结果
|
||||
|
||||
public static async createRec(roleId: string, gachaId: number, activityId: number, count: number, result: GachaResult[]) {
|
||||
let code = genCode(8);
|
||||
const rec = await UserGachaRecModel.findOneAndUpdate({ code }, { $set: { roleId, gachaId, activityId, count, result } }, { new: true, upsert: true });
|
||||
return rec;
|
||||
}
|
||||
}
|
||||
|
||||
export const UserGachaRecModel = getModelForClass(UserGachaRec);
|
||||
|
||||
export interface UserGachaRecType extends Pick<DocumentType<UserGachaRec>, keyof UserGachaRec> { }
|
||||
export type UserGachaRecParam = Partial<UserGachaRecType>;
|
||||
@@ -5,6 +5,7 @@ import { UserGachaType } from '../../db/UserGacha';
|
||||
import { getSeconds } from '../../pubUtils/timeUtil';
|
||||
import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
|
||||
import { getFloorStatus } from '../../services/gachaService';
|
||||
import { GACHA_OCCUPY_HID } from '../../consts';
|
||||
|
||||
|
||||
// 抽卡数据
|
||||
@@ -76,7 +77,7 @@ export class GachaListReturn {
|
||||
this.gachaId = dicGacha.id;
|
||||
|
||||
if(userGacha) {
|
||||
this.freeCount = dicGacha.free.count - userGacha.freeCount;
|
||||
this.freeCount = userGacha.freeCount;
|
||||
this.refFreeTime = getSeconds(userGacha.refFreeTime);
|
||||
this.count = userGacha.count;
|
||||
this.floor = getFloorStatus(dicGacha.id, userGacha.floor);
|
||||
@@ -88,4 +89,43 @@ export class GachaListReturn {
|
||||
this.floor = getFloorStatus(dicGacha.id, []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class GachaResult {
|
||||
@prop({ required: true })
|
||||
contentId: number; // 抽卡内容id
|
||||
@prop({ required: true })
|
||||
hid: number = 0; // 武将id
|
||||
@prop({ required: true })
|
||||
isTransfer: boolean = false; // 是否转换为碎片
|
||||
@prop({ required: true })
|
||||
id: number = 0; // 道具id
|
||||
@prop({ required: true })
|
||||
count: number = 0; // 道具数量
|
||||
|
||||
constructor(contentId: number) {
|
||||
this.contentId = contentId;
|
||||
}
|
||||
|
||||
setSetPickHero(hid: number) {
|
||||
if(hid > 0 && this.hid == GACHA_OCCUPY_HID) {
|
||||
this.hid = hid;
|
||||
}
|
||||
}
|
||||
|
||||
setHero(hid: number) {
|
||||
this.hid = hid;
|
||||
this.count = 1;
|
||||
}
|
||||
|
||||
setItem(id: number, count: number) {
|
||||
this.id = id;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
transferToPiece(id: number, count: number) {
|
||||
this.isTransfer = true;
|
||||
this.id = id;
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ import { dicGoods, blueprt, dicJewel, figureCondition } from "./dictionary/DicGo
|
||||
import { dicBlueprtCompose } from "./dictionary/DicBlueprtCompose";
|
||||
import { dicBlueprtPossibility } from "./dictionary/DicBlueprtPossibility";
|
||||
import { dicDaily } from "./dictionary/DicDaily";
|
||||
import { dicEvent } from "./dictionary/DicEvent";
|
||||
import { dicExpedition } from "./dictionary/DicExpedition";
|
||||
import { dicEvent, dicEventList } from "./dictionary/DicEvent";
|
||||
import { dicExpedition, DicExpedition } from "./dictionary/DicExpedition";
|
||||
import { dicExpeditionPoint } from "./dictionary/DicExpeditionPoint";
|
||||
import { dicFuncSwitch } from "./dictionary/DicFuncSwitch";
|
||||
import { dicHeroSkill } from "./dictionary/DicHeroSkill";
|
||||
@@ -66,8 +66,8 @@ import { dicCityActivity } from "./dictionary/DicCityActivity";
|
||||
import { dicChatAccuse } from "./dictionary/DicChatAccuse";
|
||||
import { dicCityActivityReward } from "./dictionary/DicCityActivityReward";
|
||||
import { dicRaceActivity, dicRaceTypes } from './dictionary/DicRaceActivity';
|
||||
import { GUILDACTIVITY } from "./dicParam";
|
||||
import { decodeIdCntArrayStr, parseGoodStr, decodeArrayListStr, getRandValueByMinMax } from "./util";
|
||||
import { GUILDACTIVITY, RECRUIT } from "./dicParam";
|
||||
import { decodeIdCntArrayStr, parseGoodStr, decodeArrayListStr, getRandValueByMinMax, getRandEelm } from "./util";
|
||||
import { RACE_EVENT_TYPE } from "../consts";
|
||||
import { dicShop, dicShopItem } from "./dictionary/DicShop";
|
||||
import { dicShopList } from "./dictionary/DicShopList";
|
||||
@@ -77,13 +77,14 @@ import { dicTaskType, taskMap, dicMainTask, dicDailyTask, dicAchievement } from
|
||||
import { dicMainTaskStage } from "./dictionary/DicMainTaskStage";
|
||||
import { dicTaskBox } from './dictionary/DicTaskBox';
|
||||
import { dicGacha } from "./dictionary/DicGacha";
|
||||
import { dicGachaContent } from "./dictionary/DicGachaContent";
|
||||
import { dicGachaContent, dicGachaContentHero } from "./dictionary/DicGachaContent";
|
||||
|
||||
export const gameData = {
|
||||
blurprtCompose: dicBlueprtCompose,
|
||||
blueprtPossibility: dicBlueprtPossibility,
|
||||
daily: dicDaily,
|
||||
event: dicEvent,
|
||||
eventList: dicEventList,
|
||||
expedition: dicExpedition,
|
||||
expeditionPoint: dicExpeditionPoint,
|
||||
funcsSwitch: dicFuncSwitch,
|
||||
@@ -186,6 +187,7 @@ export const gameData = {
|
||||
taskBox: dicTaskBox,
|
||||
gacha: dicGacha,
|
||||
gachaContent: dicGachaContent,
|
||||
gachaContentHero: dicGachaContentHero
|
||||
};
|
||||
|
||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||
@@ -532,7 +534,7 @@ function decodeRaceActivityEncounter() {
|
||||
let eventNum = 0;
|
||||
for(let [key, value] of map) {
|
||||
if(value == RACE_EVENT_TYPE.EVENT) eventNum ++;
|
||||
newMap.set(parseInt(key), parseInt(value));
|
||||
newMap.set(parseInt(key), value);
|
||||
}
|
||||
return { events: newMap, eventNum };
|
||||
}
|
||||
@@ -565,4 +567,19 @@ export function getRaceEventItems() {
|
||||
result.push({ id, count });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 根据保底类型获得保底数量
|
||||
export function getDicGachaFloor(id: number) {
|
||||
let map = decodeIdCntArrayStr(RECRUIT.RECRUIT_MUST, 1);
|
||||
return map.get(id.toString())
|
||||
}
|
||||
|
||||
|
||||
export function getRandExpedition(cnt = 1) {
|
||||
let arr: DicExpedition[] = [];
|
||||
for(let [_id, dicExpedition] of gameData.expedition) {
|
||||
arr.push(dicExpedition);
|
||||
}
|
||||
return getRandEelm(arr, cnt);
|
||||
}
|
||||
@@ -36,12 +36,13 @@ const str = readJsonFile(FILENAME.DIC_EVENT);
|
||||
let arr = JSON.parse(str);
|
||||
|
||||
export const dicEvent = new Map<number, DicEvent>();
|
||||
export const dicEventList = new Array<DicEvent>();
|
||||
arr.forEach(o => {
|
||||
o.winReward = parseGoodStr(o.winReward);
|
||||
o.loseReward = parseGoodStr(o.loseReward);
|
||||
o.suitLevel = parseSuitLevel(o.suitLevel);
|
||||
o.movePointArray = parseNumberList(o.movePointArray);
|
||||
|
||||
dicEventList.push(o);
|
||||
dicEvent.set(o.eventID, o);
|
||||
});
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ export interface DicGacha {
|
||||
// 消耗的招募券
|
||||
readonly cost: RewardInter[];
|
||||
// 概率
|
||||
readonly percent: { id: number, percent: number }[];
|
||||
readonly percent: { id: number, weight: number }[];
|
||||
}
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_GACHA);
|
||||
let arr = JSON.parse(str);
|
||||
|
||||
export const dicGacha = new Map<number, DicGacha>();
|
||||
export const dicGacha = new Map<number, DicGacha>(); // id => dic
|
||||
arr.forEach(o => {
|
||||
o.count = parseNumberList(o.count);
|
||||
o.free = parseFree(o.free);
|
||||
@@ -41,14 +41,14 @@ function parseFree(str: string) {
|
||||
}
|
||||
|
||||
function parsePercent(str: string) {
|
||||
let result = new Array<{ id: number, percent: number }>();
|
||||
let result = new Array<{ id: number, weight: number }>();
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let [id, percent] of decodeArr) {
|
||||
if (isNaN(parseInt(id)) || isNaN(parseInt(percent))) {
|
||||
for (let [id, weight] of decodeArr) {
|
||||
if (isNaN(parseInt(id)) || isNaN(parseInt(weight))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({ id: parseInt(id), percent: parseInt(percent) });
|
||||
result.push({ id: parseInt(id), weight: parseInt(weight) });
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { readJsonFile, parseNumberList } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
import { FILENAME, GACHA_CONTENT_TYPE } from '../../consts'
|
||||
|
||||
export interface DicGachaContent {
|
||||
// 内容id
|
||||
@@ -15,9 +15,14 @@ export interface DicGachaContent {
|
||||
const str = readJsonFile(FILENAME.DIC_GACHA_CONTENT);
|
||||
let arr = JSON.parse(str);
|
||||
|
||||
export const dicGachaContent = new Map<number, DicGachaContent>();
|
||||
export const dicGachaContent = new Map<number, DicGachaContent>(); // id => dic
|
||||
export const dicGachaContentHero = new Map<number, number>(); // quality => dic
|
||||
arr.forEach(o => {
|
||||
o.param = parseNumberList(o.param);
|
||||
if(o.type == GACHA_CONTENT_TYPE.HERO) {
|
||||
dicGachaContentHero.set(o.param[0], o.id);
|
||||
}
|
||||
dicGachaContent.set(o.id, o);
|
||||
});
|
||||
|
||||
arr = undefined;
|
||||
@@ -27,13 +27,15 @@ export interface DicHero {
|
||||
readonly baseAbilityArr:Map<number, number>;
|
||||
readonly baseAbilityUpArr:Map<number, number>;
|
||||
readonly initialSkin: number;
|
||||
// 是否可招募
|
||||
readonly recruit: boolean;
|
||||
}
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_HERO);
|
||||
let arr = JSON.parse(str);
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicHeroKeys: KeysEnum<DicHero> = {heroId: true, name: true, quality: true, camp: true, jobid: true, skill: true, pieceId: true, initialStars: true, pieceCount: true, baseAbilityArr: true, baseAbilityUpArr: true, initialSkin: true};
|
||||
const DicHeroKeys: KeysEnum<DicHero> = {heroId: true, name: true, quality: true, camp: true, jobid: true, skill: true, pieceId: true, initialStars: true, pieceCount: true, baseAbilityArr: true, baseAbilityUpArr: true, initialSkin: true, recruit: true};
|
||||
export const dicMyHeroes = new Array<number>();
|
||||
export const dicHero = new Map<number, DicHero>();
|
||||
arr.forEach(o => {
|
||||
@@ -42,7 +44,7 @@ arr.forEach(o => {
|
||||
}
|
||||
o.baseAbilityArr = parseBaseAbilityArr(o);
|
||||
o.baseAbilityUpArr = parseBaseAbilityUpArr(o);
|
||||
|
||||
o.recruit = parseInt(o.recruit) == 1;
|
||||
dicHero.set(o.heroId, _.pick(o, Object.keys(DicHeroKeys)));
|
||||
});
|
||||
|
||||
|
||||
@@ -330,12 +330,6 @@ export function getExpeditionById(id: number) {
|
||||
return expeditionInfo.get(id);
|
||||
}
|
||||
|
||||
export function getRandExpedition(cnt = 1) {
|
||||
const file = 'dic_expedition';
|
||||
const data = gamedata['jsons'][file] || [];
|
||||
return getRandEelm(data, cnt);
|
||||
}
|
||||
|
||||
export function getComBtlSetByQuality(quality: number) {
|
||||
return comBtlInfo.get(quality);
|
||||
}
|
||||
@@ -366,7 +360,7 @@ export function getBossHpByWarId(warId: number) {
|
||||
let { attribute, dataId, relation, actorId } = hero;
|
||||
if (relation === 2) {
|
||||
let attriData = decodeIdCntArrayStr(attribute, 1);
|
||||
const hp = parseInt(attriData.get('1'));
|
||||
const hp = attriData.get('1');
|
||||
if (hp > 0) {
|
||||
bossHpArr.push({dataId, hp, actorId});
|
||||
bossHpSum += hp;
|
||||
@@ -385,7 +379,7 @@ export function getWarIdByBlueprtId(blueprtId: number) {
|
||||
if (!warId) {
|
||||
const { specialAttr } = getGoodById(blueprtId);
|
||||
const attrData = decodeIdCntArrayStr(specialAttr, 1);
|
||||
warId = parseInt(attrData.get('1'));
|
||||
warId = attrData.get('1');
|
||||
blueprtToWar.set(blueprtId, warId);
|
||||
}
|
||||
return warId;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
import { HeroModel, HeroUpdate } from '../db/Hero';
|
||||
import { HeroModel, HeroUpdate, HeroType } from '../db/Hero';
|
||||
import { ItemModel } from '../db/Item';
|
||||
import { EquipModel, RandSe, Holes } from './../db/Equip';
|
||||
import { BagInter, EquipInter } from './interface';
|
||||
@@ -231,7 +231,7 @@ export async function createHeroes(roleId: string, heroInfos: HeroUpdate[]) {
|
||||
let heroNum = 0;
|
||||
let skinIds = new Array<number>();
|
||||
let conditions = new Array<{type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }>();
|
||||
let heroes = [], calHeroResults = [], calAllHeroResults = [];
|
||||
let heroes: HeroType[] = [], calHeroResults = [], calAllHeroResults = [];
|
||||
|
||||
for(let heroInfo of heroInfos) {
|
||||
let curHero = await HeroModel.createHero(heroInfo); heroes.push(curHero);
|
||||
|
||||
@@ -189,11 +189,11 @@ export function decodeArrayListStr(str: string) {
|
||||
*/
|
||||
export function decodeIdCntArrayStr(str: string, multi: number) {
|
||||
const strArr = decodeArrayStr(str);
|
||||
console.log('decodeIdCntArrayStr: ', strArr);
|
||||
const strMap = new Map();
|
||||
// console.log('decodeIdCntArrayStr: ', strArr);
|
||||
const strMap = new Map<string, number>();
|
||||
strArr.forEach(item => {
|
||||
const kv = item.split('&');
|
||||
strMap.set(kv[0], multi ? Math.ceil(parseInt(kv[1]) * multi) : kv[1]);
|
||||
strMap.set(kv[0], multi ? Math.ceil(parseInt(kv[1]) * multi) : parseInt(kv[1]));
|
||||
});
|
||||
return strMap;
|
||||
}
|
||||
@@ -219,7 +219,7 @@ export function getRandomIndexByLen(len: number) {
|
||||
return Math.floor(Math.random() * len);
|
||||
}
|
||||
|
||||
export function getRandomWithWeight(randomList: any) {
|
||||
export function getRandomWithWeight<T extends { weight: number }>(randomList: T[]): { dic: T, index: number } {
|
||||
let len = randomList.reduce((pre, cur) => {
|
||||
return pre + cur.weight || 1;
|
||||
}, 0);
|
||||
@@ -312,7 +312,7 @@ export function getRefTime(now = new Date(), checkHour: number, day = 0) {
|
||||
* @param source 原数组
|
||||
* @param cnt 返回随机元素个数
|
||||
*/
|
||||
export function getRandEelm(source: Array<any> = [], cnt = 1): Array<any> {
|
||||
export function getRandEelm<T>(source: Array<T> = [], cnt = 1): Array<T> {
|
||||
if (cnt > source.length || cnt == 0) return [];
|
||||
if (cnt === source.length) return source;
|
||||
let idxs = new Set();
|
||||
|
||||
Reference in New Issue
Block a user