✨ feat(gvg): 复活队伍
This commit is contained in:
@@ -69,13 +69,14 @@ export enum GVG_ITEM_TYPE {
|
||||
}
|
||||
|
||||
export enum GVG_ITEM {
|
||||
WHEAT = 1, // 小麦
|
||||
CORN = 2, // 粟米
|
||||
RICE = 3, // 水稻
|
||||
PRODUCE_COIN = 10, // 内政令
|
||||
FIGHT_COIN = 11, // 征战令
|
||||
BATTLE_FEAT = 12, // 战功
|
||||
KNIFE = 14, // 诸葛连弩
|
||||
WHEAT = 1, // 小麦
|
||||
CORN = 2, // 粟米
|
||||
RICE = 3, // 水稻
|
||||
PRODUCE_COIN = 10, // 内政令
|
||||
FIGHT_COIN = 11, // 征战令
|
||||
BATTLE_FEAT = 12, // 战功
|
||||
REVIVE_COIN = 13, // 复活令
|
||||
KNIFE = 14, // 诸葛连弩
|
||||
}
|
||||
|
||||
export enum GVG_RESOURCE_TYPE {
|
||||
|
||||
@@ -1128,6 +1128,7 @@ export enum ITEM_CHANGE_REASON {
|
||||
GVG_VESTIGE_END = 171, // gvg征战中原挑战
|
||||
GVG_VESTIGE_RECEIVE_RANK = 172, // gvg征战中原领取排行榜奖励
|
||||
GVG_TECH_SEND_KNIFE = 173, // gvg点科技树发放诸葛连弩
|
||||
GVG_REVIVE = 174, // gvg复活队伍
|
||||
}
|
||||
|
||||
export enum TA_EVENT {
|
||||
|
||||
@@ -378,6 +378,7 @@ export const STATUS = {
|
||||
GVG_TEAM_NOT_SAME_AREA: { code: 21415, simStr: '对方不在同一个区域内' },
|
||||
GVG_POINT_HAS_SETTLED: { code: 21416, simStr: '该据点已经有其他队伍驻守' },
|
||||
GVG_POINT_NOT_AREA: { code: 21417, simStr: '您不在该积分点所在区域' },
|
||||
GVG_TEAM_NOT_NEED_REVIVE: { code: 21418, simStr: '此队伍不需要复活' },
|
||||
|
||||
// 通用 30000 - 30099
|
||||
DIC_DATA_NOT_FOUND: { code: 30000, simStr: '数据表未找到' },
|
||||
|
||||
@@ -150,8 +150,14 @@ export default class GVGTeam extends BaseModel {
|
||||
return teams;
|
||||
}
|
||||
|
||||
// 获取我的编队
|
||||
public static async findByTeamCode(roleId: string, teamCode: string, select = '') {
|
||||
// 获取某个玩家的某个的编队
|
||||
public static async findMyTeamByCode(roleId: string, teamCode: string, select = '') {
|
||||
const res: GVGTeamType = await GVGTeamModel.findOne({ roleId, teamCode }).select(select).lean();
|
||||
return res;
|
||||
}
|
||||
|
||||
// 获取编队
|
||||
public static async findByCode(roleId: string, teamCode: string, select = '') {
|
||||
const res: GVGTeamType = await GVGTeamModel.findOne({ roleId, teamCode }).select(select).lean();
|
||||
return res;
|
||||
}
|
||||
@@ -256,31 +262,31 @@ export default class GVGTeam extends BaseModel {
|
||||
}
|
||||
|
||||
// 结算挑战方
|
||||
public static async battleEndAttack(teamCode: string, hpInc: number, playerScoreInc: number, rebirthAreaId: number) {
|
||||
public static async battleEndAttack(teamCode: string, hpInc: number, playerScoreInc: number, rebirthAreaId: number, reviveCd: number) {
|
||||
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $inc: { durability: hpInc, score: playerScoreInc } }, { new: true }).lean();
|
||||
if(team.durability <= 0) {
|
||||
let originPointId = team.pointId;
|
||||
team = await GVGTeamModel.teamBreak(teamCode, team.isRobot, team.maxDurability, rebirthAreaId);
|
||||
team = await GVGTeamModel.teamBreak(teamCode, team.isRobot, team.maxDurability, rebirthAreaId, reviveCd);
|
||||
team.originPointId = originPointId;
|
||||
}
|
||||
return team;
|
||||
}
|
||||
|
||||
// 结算防守方
|
||||
public static async battleEndDefense(teamCode: string, hpInc: number, playerScoreInc: number, rebirthAreaId: number) {
|
||||
public static async battleEndDefense(teamCode: string, hpInc: number, playerScoreInc: number, rebirthAreaId: number, reviveCd: number) {
|
||||
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { defenseTime: nowSeconds() + GVG.GVG_DEFAULT_DEFENSE_CD, lockTime: 0, lockTeamCode: '' }, $inc: { durability: hpInc, score: playerScoreInc } }, { new: true }).lean();
|
||||
if(team.durability <= 0) {
|
||||
let originPointId = team.pointId;
|
||||
team = await GVGTeamModel.teamBreak(teamCode, team.isRobot, team.maxDurability, rebirthAreaId);
|
||||
team = await GVGTeamModel.teamBreak(teamCode, team.isRobot, team.maxDurability, rebirthAreaId, reviveCd);
|
||||
team.originPointId = originPointId;
|
||||
}
|
||||
return team;
|
||||
}
|
||||
|
||||
// 队伍进入修整器
|
||||
public static async teamBreak(teamCode: string, isRobot: boolean, maxDurability: number, areaId: number) {
|
||||
public static async teamBreak(teamCode: string, isRobot: boolean, maxDurability: number, areaId: number, reviveCd: number) {
|
||||
if(!isRobot) {
|
||||
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { restartTime: nowSeconds() + GVG.GVG_DEFAULT_DEFENSE_CD, stopMoveTime: nowSeconds(), areaId, durability: maxDurability } }, { new: true }).lean();
|
||||
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { restartTime: nowSeconds() - reviveCd, stopMoveTime: nowSeconds(), areaId, durability: maxDurability } }, { new: true }).lean();
|
||||
team.curTeamBreak = true;
|
||||
return team;
|
||||
} else {
|
||||
@@ -332,6 +338,11 @@ export default class GVGTeam extends BaseModel {
|
||||
return team;
|
||||
}
|
||||
|
||||
// 复活
|
||||
public static async reviveTeam(teamCode: string) {
|
||||
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { restartTime: 0 } }, { new: true }).lean();
|
||||
return team;
|
||||
}
|
||||
}
|
||||
|
||||
export const GVGTeamModel = getModelForClass(GVGTeam);
|
||||
|
||||
@@ -79,6 +79,9 @@ export default class GVGUserData extends BaseModel {
|
||||
@prop({ required: false })
|
||||
cityId: number; // 城池id
|
||||
|
||||
@prop({ required: false })
|
||||
reviveCnt: number; // 城池id
|
||||
|
||||
public static async findByRole(configId: number, leagueCode: string, roleId: string) {
|
||||
const result: GVGUserDataType = await GVGUserDataModel.findOneAndUpdate({ configId, leagueCode, roleId }, {}, { new: true, upsert: true}).lean();
|
||||
return result;
|
||||
@@ -130,6 +133,11 @@ export default class GVGUserData extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async addReviveCnt(configId: number, leagueCode: string, roleId: string, cnt: number) {
|
||||
const result: GVGUserDataType = await GVGUserDataModel.findOneAndUpdate({ configId, leagueCode, roleId }, { $inc: { reviveCnt: cnt } }, { new: true, upsert: true}).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const GVGUserDataModel = getModelForClass(GVGUserData);
|
||||
|
||||
@@ -42,6 +42,7 @@ class LeaguePlayerData {
|
||||
// 奖励相关
|
||||
receivedLv: number = 0; // 奖励领到几级
|
||||
tasks: GVGTask[] = []; // 如果没有达成的任务就不放在这个数组里面
|
||||
reviveCnt: number = 0; // 使用元宝复活的次数
|
||||
}
|
||||
|
||||
class LeagueResource {
|
||||
@@ -129,6 +130,7 @@ export class GVGMainData {
|
||||
if(userData) {
|
||||
this.myInfo.job = userData?.job||0;
|
||||
this.myInfo.receivedLv = userData?.receivedLv||0;
|
||||
this.myInfo.reviveCnt = userData?.reviveCnt||0;
|
||||
}
|
||||
this.myInfo.tasks = tasks;
|
||||
}
|
||||
|
||||
@@ -337,6 +337,7 @@ export const gameData = {
|
||||
gvgBattleDurabilityMinus: { win: 0, fail: 0 },
|
||||
gvgTeamDurability: new Map<number, number>(),
|
||||
gvgPointByAreaId: dicGVGPointsByAreaId,
|
||||
gvgReviveGold: new Map<number|'max', number>(),
|
||||
};
|
||||
|
||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||
@@ -1230,6 +1231,21 @@ function parseGVGTeamDurability() {
|
||||
|
||||
}
|
||||
|
||||
function parseGVGReviveCoin() {
|
||||
let arr = decodeArrayListStr(param.GVG.GVG_REVIVE_GOLD);
|
||||
for(let [_cnt, _gold] of arr) {
|
||||
let cnt = parseInt(_cnt);
|
||||
let gold = parseInt(_gold);
|
||||
gameData.gvgReviveGold.set(cnt, gold);
|
||||
gameData.gvgReviveGold.set('max', gold);
|
||||
}
|
||||
}
|
||||
|
||||
export function getReviveGold(cnt: number) {
|
||||
if(gameData.gvgReviveGold.has(cnt)) return gameData.gvgReviveGold.get(cnt)||0;
|
||||
return gameData.gvgReviveGold.get('max')||0;
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
function initDatas() {
|
||||
parseDicParam();
|
||||
@@ -1255,6 +1271,7 @@ function parseDicParam() {
|
||||
parseGVGVestigeCnt();
|
||||
parseGVGDurabilityMinus();
|
||||
parseGVGTeamDurability();
|
||||
parseGVGReviveCoin();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user