修改结算的判断标准和各值的计算方式

This commit is contained in:
zhl 2021-02-24 20:45:11 +08:00
parent b94889eaa2
commit 3f02d3a3e9

View File

@ -40,11 +40,16 @@ class GameResult{
export class GameResultCommand extends Command<CardGameState, {}> {
async execute() {
let teamSet = new Set()
for (let [, player] of this.state.players) {
teamSet.add(player.team)
}
const teamCount = teamSet.size
// 计算最终结果
let hp: number[] = [0, 0];
let ap: number[] = [0, 0];
let petAp: number[] = [0, 0];
let score: number[] = [0, 0];
let hp: number[] = new Array(teamCount).fill(0);
let ap: number[] = new Array(teamCount).fill(0);
let petAp: number[] = new Array(teamCount).fill(0);
let score: number[] = new Array(teamCount).fill(0);
let results: Map<Player, GameResult> = new Map();
const fc = global.$cfg.get(BaseConst.FORMULA);
for (let [, player] of this.state.players) {
@ -64,20 +69,14 @@ export class GameResultCommand extends Command<CardGameState, {}> {
* @type {number}
*/
let winner = 0;
if (hp[0] > hp[1]) {
winner = 0;
} else if (hp[0] < hp[1]) {
winner = 1;
if (Math.max.apply(this, hp) > Math.min.apply(this, hp)) {
winner = hp.indexOf(Math.max.apply(this, hp))
} else {
if (ap[0] > ap[1]) {
winner = 0;
} else if (ap[0] < ap[1]){
winner = 1;
if (Math.max.apply(this, ap) > Math.min.apply(this, ap)) {
winner = ap.indexOf(Math.max.apply(this, ap))
} else {
if (petAp[0] >= petAp[1]) {
winner = 0;
} else if (petAp[0] < petAp[1]) {
winner = 1;
if (Math.max.apply(this, petAp) > Math.min.apply(this, petAp)) {
winner = petAp.indexOf(Math.max.apply(this, petAp))
}
}
}
@ -93,19 +92,18 @@ export class GameResultCommand extends Command<CardGameState, {}> {
let resultMap: Map<StateTypeEnum, [string, number]> = new Map();
let scoreMap: Map<Player, number> = new Map();
for (let [, player] of this.state.players) {
let otherTeam = 1 - player.team;
let result = results.get(player);
if (winner == player.team) {
if (score[player.team] >= score[otherTeam]) {
result.scoreChange = 100/(1+Math.pow(10, ((score[player.team]-score[otherTeam])/2500)));
if (score[player.team] == Math.max.apply(this, score)) {
result.scoreChange = 100/(1+Math.pow(10, ((score[player.team]- Math.min.apply(this, score))/2500)));
} else {
result.scoreChange = 100-100/(1+Math.pow(10, ((score[otherTeam]-score[player.team])/2500)));
result.scoreChange = 100-100/(1+Math.pow(10, ((Math.max.apply(this, score)-score[player.team])/2500)));
}
} else {
if (score[player.team] >= score[otherTeam]) {
result.scoreChange = -(80-80/(1+Math.pow(10, ((score[player.team]-score[otherTeam])/2500))));
if (score[player.team] == Math.max.apply(this, score)) {
result.scoreChange = -(80-80/(1+Math.pow(10, ((score[player.team]-Math.min.apply(this, score))/2500))));
} else {
result.scoreChange = -(80/(1+Math.pow(10, ((score[otherTeam]-score[player.team])/2500))));
result.scoreChange = -(80/(1+Math.pow(10, ((Math.max.apply(this, score)-score[player.team])/2500))));
}
}
let s = 0;