mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 15:40:43 +00:00
9c24d29824
## Description: See PR https://github.com/openfrontio/OpenFrontIO/pull/2203 It was reverted. This unreverts it, with an added fix for boat troops not getting returned to owner. And small comment updates. And a const for boatOwner to re-use. The added bugfix is check for this.sourceTile === null in the retreat() function in AttackExecution. A boat attack always sets removeTroops to false because the troops were already removed from owner troops when the boat departed. They don't have to be removed again in AttackExecution init, when the boat lands and the attack starts. But at the end of the attack, in retreat() in AttackExecution, the starting/boat troops still need to be returned to the owner. That's why even if removeTroops is false, when sourceTile is not null (only when it's a boat attack) we add back the troops to the owner. ## 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: tryout33 --------- Co-authored-by: Fx Morin <28154542+FxMorin@users.noreply.github.com> Co-authored-by: Ryan <7389646+ryanbarlow97@users.noreply.github.com>
111 lines
2.2 KiB
TypeScript
111 lines
2.2 KiB
TypeScript
import { NukeMagnitude } from "../../src/core/configuration/Config";
|
|
import { DefaultConfig } from "../../src/core/configuration/DefaultConfig";
|
|
import {
|
|
Game,
|
|
Player,
|
|
TerraNullius,
|
|
Tick,
|
|
UnitType,
|
|
} from "../../src/core/game/Game";
|
|
import { TileRef } from "../../src/core/game/GameMap";
|
|
|
|
export class TestConfig extends DefaultConfig {
|
|
private _proximityBonusPortsNb: number = 0;
|
|
private _defaultNukeSpeed: number = 4;
|
|
|
|
samHittingChance(): number {
|
|
return 1;
|
|
}
|
|
|
|
radiusPortSpawn(): number {
|
|
return 1;
|
|
}
|
|
|
|
proximityBonusPortsNb(totalPorts: number): number {
|
|
return this._proximityBonusPortsNb;
|
|
}
|
|
|
|
// Specific to TestConfig
|
|
setProximityBonusPortsNb(nb: number): void {
|
|
this._proximityBonusPortsNb = nb;
|
|
}
|
|
|
|
nukeMagnitudes(_: UnitType): NukeMagnitude {
|
|
return { inner: 1, outer: 1 };
|
|
}
|
|
|
|
setDefaultNukeSpeed(speed: number): void {
|
|
this._defaultNukeSpeed = speed;
|
|
}
|
|
|
|
defaultNukeSpeed(): number {
|
|
return this._defaultNukeSpeed;
|
|
}
|
|
|
|
defaultNukeTargetableRange(): number {
|
|
return 20;
|
|
}
|
|
|
|
deletionMarkDuration(): number {
|
|
return 5;
|
|
}
|
|
|
|
defaultSamRange(): number {
|
|
return 20;
|
|
}
|
|
|
|
samRange(level: number): number {
|
|
return 20;
|
|
}
|
|
|
|
spawnImmunityDuration(): Tick {
|
|
return 0;
|
|
}
|
|
|
|
attackLogic(
|
|
gm: Game,
|
|
attackTroops: number,
|
|
attacker: Player,
|
|
defender: Player | TerraNullius,
|
|
tileToConquer: TileRef,
|
|
): {
|
|
attackerTroopLoss: number;
|
|
defenderTroopLoss: number;
|
|
tilesPerTickUsed: number;
|
|
} {
|
|
return { attackerTroopLoss: 1, defenderTroopLoss: 1, tilesPerTickUsed: 1 };
|
|
}
|
|
|
|
attackTilesPerTick(
|
|
attackTroops: number,
|
|
attacker: Player,
|
|
defender: Player | TerraNullius,
|
|
numAdjacentTilesWithEnemy: number,
|
|
): number {
|
|
return 1;
|
|
}
|
|
}
|
|
export class UseRealAttackLogic extends TestConfig {
|
|
// Override to use DefaultConfig's real attackLogic
|
|
attackLogic(
|
|
gm: Game,
|
|
attackTroops: number,
|
|
attacker: Player,
|
|
defender: Player | TerraNullius,
|
|
tileToConquer: TileRef,
|
|
): {
|
|
attackerTroopLoss: number;
|
|
defenderTroopLoss: number;
|
|
tilesPerTickUsed: number;
|
|
} {
|
|
return DefaultConfig.prototype.attackLogic.call(
|
|
this,
|
|
gm,
|
|
attackTroops,
|
|
attacker,
|
|
defender,
|
|
tileToConquer,
|
|
);
|
|
}
|
|
}
|