mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-06 15:46:46 +00:00
Stop getting gold from conquering inactive players 🔧 (#3020)
## Description:
Maybe for v29.
In the 5M starting gold modifier games you can conquer a inactive player
(spawned but didn't do anything) and get their 5M gold.
Huge unfair advantage.
I think that even without the starting gold modifier you should not get
the gold of inactive players because its unfair.
I identify inactive players (spawned but didn't do anything) by checking
the attack stats.
I added a translation for the displayMessage "Conquered {name}, received
{gold} gold". Why was that not translated?
I added a new message "Conquered {name} (Inactive player, received no
gold)".
## Please complete the following:
- [X] I have added screenshots for all UI updates
- [X] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [X] I have added relevant tests to the test directory
- [X] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
## Please put your Discord username so you can be contacted if a bug or
regression is found:
FloPinguin
---------
Co-authored-by: Ryan <7389646+ryanbarlow97@users.noreply.github.com>
This commit is contained in:
+36
-13
@@ -7,6 +7,7 @@ import {
|
||||
import { AStarWaterHierarchical } from "../pathfinding/algorithms/AStar.WaterHierarchical";
|
||||
import { PathFinder } from "../pathfinding/types";
|
||||
import { AllPlayersStats, ClientID, Winner } from "../Schemas";
|
||||
import { ATTACK_INDEX_SENT } from "../StatsSchemas";
|
||||
import { simpleHash } from "../Util";
|
||||
import { AllianceImpl } from "./AllianceImpl";
|
||||
import { AllianceRequestImpl } from "./AllianceRequestImpl";
|
||||
@@ -1097,26 +1098,48 @@ export class GameImpl implements Game {
|
||||
}
|
||||
}
|
||||
|
||||
const gold = conquered.gold();
|
||||
this.displayMessage(
|
||||
`Conquered ${conquered.displayName()} received ${renderNumber(
|
||||
// Don't transfer gold when the conquered player didn't play (never attacked anyone)
|
||||
// This is especially important when starting gold is enabled
|
||||
const stats = this._stats.getPlayerStats(conquered);
|
||||
const attacksSent = stats?.attacks?.[ATTACK_INDEX_SENT] ?? 0n;
|
||||
const skipGoldTransfer =
|
||||
attacksSent === 0n && conquered.type() === PlayerType.Human;
|
||||
const gold = skipGoldTransfer ? 0n : conquered.gold();
|
||||
|
||||
if (skipGoldTransfer) {
|
||||
this.displayMessage(
|
||||
"events_display.conquered_no_gold",
|
||||
MessageType.CONQUERED_PLAYER,
|
||||
conqueror.id(),
|
||||
undefined,
|
||||
{
|
||||
name: conquered.displayName(),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
this.displayMessage(
|
||||
"events_display.received_gold_from_conquest",
|
||||
MessageType.CONQUERED_PLAYER,
|
||||
conqueror.id(),
|
||||
gold,
|
||||
)} gold`,
|
||||
MessageType.CONQUERED_PLAYER,
|
||||
conqueror.id(),
|
||||
gold,
|
||||
);
|
||||
conqueror.addGold(gold);
|
||||
conquered.removeGold(gold);
|
||||
{
|
||||
gold: renderNumber(gold),
|
||||
name: conquered.displayName(),
|
||||
},
|
||||
);
|
||||
conqueror.addGold(gold);
|
||||
conquered.removeGold(gold);
|
||||
|
||||
// Record stats
|
||||
this.stats().goldWar(conqueror, conquered, gold);
|
||||
}
|
||||
|
||||
this.addUpdate({
|
||||
type: GameUpdateType.ConquestEvent,
|
||||
conquerorId: conqueror.id(),
|
||||
conqueredId: conquered.id(),
|
||||
gold,
|
||||
});
|
||||
|
||||
// Record stats
|
||||
this.stats().goldWar(conqueror, conquered, gold);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user