修改结算数据
This commit is contained in:
parent
82f0a7d79e
commit
24ac49fafb
@ -38,7 +38,7 @@ export function requestUnlockHero(accountid: string, heroid: number | string) {
|
|||||||
* 上报游戏结果
|
* 上报游戏结果
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export function reportGameResult(data: any) {
|
export async function reportGameResult(data: any) {
|
||||||
let dataStr = JSON.stringify(data);
|
let dataStr = JSON.stringify(data);
|
||||||
|
|
||||||
let reqConfig = {
|
let reqConfig = {
|
||||||
@ -51,13 +51,7 @@ export function reportGameResult(data: any) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
axios(reqConfig)
|
return axios(reqConfig)
|
||||||
.then(function (response) {
|
|
||||||
debugRoom(JSON.stringify(response.data));
|
|
||||||
})
|
|
||||||
.catch(function (err) {
|
|
||||||
error(err);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,9 +48,7 @@ export class GeneralRoom extends Room {
|
|||||||
if (options.count) {
|
if (options.count) {
|
||||||
this.robotCount = Math.min(Math.max(0, options.count), this.maxClients - 1);
|
this.robotCount = Math.min(Math.max(0, options.count), this.maxClients - 1);
|
||||||
}
|
}
|
||||||
if (options.match) {
|
this.match = !!options.match || false;
|
||||||
this.match = options.match;
|
|
||||||
}
|
|
||||||
if (options.score) {
|
if (options.score) {
|
||||||
this.score = options.score;
|
this.score = options.score;
|
||||||
}
|
}
|
||||||
|
@ -126,8 +126,8 @@ Object.defineProperties(Room.prototype, {
|
|||||||
let dstHp = player.hp + (hp | 0);
|
let dstHp = player.hp + (hp | 0);
|
||||||
let sourceP = this.state.players.get(fromplayer);
|
let sourceP = this.state.players.get(fromplayer);
|
||||||
if (sourceP && hp < 0) {
|
if (sourceP && hp < 0) {
|
||||||
sourceP.statData.inc(StateTypeEnum.DMG, hp);
|
sourceP.statData.inc(StateTypeEnum.DMG, Math.min(-hp, player.hp));
|
||||||
player.statData.inc(StateTypeEnum.TDMG, hp);
|
player.statData.inc(StateTypeEnum.TDMG, Math.min(-hp, player.hp));
|
||||||
}
|
}
|
||||||
debugRoom(`更新血量: ${player.id} ${player.hp} -> ${hp}, reason: ${reason}`);
|
debugRoom(`更新血量: ${player.id} ${player.hp} -> ${hp}, reason: ${reason}`);
|
||||||
if (dstHp <= 0) {
|
if (dstHp <= 0) {
|
||||||
@ -200,6 +200,7 @@ Object.defineProperties(Room.prototype, {
|
|||||||
if (!player || !targetPlayer) {
|
if (!player || !targetPlayer) {
|
||||||
error(`updatePetStat, player or targetPlayer is null ${!!player} ${!!targetPlayer}`);
|
error(`updatePetStat, player or targetPlayer is null ${!!player} ${!!targetPlayer}`);
|
||||||
}
|
}
|
||||||
|
debugRoom(`updatePetStat, val change, old: ${valOld}, new: ${valNew}`);
|
||||||
if (valNew < valOld) {
|
if (valNew < valOld) {
|
||||||
player?.statData.inc(StateTypeEnum.DMG, valOld - valNew);
|
player?.statData.inc(StateTypeEnum.DMG, valOld - valNew);
|
||||||
targetPlayer?.statData.inc(StateTypeEnum.TDMG, valOld - valNew);
|
targetPlayer?.statData.inc(StateTypeEnum.TDMG, valOld - valNew);
|
||||||
|
@ -22,6 +22,7 @@ class GameResult{
|
|||||||
public mvpScore: number
|
public mvpScore: number
|
||||||
public scoreChange: number
|
public scoreChange: number
|
||||||
public scoreOld: number
|
public scoreOld: number
|
||||||
|
public stat: any;
|
||||||
|
|
||||||
constructor(player: Player) {
|
constructor(player: Player) {
|
||||||
this.id = player.id;
|
this.id = player.id;
|
||||||
@ -30,6 +31,7 @@ class GameResult{
|
|||||||
this.alive = player.state != PlayerStateConst.PLAYER_DEAD;
|
this.alive = player.state != PlayerStateConst.PLAYER_DEAD;
|
||||||
this.ap = gameUtil.calcTotalAp(player);
|
this.ap = gameUtil.calcTotalAp(player);
|
||||||
this.scoreOld = player.score;
|
this.scoreOld = player.score;
|
||||||
|
this.stat = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -111,6 +113,7 @@ export class GameResultCommand extends Command<CardGameState, {}> {
|
|||||||
if (type >= scores.length) {
|
if (type >= scores.length) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
result.stat[type] = val;
|
||||||
val = val * scores[type];
|
val = val * scores[type];
|
||||||
s += val;
|
s += val;
|
||||||
if (resultMap.has(type)) {
|
if (resultMap.has(type)) {
|
||||||
@ -136,19 +139,23 @@ export class GameResultCommand extends Command<CardGameState, {}> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
let mvp;
|
||||||
for (let [p, val] of scoreMap) {
|
for (let [p, val] of scoreMap) {
|
||||||
let mvpRate = p.team == winner ? fc.get(70051).number : fc.get(70052).number;
|
let mvpRate = p.team == winner ? fc.get(70051).number : fc.get(70052).number;
|
||||||
let data = results.get(p);
|
let data = results.get(p);
|
||||||
data.mvpScore = val * mvpRate; // mvp分
|
data.mvpScore = val * mvpRate; // mvp分
|
||||||
|
if (!mvp) {
|
||||||
|
mvp = p;
|
||||||
|
} else {
|
||||||
|
if (data.mvpScore > results.get(mvp).mvpScore) {
|
||||||
|
mvp = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let resultData: any = {
|
|
||||||
winner: winner,
|
|
||||||
results: [...results.values()],
|
|
||||||
statics: statics
|
|
||||||
};
|
|
||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
this.room.bGameResult(resultData);
|
|
||||||
this.state.updateGameState(GameStateConst.STATE_GAME_OVER);
|
this.state.updateGameState(GameStateConst.STATE_GAME_OVER);
|
||||||
//启动定时, 时间到后, 踢出没离开且没点重玩的玩家, 并将房间设为非private
|
//启动定时, 时间到后, 踢出没离开且没点重玩的玩家, 并将房间设为非private
|
||||||
let resultTimeOver = async function () {
|
let resultTimeOver = async function () {
|
||||||
@ -186,7 +193,15 @@ export class GameResultCommand extends Command<CardGameState, {}> {
|
|||||||
}
|
}
|
||||||
let time = new GameEnv().gameResultTime * 1000;
|
let time = new GameEnv().gameResultTime * 1000;
|
||||||
this.room.beginSchedule(time, resultTimeOver, 'restart_schedule');
|
this.room.beginSchedule(time, resultTimeOver, 'restart_schedule');
|
||||||
self.reportGameResult(resultData.winner);
|
let seasonData = (await self.reportGameResult(winner, mvp.id, results.get(mvp).mvpScore, results)).data.data;
|
||||||
|
let resultData: any = {
|
||||||
|
winner: winner,
|
||||||
|
mvp: mvp.id,
|
||||||
|
results: [...results.values()],
|
||||||
|
statics: statics,
|
||||||
|
seasonData
|
||||||
|
};
|
||||||
|
this.room.bGameResult(resultData);
|
||||||
this.resetAllState();
|
this.resetAllState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,13 +245,15 @@ export class GameResultCommand extends Command<CardGameState, {}> {
|
|||||||
/**
|
/**
|
||||||
* 向info-svr上报游戏结果
|
* 向info-svr上报游戏结果
|
||||||
* @param {number} winner
|
* @param {number} winner
|
||||||
|
* @param mvp
|
||||||
|
* @param mvpScore
|
||||||
*/
|
*/
|
||||||
reportGameResult(winner: number) {
|
async reportGameResult(winner: number, mvp: string, mvpScore: number, results: Map<Player, GameResult>) {
|
||||||
let data: any = {
|
let data: any = {
|
||||||
roomid: this.room.roomId,
|
roomid: this.room.roomId,
|
||||||
round: this.state.round,
|
round: this.state.round,
|
||||||
winner: winner,
|
winner: winner,
|
||||||
season: 0,
|
season: this.room.match ? 1: 0
|
||||||
}
|
}
|
||||||
let players: any[] = [];
|
let players: any[] = [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
@ -246,6 +263,9 @@ export class GameResultCommand extends Command<CardGameState, {}> {
|
|||||||
for (let [key,val] of player.statData) {
|
for (let [key,val] of player.statData) {
|
||||||
dataObj[key] = val;
|
dataObj[key] = val;
|
||||||
}
|
}
|
||||||
|
if (player.id == mvp) {
|
||||||
|
data.mvp = player.accountId ;
|
||||||
|
}
|
||||||
players.push({
|
players.push({
|
||||||
accountid: player.accountId,
|
accountid: player.accountId,
|
||||||
playerid: player.id,
|
playerid: player.id,
|
||||||
@ -254,11 +274,13 @@ export class GameResultCommand extends Command<CardGameState, {}> {
|
|||||||
heroid: player.heroId,
|
heroid: player.heroId,
|
||||||
statdata: dataObj,
|
statdata: dataObj,
|
||||||
score: player.score,
|
score: player.score,
|
||||||
cards: cards
|
cards: cards,
|
||||||
|
scoreChange: results.get(player).scoreChange,
|
||||||
|
mvpscore: player.id == mvp ? mvpScore : 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
data.players = players;
|
data.players = players;
|
||||||
reportGameResult(data);
|
return reportGameResult(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ export class SelectHeroCommand extends Command<CardGameState, { client: Client,
|
|||||||
heroPet.ap = unitData.powernum;
|
heroPet.ap = unitData.powernum;
|
||||||
heroPet.state = 1;
|
heroPet.state = 1;
|
||||||
heroPet.id = unitData.id;
|
heroPet.id = unitData.id;
|
||||||
|
player.petData.set(0, heroPet.ap);
|
||||||
if (unitData.base_skill1id) heroPet.skills.push(unitData.base_skill1id);
|
if (unitData.base_skill1id) heroPet.skills.push(unitData.base_skill1id);
|
||||||
if (unitData.base_skill2id) heroPet.skills.push(unitData.base_skill2id);
|
if (unitData.base_skill2id) heroPet.skills.push(unitData.base_skill2id);
|
||||||
if (unitData.base_skill3id) heroPet.skills.push(unitData.base_skill3id);
|
if (unitData.base_skill3id) heroPet.skills.push(unitData.base_skill3id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user