试炼
This commit is contained in:
@@ -308,7 +308,10 @@ export const FILENAME = {
|
||||
DIC_GUILD_POSITION: 'dic_army_position',
|
||||
DIC_ACTIVE_DAY_REWARD: 'dic_army_activeDayReward',
|
||||
DIC_ACTIVE_WEEK_REWARD: 'dic_army_activeWeekReward',
|
||||
DIC_MAIL: 'dic_email_army'
|
||||
DIC_MAIL: 'dic_email_army',
|
||||
DIC_ARMY_TRAIN_JU_DIAN: 'dic_army_trainJuDian',
|
||||
DIC_ARMY_TRAIN_SOLO_REWARD: 'dic_army_trainSoloReward'
|
||||
|
||||
}
|
||||
|
||||
export const WAR_RELATE_TABLES = [
|
||||
|
||||
@@ -224,6 +224,7 @@ export const STATUS = {
|
||||
GUILD_GET_TRAIN_BOX_FAIL: {code: 30913, simStr: '宝箱领取失败'},
|
||||
GUILD_TRAIN_REWARD_IS_RECEIVED: {code: 30913, simStr: '试炼进阶奖励已领取'},
|
||||
GUILD_GET_TRAIN_REWARD_FAIL: {code: 30913, simStr: '宝箱领取失败'},
|
||||
GUILD_TRAIN_LEVEL_IS_COMPLETE: {code: 30913, simStr: '试炼已经进阶'},
|
||||
|
||||
// 社交相关状态 40000 - 49999
|
||||
// 运营模块相关状态 50000 - 59999
|
||||
|
||||
@@ -22,6 +22,10 @@ class Record {
|
||||
trainId?:number;
|
||||
@prop({ required: false })
|
||||
hid?:number;
|
||||
@prop({ required: false })
|
||||
guildCode?: string;
|
||||
@prop({ required: false })
|
||||
difficulty: number;
|
||||
}
|
||||
|
||||
export default class BattleRecord extends BaseModel {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, Ref } from '@typegoose/typegoose';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
class Reward {
|
||||
@prop({ required: true })
|
||||
id: number;
|
||||
@@ -16,15 +17,15 @@ class TrainBox {
|
||||
index: number;
|
||||
}
|
||||
|
||||
class TrainScript {
|
||||
export class TrainInstance {
|
||||
@prop({ required: true })
|
||||
hid: number;
|
||||
@prop({ required: true })
|
||||
progress: number;
|
||||
@prop({ required: true })
|
||||
time: number;
|
||||
@prop({ required: true, default: [], type: TrainBox})
|
||||
trainBoxs: Array<TrainBox>;
|
||||
endTime: number;
|
||||
@prop({ required: true, default: [], type: TrainBox, _id: false })
|
||||
trainBoxs: TrainBox[];
|
||||
}
|
||||
|
||||
class Rank {
|
||||
@@ -58,12 +59,12 @@ export default class GuildTrain extends BaseModel {
|
||||
trainId: number;
|
||||
@prop({ required: true })
|
||||
isComplete: boolean;
|
||||
@prop({ required: true, default: [], type: TrainScript})
|
||||
trainScripts: Array<TrainScript>;
|
||||
@prop({ required: true, default: [], type: Rank })
|
||||
ranks: Array<Rank>;
|
||||
@prop({ required: true, default: [], type: Report })
|
||||
reports: Array<Report>;
|
||||
@prop({ required: true, default: [], type: TrainInstance, _id: false })
|
||||
trainInstances: TrainInstance[];
|
||||
@prop({ required: true, default: [], type: Rank, _id: false })
|
||||
ranks: Rank[];
|
||||
@prop({ required: true, default: [], type: Report, _id: false })
|
||||
reports: Report[];
|
||||
@prop({ required: true, default: false})
|
||||
locked: boolean;
|
||||
|
||||
@@ -83,30 +84,30 @@ export default class GuildTrain extends BaseModel {
|
||||
}
|
||||
|
||||
public static async updateGuildTrain(guildCode: string, trainId: number, update: GuildTrainTypeParam, lean = true) {
|
||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOneAndUpdate({ guildCode, trainId}, { $set: update }).lean(lean);
|
||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOneAndUpdate({ guildCode, trainId}, { $set: update }, {new: true}).lean(lean);
|
||||
return guildTrain;
|
||||
}
|
||||
|
||||
public static async updateGuildTrainProgress(guildCode: string, trainId: number, hid:number, progress: number, ranks:Array<Rank>, reports: Array<Report>, isComplete: boolean,lean = true) {
|
||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOneAndUpdate({ guildCode, trainId, 'trainScripts.hid':hid},
|
||||
{ $set: {'trainScripts.$.progress': progress, ranks, reports, isComplete} }).lean(lean);
|
||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOneAndUpdate({ guildCode, trainId, 'trainInstances.hid':hid},
|
||||
{ $set: {'trainInstances.$.progress': progress, ranks, reports, isComplete,'trainInstances.$.endTime': nowSeconds() + 24*60*60} },{new: true}).lean(lean);
|
||||
return guildTrain;
|
||||
}
|
||||
|
||||
public static async openGuildTrain(guildCode: string, trainId: number, trainScripts: Array<TrainScript>, lean = true) {
|
||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOneAndUpdate({ guildCode, trainId },{ trainId, reports: [], locked: false, ranks: [], trainScripts, isComplete: false, guildCode}, {new: true, upsert: true}).lean(lean);
|
||||
public static async openGuildTrain(guildCode: string, trainId: number, trainInstances: Array<TrainInstance>, lean = true) {
|
||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOneAndUpdate({ guildCode, trainId },{ trainId, reports: [], locked: false, ranks: [], trainInstances, isComplete: false, guildCode}, {new: true, upsert: true}).lean(lean);
|
||||
return guildTrain;
|
||||
}
|
||||
|
||||
public static async findTrainScriptBoxByIndex(guildCode: string, roleId: string, trainId: number, hid: number, index: number, progress: number, time, locked = false, lean = true) {
|
||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOne({ guildCode, trainId, locked, 'trainScripts.hid': hid,
|
||||
'trainScripts.index':{$ne:index },'trainScripts.roleId':{$ne:roleId }, progress: {$gte: progress}, time:{$gte: time}}).lean(lean);
|
||||
public static async findTrainInstanceBoxByIndex(guildCode: string, roleId: string, trainId: number, hid: number, index: number, progress: number, time: number, locked = false, lean = true) {
|
||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOne({ guildCode, trainId, locked, 'trainInstances.hid': hid,
|
||||
'trainInstances.trainBoxs.index':{$ne:index },'trainInstances.trainBoxs.roleId':{$ne:roleId }, 'trainInstances.progress': {$gte: progress}, 'trainInstances.endTime':{$gte: time}}).lean(lean);
|
||||
return guildTrain;
|
||||
}
|
||||
|
||||
public static async receiveBoxByIndex(guildCode: string, roleId: string, trainId: number, hid: number, index: number, good: Reward, locked = false, lean = true) {
|
||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOneAndUpdate({ guildCode, trainId, locked, 'trainScripts.hid': hid, },
|
||||
{ $push:{ 'trainScripts.$.trainBoxs': {roleId, index, good} }} ).lean(lean);
|
||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOneAndUpdate({ guildCode, trainId, locked, 'trainInstances.hid': hid, },
|
||||
{ $push:{ 'trainInstances.$.trainBoxs': {roleId, index, good} }}, {new: true}).lean(lean);
|
||||
return guildTrain;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,12 +128,13 @@ export default class UserGuild extends BaseModel {
|
||||
const result = await UserGuildModel.findOneAndUpdate({ roleId, status: USER_GUILD_STATUS.ON }, { $inc: { honourWeekly: inc } }, { new: true }).select(select).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static async receiveTrainRewards(roleId: string, trainId: number, lean = true) {
|
||||
const result = await UserGuildModel.findOneAndUpdate({ roleId, status: USER_GUILD_STATUS.ON, 'trainRewards':{$ne: trainId }},
|
||||
{$push:{trainRewards: trainId} }).lean(lean);
|
||||
{$push:{trainRewards: trainId} },{new: true}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const UserGuildModel = getModelForClass(UserGuild);
|
||||
|
||||
@@ -49,6 +49,8 @@ import { dicGuildActiveDayReward } from './dictionary/DicGuildActiveDayReward';
|
||||
import { dicGuildActiveWeekReward } from './dictionary/DicGuildActiveWeekReward';
|
||||
import { dicGuildPosition } from "./dictionary/DicGuildPosition";
|
||||
import { dicMail } from "./dictionary/DicMail";
|
||||
import { dicArmyTrainJuDian } from './dictionary/dicArmyTrainJuDian';
|
||||
import { dicTrainSoloReward } from './dictionary/dicTrainSoloReward';
|
||||
|
||||
export const gameData = {
|
||||
blurprtCompose: dicBlueprtCompose,
|
||||
@@ -121,7 +123,8 @@ export const gameData = {
|
||||
guildActiveDayReward: dicGuildActiveDayReward,
|
||||
guildActiveWeekReward: dicGuildActiveWeekReward,
|
||||
guildPosition: dicGuildPosition,
|
||||
mail: dicMail
|
||||
armyTrainJuDian: dicArmyTrainJuDian,
|
||||
trainSoloReward: dicTrainSoloReward
|
||||
};
|
||||
|
||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||
@@ -334,4 +337,16 @@ export function hasStructureConsume(structureId: number, level: number) {
|
||||
|
||||
export function getBossByLv(lv: number) {
|
||||
return gameData.bossBase.get(lv);
|
||||
}
|
||||
}
|
||||
|
||||
export function getArmyTrainJuDian(trainId: number) {
|
||||
return gameData.armyTrainJuDian.get(trainId);
|
||||
}
|
||||
export function getTrainSoloReward(id: number) {
|
||||
return gameData.trainSoloReward.get(id);
|
||||
}
|
||||
export function getTrainBaseByLv(lv: number) {
|
||||
return gameData.trainBase.get(lv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
34
shared/pubUtils/dictionary/DicArmyTrainJuDian.ts
Normal file
34
shared/pubUtils/dictionary/DicArmyTrainJuDian.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { readJsonFile, parseGoodStr } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface DicArmyTrainJuDian {
|
||||
|
||||
readonly id: number;
|
||||
// 目标品质
|
||||
readonly trainInstances: Array<{hid: number, warId: number, progress: number}>;
|
||||
readonly heroRewards: Array<{id: number, count: number}>;
|
||||
}
|
||||
|
||||
const DicArmyTrainJuDianKeys: KeysEnum<DicArmyTrainJuDian> = {
|
||||
id: true,
|
||||
trainInstances: true,
|
||||
heroRewards: true
|
||||
};
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_ARMY_TRAIN_JU_DIAN);
|
||||
let arr = JSON.parse(str);
|
||||
|
||||
export const dicArmyTrainJuDian = new Map<number, DicArmyTrainJuDian>();
|
||||
arr.forEach(o => {
|
||||
o.trainInstances = o.gkid.split('|').map(element => {
|
||||
let arr = element.split('&');
|
||||
return {hid: parseInt(arr[0]), warId: parseInt(arr[1]), progress: parseInt(arr[2])};
|
||||
});
|
||||
|
||||
o.heroRewards = parseGoodStr(o.shilianReward);
|
||||
|
||||
dicArmyTrainJuDian.set(o.id,_.pick(o, Object.keys(DicArmyTrainJuDianKeys)));
|
||||
});
|
||||
arr = undefined;
|
||||
50
shared/pubUtils/dictionary/DicTrainSoloReward.ts
Normal file
50
shared/pubUtils/dictionary/DicTrainSoloReward.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { readJsonFile } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface DicTrainSoloReward {
|
||||
|
||||
readonly id: number;
|
||||
// 目标品质
|
||||
readonly ratio: number;
|
||||
readonly winScore: number;
|
||||
readonly failScore: number;
|
||||
readonly winHonour: number;
|
||||
readonly failHonour: number;
|
||||
|
||||
}
|
||||
|
||||
const DicTrainSoloRewardKeys: KeysEnum<DicTrainSoloReward> = {
|
||||
id: true,
|
||||
ratio: true,
|
||||
winScore: true,
|
||||
failScore: true,
|
||||
winHonour: true,
|
||||
failHonour: true,
|
||||
};
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_ARMY_TRAIN_SOLO_REWARD);
|
||||
let arr = JSON.parse(str);
|
||||
|
||||
export const dicTrainSoloReward = new Map<number, DicTrainSoloReward>();
|
||||
arr.forEach(o => {
|
||||
o.winReward.split('|').map(cur=>{
|
||||
let arr = cur.split('&');
|
||||
if (arr[0] == 1) {
|
||||
o.winScore = parseInt(arr[1]);
|
||||
} else if (arr[0] == 2) {
|
||||
o.winHonour = parseInt(arr[1]);
|
||||
}
|
||||
})
|
||||
o.failReward.split('|').map(cur=>{
|
||||
let arr = cur.split('&');
|
||||
if (arr[0] == 1) {
|
||||
o.failScore = parseInt(arr[1]);
|
||||
} else if (arr[0] == 2) {
|
||||
o.failHonour = parseInt(arr[1]);
|
||||
}
|
||||
})
|
||||
dicTrainSoloReward.set(o.id,_.pick(o, Object.keys(DicTrainSoloRewardKeys)));
|
||||
});
|
||||
arr = undefined;
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "试炼1-初出茅庐",
|
||||
"count": 4,
|
||||
"heroid": "1&3&5&4",
|
||||
"gkid": "1&8501|3&8502|5&8503|7&8504",
|
||||
"gkid": "1&8501&800|3&8502&800|5&8503&800|7&8504&800",
|
||||
"shilianReward": "40005&6000|20001&60|21008&30|42008&10",
|
||||
"soloRewardRatio": 1
|
||||
},
|
||||
@@ -13,7 +13,7 @@
|
||||
"name": "试炼2-过关斩将",
|
||||
"count": 4,
|
||||
"heroid": "2&3&5&7",
|
||||
"gkid": "2&8505|3&8506&|5&8507|7&8508",
|
||||
"gkid": "2&8505&800|3&8506&800|5&8507&800|7&8508&800",
|
||||
"shilianReward": "40005&4000|20001&60|21008&30|42008&11",
|
||||
"soloRewardRatio": 1.1
|
||||
},
|
||||
@@ -22,7 +22,7 @@
|
||||
"name": "试炼3-黄巾起义",
|
||||
"count": 4,
|
||||
"heroid": "7&8&9&10",
|
||||
"gkid": "7&8509|8&8510|9&8511|10&8512",
|
||||
"gkid": "7&8509&800|8&8510&800|9&8511&800|10&8512&800",
|
||||
"shilianReward": "40005&3000|20001&60|21008&30|42008&12",
|
||||
"soloRewardRatio": 1.2
|
||||
},
|
||||
@@ -31,7 +31,7 @@
|
||||
"name": "试炼4-火烧赤壁",
|
||||
"count": 4,
|
||||
"heroid": "11&12&13&14",
|
||||
"gkid": "11&8513|12&8514|13&8515|14&8516",
|
||||
"gkid": "11&8513&800|12&8514&800|13&8515&800|14&8516&800",
|
||||
"shilianReward": "40005&2000|20001&60|21008&30|42008&13",
|
||||
"soloRewardRatio": 1.3
|
||||
},
|
||||
@@ -40,7 +40,7 @@
|
||||
"name": "试炼5-官渡之战",
|
||||
"count": 4,
|
||||
"heroid": "7&8&9&11",
|
||||
"gkid": "7&8517|8&8518|9&8519|11&8520",
|
||||
"gkid": "7&8517&800|8&8518&800|9&8519&800|11&8520&800",
|
||||
"shilianReward": "40005&1000|20001&60|21008&30|42008&14",
|
||||
"soloRewardRatio": 1.4
|
||||
},
|
||||
@@ -49,7 +49,7 @@
|
||||
"name": "试炼6- 后起之秀",
|
||||
"count": 4,
|
||||
"heroid": "11&12&13&15",
|
||||
"gkid": "11&8521|12&8522|13&8523|15&8524",
|
||||
"gkid": "11&8521&800|12&8522&800|13&8523&800|15&8524&800",
|
||||
"shilianReward": "40005&500|20001&60|21008&30|42008&15",
|
||||
"soloRewardRatio": 1.5
|
||||
},
|
||||
@@ -58,7 +58,7 @@
|
||||
"name": "试炼7- 分庭抗礼",
|
||||
"count": 4,
|
||||
"heroid": "7&8&9&12",
|
||||
"gkid": "7&8525|8&8526|9&852712&8528",
|
||||
"gkid": "7&8525&800|8&8526&800|9&8527&800|12&8528&800",
|
||||
"shilianReward": "40005&6000|20001&60|21008&30|42008&16",
|
||||
"soloRewardRatio": 1.6
|
||||
},
|
||||
@@ -67,7 +67,7 @@
|
||||
"name": "试炼8- 群雄逐鹿",
|
||||
"count": 4,
|
||||
"heroid": "11&12&13&16",
|
||||
"gkid": "11&8529|12&8530|13&8531|16&8532",
|
||||
"gkid": "11&8529&800|12&8530&800|13&8531&800|16&8532&800",
|
||||
"shilianReward": "40005&4000|20001&60|21008&30|42008&17",
|
||||
"soloRewardRatio": 1.7
|
||||
},
|
||||
@@ -76,7 +76,7 @@
|
||||
"name": "试炼9-三足鼎立",
|
||||
"count": 4,
|
||||
"heroid": "7&8&9&13",
|
||||
"gkid": "7&8533|8&8534|9&8535|13&8536",
|
||||
"gkid": "7&8533&800|8&8534&800|9&8535&800|13&8536&800",
|
||||
"shilianReward": "40005&3000|20001&60|21008&30|42008&18",
|
||||
"soloRewardRatio": 1.8
|
||||
},
|
||||
@@ -85,7 +85,7 @@
|
||||
"name": "试炼10-封金挂印",
|
||||
"count": 4,
|
||||
"heroid": "11&12&13&17",
|
||||
"gkid": "11&8537|12&8538|13&8539|17&8540",
|
||||
"gkid": "11&8537&800|12&8538&800|13&8539&800|17&8540&800",
|
||||
"shilianReward": "40005&2000|20001&60|21008&30|42008&19",
|
||||
"soloRewardRatio": 2
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user