寻宝:奖励

This commit is contained in:
luying
2022-07-27 18:08:26 +08:00
parent 1cb41f2733
commit e1dc6307d2
11 changed files with 285 additions and 193 deletions

View File

@@ -8,7 +8,8 @@ export const ACTION_POIN = {
export const BATTLE_REWARD_TYPE = {
FIX_REWARD: 1,
CONDITION_REWARD: 2,
RANDOM_REWARD: 3
RANDOM_REWARD: 3,
EXTRA_REWARD: 4,
};
export const WAR_TYPE = {
@@ -18,7 +19,7 @@ export const WAR_TYPE = {
DAILY: 4, // 每日
EXPEDITION: 5, // 远征
MYSTERY: 6, // 秘境
WARLOARDS: 7, // 群雄
COM_BATTLE: 7, // 群雄
TOWER: 8, // 天梯
PVP: 9, // PVP
GUILD_ACTIVITY: 10, // 军团活动

View File

@@ -1,8 +1,8 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { EXTERIOR } from '../pubUtils/dicParam';
import { ItemReward } from '../domain/dbGeneral';
import { nowSeconds } from '../pubUtils/timeUtil';
import { RoleUpdate } from './Role';
export class ComRoleStatusHero {
@prop({ required: true })
@@ -33,12 +33,23 @@ export class ComRoleStatusHero {
}
}
export class ComBattleReward {
@prop({ required: true })
type: number;
@prop({ required: true })
id: number;
@prop({ required: true })
count: number;
}
export class RoleStatus {
@prop({ required: true })
roleId: string;
@prop({ required: true })
roleName: string;
@prop({ required: true })
guildCode: string;
@prop({ required: true })
isCap: boolean;
@prop({ required: true, default: 0 })
totalDmg: number;
@@ -79,30 +90,30 @@ export class RoleStatus {
@prop({ required: true, default: false })
gotReward: boolean;
// 队长奖励
@prop({ required: true, default: [], type: ItemReward })
fixReward: ItemReward[];
// 队友奖励
@prop({ required: true, default: [], type: ItemReward })
teammateReward: ItemReward[];
@prop({ required: true, default: [], type: ComBattleReward, _id: false })
rewards: ComBattleReward[];
// 好友间伤害加成
@prop({ required: true, default: 0 })
frdRatio: number = 0;
constructor(roleId: string, roleName: string, isCap: boolean, isFrd: boolean, head: number, frame: number, spine: number, topLineupCe: number, lv: number, heroes: ComRoleStatusHero[] = [], isRobot = false) {
this.roleId = roleId;
this.roleName = roleName;
constructor(role: RoleUpdate, isCap: boolean, isFrd: boolean, heroes: ComRoleStatusHero[] = [], isRobot = false) {
if(role) {
this.roleId = role.roleId||'';
this.roleName = role.roleName||'';
this.guildCode = role.guildCode||'';
this.head = role.head||EXTERIOR.EXTERIOR_FACE;
this.frame = role.frame||EXTERIOR.EXTERIOR_FACECASE;
this.spine = role.spine||EXTERIOR.EXTERIOR_APPEARANCE;
this.topLineupCe = role.topLineupCe||0;
this.lv = role.lv||1;
}
this.isCap = isCap;
this.totalDmg = 0;
this.isFrd = isFrd;
this.head = head;
this.frame = frame;
this.spine = spine;
this.topLineupCe = topLineupCe;
this.lv = lv;
this.heroes = heroes;
this.killed = [];
this.isRobot = isRobot;
this.fixReward = [];
this.rewards = [];
}
addFrdRatio(frdRatio: number) {
@@ -162,7 +173,7 @@ export default class ComBattleTeam extends BaseModel {
@prop({ required: true, default: 0 })
status: number;
@prop({ required: true, type: RoleStatus, default: [] })
@prop({ required: true, type: RoleStatus, default: [], _id: false })
roleStatus: RoleStatus[];
// 队长 roleId
@@ -178,7 +189,7 @@ export default class ComBattleTeam extends BaseModel {
roleCnt: number;
// 单个 boss 血量状态
@prop({ required: false, type: BossHp, default: [] })
@prop({ required: false, type: BossHp, default: [], _id: false })
bossHpArr: BossHp[];
// 队伍是否开放加入
@@ -188,6 +199,14 @@ export default class ComBattleTeam extends BaseModel {
// 黑名单
blacklist: string[] = [];
// 开始时间
@prop({ required: true, default: 0 })
startTime: number = 0;
// 是否有特殊时间奖励
@prop({ required: true, default: 0 })
hasTimeExtraReward: boolean = false;
// 结束时间
@prop({ required: true, default: 0 })
endTime: number = 0;
@@ -255,8 +274,8 @@ export default class ComBattleTeam extends BaseModel {
return team;
}
public static async updateStatusByCode(teamCode: string, status: number, lean = true) {
const team: ComBattleTeamType = await ComBattleTeamModel.findOneAndUpdate({ teamCode: teamCode }, {status}, {new: true}).lean(lean);
public static async updateStatusByCode(teamCode: string, status: number, startTime: number, endTime: number, hasTimeExtraReward: boolean) {
const team: ComBattleTeamType = await ComBattleTeamModel.findOneAndUpdate({ teamCode: teamCode }, { $set: {status, startTime, endTime, hasTimeExtraReward }}, {new: true}).lean();
return team;
}

View File

@@ -17,6 +17,8 @@ export default class FriendPoint extends BaseModel {
@prop({ required: true, default: 0 })
sendCnt: number; // 当天赠送的点数
@prop({ required: true, default: 0 })
comBattleCnt: number; // 今天在寻宝上获得的友情点
@prop({ required: true, default: 0 })
type: number; // 情谊点统计的类型,不同功能都可能有每日获取上限
/**

View File

@@ -1,8 +1,10 @@
import { COM_TEAM_STATUS } from '../../consts';
import { getBossHpByBlueprtId, getDicBlueprtById } from '../../pubUtils/data';
import { COM_BTL_CONST, COM_TEAM_STATUS } from '../../consts';
import { gameData, getBossHpByBlueprtId, getDicBlueprtById } from '../../pubUtils/data';
import ComBattleTeam from './../../db/ComBattleTeam';
import { cloneDeep } from 'lodash'
import { FriendParams } from '../roleField/friend';
import { nowSeconds } from '../../pubUtils/timeUtil';
import moment = require('moment');
/**
* 拷贝敌军数组并添加当前血量字段
@@ -48,6 +50,13 @@ export class MemComBtlTeam extends ComBattleTeam {
findMemberByRoleId(roleId: string) {
return this.roleStatus.find(cur => cur.roleId == roleId);
}
startTeam() {
this.status = COM_TEAM_STATUS.FIGHTING;
this.startTime = nowSeconds();
this.endTime = nowSeconds() + COM_BTL_CONST.BTL_TIME_LMT/1000;
this.hasTimeExtraReward = isComBattleTimeLimit();
}
};
@@ -65,4 +74,19 @@ export class MemComBtlTeam extends ComBattleTeam {
this.roleCnt = comBattle.roleCnt;
this.status = comBattle.status;
}
}
}
/**
* 当前是否是有加成的特殊时间
*/
export function isComBattleTimeLimit() {
let arr = gameData.comBattleRewardTime;
for(let { from, to } of arr) {
let fromTime = moment(moment().format(`YYYY-MM-DD ${from}`)).valueOf();
let toTime = moment(moment().format(`YYYY-MM-DD ${to}`)).valueOf();
let now = moment().valueOf();
if(fromTime <= now && toTime >= now) return true;
}
return false;
}

View File

@@ -11,7 +11,7 @@ import { dicQuestion, loadQuestion } from "./dictionary/DicQuestion";
import { dicSe, loadSe } from "./dictionary/DicSe";
import { dicTower, loadTower } from "./dictionary/DicTower";
import { dicTowerTask, loadTowerTask } from "./dictionary/DicTowerTask";
import { dicWar, dicWarPvp, dicDailyWarByType, loadWar, dicHeroIdByWar } from "./dictionary/DicWar";
import { dicWar, dicWarPvp, dicDailyWarByType, loadWar, dicHeroIdByWar, dicComBattleReward } from "./dictionary/DicWar";
import { dicWarJson, loadWarJson } from "./dictionary/DicWarJson";
import { AUCTION_TIME } from "../consts";
import { dicFashions, dicFashionsByHeroId, loadFashions } from "./dictionary/DicFashions";
@@ -273,7 +273,9 @@ export const gameData = {
ladderConsume: new Array<{id: number, count: number, times: number}>(),
ladderMatch: dicLadderMatch,
ladderDifficultRatio: dicLadderDifficultRatio,
ladderRankReward: dicLadderRankReward
ladderRankReward: dicLadderRankReward,
comBattleRewardTime: new Array<{from: string, to: string}>(),
comBattleReward: dicComBattleReward,
};
// 在此提供一些原先在gamedata中提供的方法以便更方便获取gameData数据
@@ -382,8 +384,8 @@ export function getWarByBlueprtId(blueprtId: number) {
}
export function getRewardByBlueprtId(blueprtId: number) {
let { fixReward, teammateReward } = getWarByBlueprtId(blueprtId);
return { fixReward, teammateReward };
let { war_id } = getWarByBlueprtId(blueprtId);
return gameData.comBattleReward.get(war_id);
}
function parseComBtlLvRange() {
@@ -1038,6 +1040,7 @@ function parseDicParam() {
getCeRatio();
loadAuctionTime();
decodeLadderBuyCost();
parseComBattleRewardTime();
}
/**
@@ -1090,6 +1093,17 @@ function treatTaskGroup() {
}
}
function parseComBattleRewardTime() {
let str = param.TREASURE.TIME_REWARD;
if (!str) return
let result: { from: string, to: string }[] = [];
let decodeArr = decodeArrayListStr(str);
for (let [from, to] of decodeArr) {
result.push({ from, to });
}
gameData.comBattleRewardTime = result;
}
// 加载json
function loadDatas() {
loadHero();

View File

@@ -1,5 +1,5 @@
// 关卡表
import {decodeArrayListStr, parseNumberList, readFileAndParse} from '../util'
import {decodeArrayListStr, parseGoodStr, parseNumberList, readFileAndParse} from '../util'
import { TRAIN_REWARD_TYPE, WAR_RELATE_TABLES, WAR_TYPE } from '../../consts';
import { isString } from 'underscore'
import { RewardInter } from '../interface';
@@ -33,10 +33,6 @@ export interface DicWar {
readonly dailyType: number;
// 寻宝匹配json
readonly dispatchJsonId: number;
// 寻宝奖励
readonly jackpotReward: Array<{id: number, weight: number}>;
// 寻宝队友奖励
readonly teammateReward: Array<{id: number, count: number}>;
// 镇念塔禁用角色
readonly fobiddenCharactor: Array<{type: number, id: number}>;
// 推荐战力
@@ -59,15 +55,32 @@ export interface DicWar {
readonly secondAttrLevel: number;
}
export interface DicComBattleReward {
// 关卡固定奖励
readonly captainReward: Array<{id: number, count: number}>;
// 队友奖励
readonly teammateReward: Array<{id: number, count: number}>;
// 队长限时段增加奖励
readonly captainTimeReward: Array<{id: number, count: number}>;
// 队友限时段增加奖励
readonly teammateTimeReward: Array<{id: number, count: number}>;
// 队长军团加成奖励
readonly captainTimeGuildReward: Map<number, {id: number, count: number}[]>;
// 队友军团加成奖励
readonly teammateTimeGuildReward: Map<number, {id: number, count: number}[]>;
}
export const dicWar = new Map<number, DicWar>();
export const dicWarPvp = new Array<DicWar>();
export const dicDailyWarByType = new Map<number, DicWar[]>();
export const dicHeroIdByWar = new Map<number, number>();
export const dicComBattleReward = new Map<number, DicComBattleReward>(); // warId => DicComBattleReward
export function loadWar() {
dicWar.clear();
dicDailyWarByType.clear();
dicWarPvp.splice(0, dicWarPvp.length);
dicHeroIdByWar.clear();
dicComBattleReward.clear();
for(let filename of WAR_RELATE_TABLES) {
let arr = readFileAndParse(filename);
@@ -75,7 +88,6 @@ export function loadWar() {
o.fixReward = parseFixReward(o.fixReward);
o.conditionReward = parseConditionReward(o.conditionReward);
o.randomReward = parseRandomReward(o.RandomReward||o.randomReward);
o.jackpotReward = parseJackpotReward(o.jackpotReward);
o.teammateReward = parseFixReward(o.teammateReward);
o.fobiddenCharactor = parseForbiddenChara(o.fobiddenCharactor);
o.mapseid = parseNumberList(o.mapseid);
@@ -100,6 +112,16 @@ export function loadWar() {
} else if (o.warType == WAR_TYPE.GUILD_TRAIN) {
o.winReward = parseTrainReward(o.winReward);
o.failReward = parseTrainReward(o.failReward);
} else if (o.warType == WAR_TYPE.COM_BATTLE) {
let reward = {
captainReward: parseGoodStr(o.fixReward),
teammateReward: parseGoodStr(o.teammateReward),
captainTimeReward: parseGoodStr(o.time_captain_normalReward),
teammateTimeReward: parseGoodStr(o.time_normalReward),
captainTimeGuildReward: parseComBattleTimeReward(o.time_captain_guildReward),
teammateTimeGuildReward: parseComBattleTimeReward(o.time_captain_guildReward),
}
dicComBattleReward.set(o.war_id, reward);
}
dicWar.set(o.war_id, o);
if(!!o.heroId) dicHeroIdByWar.set(o.war_id, o.heroId);
@@ -147,18 +169,18 @@ function parseRandomReward(str: string = '') {
return result
}
function parseJackpotReward(str: string = '') {
let result = new Array<{id: number, weight: number}>();
if(!str) return result;
let decodeArr = decodeArrayListStr(str);
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), weight: parseInt(weight)});
}
return result
}
// function parseJackpotReward(str: string = '') {
// let result = new Array<{id: number, weight: number}>();
// if(!str) return result;
// let decodeArr = decodeArrayListStr(str);
// 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), weight: parseInt(weight)});
// }
// return result
// }
function parseForbiddenChara(str: string = '') {
let result = new Array<{type: number, id: number}>();
@@ -196,4 +218,15 @@ function parseTrainReward(str: string) {
}
}
return result
}
function parseComBattleTimeReward(str: string) {
let result = new Map<number, {id: number, count: number}[]>();
if(!str) return result;
let decodeArr = decodeArrayListStr(str);
for(let i = 0; i < decodeArr.length; i++) {
let [id, count] = decodeArr[i]
result.set(i + 1, [{ id: parseInt(id), count: parseInt(count) }]);
}
return result;
}

View File

@@ -642,7 +642,7 @@ export function getReasonByWarType(warType: number) {
return ITEM_CHANGE_REASON.EXPEDITION_BATTLE_END;
case WAR_TYPE.MYSTERY:
return ITEM_CHANGE_REASON.MYSTERY_BATTLE_END;
case WAR_TYPE.WARLOARDS:
case WAR_TYPE.COM_BATTLE:
return ITEM_CHANGE_REASON.WARLOARDS_BATTLE_END;
case WAR_TYPE.TOWER:
return ITEM_CHANGE_REASON.TOWER_BATTLE_END;
@@ -685,7 +685,7 @@ export function getWarTypeName(warType: number) {
case WAR_TYPE.DAILY: return '每日';
case WAR_TYPE.EXPEDITION: return '远征';
case WAR_TYPE.MYSTERY: return '秘境';
case WAR_TYPE.WARLOARDS: return '群雄';
case WAR_TYPE.COM_BATTLE: return '寻宝';
case WAR_TYPE.TOWER: return '镇念塔';
case WAR_TYPE.PVP: return '竞技';
case WAR_TYPE.GUILD_ACTIVITY: return '军团活动';