feat(gvg): 优化血量继承、实时刷新、遗迹天数、系统播报 6267076fc

This commit is contained in:
luying
2023-10-20 09:55:08 +08:00
parent c2ad7145c1
commit d9f911f520
14 changed files with 371 additions and 98 deletions

View File

@@ -16,6 +16,7 @@ import { GVGTeamMem } from "../battleField/gvgBattle";
import { GVGTeamType } from "../../db/GVGTeam";
import { GVGRoleDataType } from "../../db/GVGRoleData";
import { Combo } from "../battleField/pvp";
import { GVGHeroInfo, PvpEnemies } from "../dbGeneral";
class LeagueLeaderInfo {
name: string; // 盟主名
@@ -653,6 +654,41 @@ export class GVGCityMapInfo {
}
}
export class GVGTeamSpineInfo {
spine: number = 0;
roleId: string = '';
roleName: string = '';
serverName: string = '';
startMoveTime: number = 0;
stopMoveTime: number = 0;
moveCdTime: number = 0;
isMoving: boolean = false;
pointId: number = 0;
areaId: number = 0;
fromAreaId: number = 0;
teamCode: string = '';
leagueCode: string = '';
leagueName: string = '';
constructor(obj: GVGTeamType, serverName: string) {
this.spine = obj.spine;
this.roleId = obj.roleId;
this.roleName = obj.roleName;
this.serverName = serverName;
this.startMoveTime = obj.startMoveTime;
this.stopMoveTime = obj.stopMoveTime;
this.moveCdTime = obj.moveCdTime;
this.isMoving = nowSeconds() < this.stopMoveTime;
this.areaId = obj.areaId;
this.pointId = obj.pointId;
this.fromAreaId = obj.fromAreaId;
this.teamCode = obj.teamCode;
this.leagueCode = obj.leagueCode;
this.leagueName = obj.leagueName;
}
}
export class GVGTeamSpineInMap {
spine: number = 0;
roleId: string = '';
@@ -674,7 +710,7 @@ export class GVGTeamSpineInMap {
this.spine = obj.spine;
this.roleId = obj.roleId;
this.roleName = obj.roleName;
if(obj.serverId) this.serverName = serverNames[obj.serverId];
if (obj.serverId) this.serverName = serverNames[obj.serverId];
this.startMoveTime = obj.startMoveTime;
this.stopMoveTime = obj.stopMoveTime;
this.moveCdTime = obj.moveCdTime;
@@ -711,8 +747,10 @@ export class GVGTeamInList {
restartTime: number;
defenseTime: number;
curTeamBreak: boolean;
hpPercent: number;
lineup: GVGLineupInfo[];
constructor(team: GVGTeamType) {
constructor(team: GVGTeamType, needLineup = false) {
if(!team) return;
this.areaId = team.areaId;
this.pointId = team.pointId;
@@ -730,6 +768,22 @@ export class GVGTeamInList {
this.restartTime = team.restartTime;
this.defenseTime = team.defenseTime;
this.curTeamBreak = !!team.curTeamBreak;
this.calHpPercent(team.isRobot, team.lineup);
if(needLineup && team.lineup)
this.lineup = team.lineup.map(cur => new GVGLineupInfo(cur));
}
calHpPercent(isRobot: boolean, lineup: GVGHeroInfo[]) {
if (isRobot) {
this.hpPercent = 100;
return
}
let hpSum = 0, hpNum = 0;
for (let { hp = 'max', maxHp = 'max' } of lineup) {
hpSum += ((hp == 'max'|| maxHp == 'max')? 100: (hp / maxHp * 100));
hpNum ++;
}
this.hpPercent = Math.ceil(hpSum / hpNum);
}
}
@@ -766,18 +820,35 @@ export class GVGTeamInListOnPoint extends GVGTeamInList {
}
}
class GVGLineupInfo {
actorId: number; // 武将
dataId: number; // 出兵表上的位置
order: number; // 行动
subHid: number;
quality: number; // 品质
hp: number|"max" = 'max'; // 血量, 当max时表示满血量由客户端来算他的血条
maxHp: number|"max" = 'max'; // 血量, 当max时表示满血量由客户端来算他的血条
others: string = ''; // 护盾相关
constructor(info: GVGHeroInfo) {
this.actorId = info.actorId;
this.dataId = info.dataId;
this.order = info.outIndex;
this.subHid = info.subActorId;
this.quality = info.quality;
this.hp = info.hp == undefined? 'max': info.hp;
this.maxHp = info.maxHp == undefined? 'max': info.maxHp;
this.others = info.others||'';
}
}
export class MyTeamSimpleInfo {
teamCode: string; // 队伍唯一id
index: number; // 队伍位置
head: number; // 保存头像
frame: number; // 保存相框
spine: number; // 保存形象
lineup: {
actorId: number; // 武将
dataId: number; // 出兵表上的位置
order: number; // 行动
subHid: number;
}[];
lineup: GVGLineupInfo[];
combo: Combo[];
hasConfirm: boolean;
@@ -787,7 +858,7 @@ export class MyTeamSimpleInfo {
this.head = team.head;
this.frame = team.frame;
this.spine = team.spine;
this.lineup = team.lineup.map(({ actorId, dataId, outIndex, subActorId }) => ({ actorId, dataId, order: outIndex, subHid: subActorId }));
this.lineup = team.lineup.map(cur => new GVGLineupInfo(cur));
this.hasConfirm = team.confirmConfigId == configId;
this.combo = team.combo;
}
@@ -802,11 +873,7 @@ export class MyTeamInfo {
spine: number; // 保存形象
title: number; // 爵位
lv: number;
lineup: {
actorId: number; // 武将
dataId: number; // 出兵表上的位置
order: number; // 行动
}[];
lineup: GVGLineupInfo[];
lineupCe: number;
durability: number; // 耐久
maxDurability: number; // 最大耐久
@@ -827,7 +894,7 @@ export class MyTeamInfo {
this.spine = team.spine;
this.title = team.title;
this.lv = team.lv;
if(team.lineup) this.lineup = team.lineup.map(({ actorId, dataId, outIndex }) => ({ actorId, dataId, order: outIndex }));
if(team.lineup) this.lineup = team.lineup.map(cur => new GVGLineupInfo(cur));
this.durability = team.durability;
this.maxDurability = team.maxDurability;
this.restartTime = team.restartTime;
@@ -841,6 +908,26 @@ export class MyTeamInfo {
}
}
export class GVGWinStreakInfo {
roleId: string;
roleName: string;
head: number;
frame: number;
lv: number;
leagueName: string;
winStreak: number;
constructor(team: GVGTeamType, winStreak: number) {
this.roleId = team.roleId;
this.roleName = team.roleName;
this.head = team.head;
this.frame = team.frame;
this.lv = team.lv;
this.leagueName = team.leagueName;
this.winStreak = winStreak;
}
}
// 情报
// 联军排名
export class LeagueRankInInfoPage {
@@ -890,4 +977,16 @@ export class GuardCityInfoPage {
}
this.leagueCe = ce;
}
}
export class GVGEnemies extends PvpEnemies {
hp: number|'max' = 'max';
others: string = '';
// score: 这个武将的军功
constructor(warjson: DicWarJson, heroInfo: GVGHeroInfo) {
super(warjson, heroInfo);
if(heroInfo.hp != undefined) this.hp = heroInfo.hp;
if(heroInfo.others != undefined) this.others = heroInfo.others;
}
}