Skip to content

Commit

Permalink
Add custom "Replace starting knight by dragon" mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gereon77 committed Jun 11, 2024
1 parent 1bb5c5d commit 7ffcdb4
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 45 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions agot-bg-game-server/src/client/GameSettingsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,21 @@ export default class GameSettingsComponent extends Component<GameSettingsCompone
onChange={() => this.changeGameSettings(() => this.gameSettings.useVassalPositions = !this.gameSettings.useVassalPositions)}
/>
</Col>
<Col xs="12">
<FormCheck
id="replace-knights-by-dragon-setting"
type="switch"
label={
<OverlayTrigger overlay={
<Tooltip id="replace-knights-by-dragon-tooltip">
All houses, except Targaryen, will replace their starting knight by a dragon.
</Tooltip>}>
<label htmlFor="replace-knights-by-dragon-setting">Replace knight by dragon</label>
</OverlayTrigger>}
checked={this.gameSettings.replaceKnightByDragon}
onChange={() => this.changeGameSettings(() => this.gameSettings.replaceKnightByDragon = !this.gameSettings.replaceKnightByDragon)}
/>
</Col>
<Col xs="12">
<FormCheck
id="hold-vps-setting"
Expand Down
2 changes: 1 addition & 1 deletion agot-bg-game-server/src/client/IngameComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ export default class IngameComponent extends Component<IngameComponentProps> {
</div>
</div>
</Row>
{this.gameSettings.playerCount >= 8 && <Row className="mx-0 mt-3">
{(this.gameSettings.playerCount >= 8 || this.gameSettings.replaceKnightByDragon) && <Row className="mx-0 mt-3">
<OverlayTrigger overlay={this.renderDragonStrengthTooltip()}
placement="auto">
<div>
Expand Down
2 changes: 2 additions & 0 deletions agot-bg-game-server/src/client/houseCardImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import aeroImage from "../../public/images/house-cards/Areo.png";
import arianneImage from "../../public/images/house-cards/Arianne.png";
import ashaImage from "../../public/images/house-cards/Asha.png";
import balonImage from "../../public/images/house-cards/Balon.png";
import balonNervedImage from "../../public/images/house-cards/Balon-nerved.png";
import blackfishImage from "../../public/images/house-cards/Blackfish.png";
import brienneImage from "../../public/images/house-cards/Brienne.png";
import catelynImage from "../../public/images/house-cards/Catelyn.png";
Expand Down Expand Up @@ -178,6 +179,7 @@ const houseCardImages = new BetterMap([
["areo-hotah", aeroImage],
["asha-greyjoy", ashaImage],
["balon-greyjoy", balonImage],
["balon-greyjoy-nerved", balonNervedImage],
["the-blackfish", blackfishImage],
["brienne-of-tarth", brienneImage],
["catelyn-stark", catelynImage],
Expand Down
96 changes: 56 additions & 40 deletions agot-bg-game-server/src/client/unitImages.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import BetterMap from "../utils/BetterMap";
import {dragon, footman, knight, ship, siegeEngine} from "../common/ingame-game-state/game-data-structure/unitTypes";
import barathFoot from "../../public/images/units/BarathFoot.png";
import barathKnight from "../../public/images/units/BarathKnight.png";
import barathSiege from "../../public/images/units/BarathSeige.png";
import barathShip from "../../public/images/units/BarathShip.png";
import boltonFoot from "../../public/images/units/BoltonFoot.png";
import boltonKnight from "../../public/images/units/BoltonKnight.png";
import boltonSiege from "../../public/images/units/BoltonSiege.png";
import boltonShip from "../../public/images/units/BoltonShip.png";
import lanFoot from "../../public/images/units/LanFoot.png";
import lanKnight from "../../public/images/units/LanKnight.png";
import lanSiege from "../../public/images/units/LanSeige.png";
import lanShip from "../../public/images/units/LanShip.png";
import baraFoot from "../../public/images/units/BarathFoot.png";
import baraKnight from "../../public/images/units/BarathKnight.png";
import baraSiege from "../../public/images/units/BarathSeige.png";
import baraShip from "../../public/images/units/BarathShip.png";
import boltFoot from "../../public/images/units/BoltonFoot.png";
import boltKnight from "../../public/images/units/BoltonKnight.png";
import boltSiege from "../../public/images/units/BoltonSiege.png";
import boltShip from "../../public/images/units/BoltonShip.png";
import lannFoot from "../../public/images/units/LanFoot.png";
import lannKnight from "../../public/images/units/LanKnight.png";
import lannSiege from "../../public/images/units/LanSeige.png";
import lannShip from "../../public/images/units/LanShip.png";
import starFoot from "../../public/images/units/StarFoot.png";
import starKnight from "../../public/images/units/StarKnight.png";
import starSiege from "../../public/images/units/StarSeige.png";
Expand All @@ -28,70 +28,86 @@ import tyrFoot from "../../public/images/units/TyrFoot.png";
import tyrKnight from "../../public/images/units/TyrKnight.png";
import tyrSiege from "../../public/images/units/TyrSeige.png";
import tyrShip from "../../public/images/units/TyrShip.png";
import arrynFoot from "../../public/images/units/ArrynFoot.png"
import arrynKnight from "../../public/images/units/ArrynKnight.png";
import arrynSiege from "../../public/images/units/ArrynSiege.png";
import arrynShip from "../../public/images/units/ArrynShip.png";
import targaryenShip from "../../public/images/units/TargShip.png";
import targaryenFoot from "../../public/images/units/TargFoot.png";
import arrFoot from "../../public/images/units/ArrynFoot.png"
import arrKnight from "../../public/images/units/ArrynKnight.png";
import arrSiege from "../../public/images/units/ArrynSiege.png";
import arrShip from "../../public/images/units/ArrynShip.png";
import targShip from "../../public/images/units/TargShip.png";
import targFoot from "../../public/images/units/TargFoot.png";
import targKnight from "../../public/images/units/TargKnight.png";
import targDragon from "../../public/images/units/TargDragon.png";
import baraDragon from "../../public/images/units/BaraDragon.png";
import lannDragon from "../../public/images/units/LannDragon.png";
import starDragon from "../../public/images/units/StarDragon.png";
import boltDragon from "../../public/images/units/BoltDragon.png";
import greyDragon from "../../public/images/units/GreyDragon.png";
import martDragon from "../../public/images/units/MartDragon.png";
import tyrDragon from "../../public/images/units/TyrDragon.png";
import arrDragon from "../../public/images/units/ArrDragon.png";


const unitImages = new BetterMap([
["baratheon", new BetterMap([
[footman.id, barathFoot],
[knight.id, barathKnight],
[siegeEngine.id, barathSiege],
[ship.id, barathShip]
[footman.id, baraFoot],
[knight.id, baraKnight],
[siegeEngine.id, baraSiege],
[ship.id, baraShip],
[dragon.id, baraDragon]
])],
["lannister", new BetterMap([
[footman.id, lanFoot],
[knight.id, lanKnight],
[siegeEngine.id, lanSiege],
[ship.id, lanShip]
[footman.id, lannFoot],
[knight.id, lannKnight],
[siegeEngine.id, lannSiege],
[ship.id, lannShip],
[dragon.id, lannDragon]
])],
["stark", new BetterMap([
[footman.id, starFoot],
[knight.id, starKnight],
[siegeEngine.id, starSiege],
[ship.id, starShip]
[ship.id, starShip],
[dragon.id, starDragon]
])],
["greyjoy", new BetterMap([
[footman.id, greyFoot],
[knight.id, greyKnight],
[siegeEngine.id, greySiege],
[ship.id, greyShip]
[ship.id, greyShip],
[dragon.id, greyDragon]
])],
["martell", new BetterMap([
[footman.id, martFoot],
[knight.id, martKnight],
[siegeEngine.id, martSiege],
[ship.id, martShip]
[ship.id, martShip],
[dragon.id, martDragon]
])],
["tyrell", new BetterMap([
[footman.id, tyrFoot],
[knight.id, tyrKnight],
[siegeEngine.id, tyrSiege],
[ship.id, tyrShip]
[ship.id, tyrShip],
[dragon.id, tyrDragon]
])],
["arryn", new BetterMap([
[footman.id, arrynFoot],
[knight.id, arrynKnight],
[siegeEngine.id, arrynSiege],
[ship.id, arrynShip]
[footman.id, arrFoot],
[knight.id, arrKnight],
[siegeEngine.id, arrSiege],
[ship.id, arrShip],
[dragon.id, arrDragon]
])],
["bolton", new BetterMap([
[footman.id, boltonFoot],
[knight.id, boltonKnight],
[siegeEngine.id, boltonSiege],
[ship.id, boltonShip]
[footman.id, boltFoot],
[knight.id, boltKnight],
[siegeEngine.id, boltSiege],
[ship.id, boltShip],
[dragon.id, boltDragon]
])],
["targaryen", new BetterMap([
[footman.id, targaryenFoot],
[footman.id, targFoot],
[knight.id, targKnight],
[dragon.id, targDragon],
[ship.id, targaryenShip]
[ship.id, targShip]
])]
]);

Expand Down
3 changes: 2 additions & 1 deletion agot-bg-game-server/src/common/EntireGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class EntireGame extends GameState<null, LobbyGameState | IngameG
draftHouseCards: false, thematicDraft: false, limitedDraft: false, randomDraft: false, blindDraft: false, selectedDraftDecks: HouseCardDecks.All,
mixedWesterosDeck1: false, cokWesterosPhase: false, fogOfWar: false, victoryPointsCountNeededToWin: 7, loyaltyTokenCountNeededToWin: 7, endless: false, faceless: false,
useVassalPositions: false, precedingMustering: false, randomStartPositions: false, initialLiveClock: 60,
noPrivateChats: false, tournamentMode: false, fixedClock: false, holdVictoryPointsUntilEndOfRound: false
noPrivateChats: false, tournamentMode: false, fixedClock: false, holdVictoryPointsUntilEndOfRound: false, replaceKnightByDragon: false
};

onSendClientMessage?: (message: ClientMessage) => void;
Expand Down Expand Up @@ -820,4 +820,5 @@ export interface GameSettings {
fixedClock: boolean;
holdVictoryPointsUntilEndOfRound: boolean;
fogOfWar: boolean;
replaceKnightByDragon: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ActionGameState, {SerializedActionGameState} from "./action-game-state/Ac
import Order from "./game-data-structure/Order";
import Game, {SerializedGame} from "./game-data-structure/Game";
import WesterosGameState, {SerializedWesterosGameState} from "./westeros-game-state/WesterosGameState";
import createGame, { applyChangesForDanceWithMotherOfDragons } from "./game-data-structure/createGame";
import createGame, { applyChangesForDanceWithMotherOfDragons, replaceKnightsByDragons } from "./game-data-structure/createGame";
import BetterMap from "../../utils/BetterMap";
import House from "./game-data-structure/House";
import Unit from "./game-data-structure/Unit";
Expand Down Expand Up @@ -146,6 +146,10 @@ export default class IngameGameState extends GameState<
applyChangesForDanceWithMotherOfDragons(this);
}

if (this.entireGame.gameSettings.replaceKnightByDragon) {
replaceKnightsByDragons(this);
}

if (this.entireGame.gameSettings.onlyLive) {
this.players.values.forEach(p => p.liveClockData = {
remainingSeconds: this.entireGame.gameSettings.initialLiveClock * 60,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Region from "./Region";
import World from "./World";
import WesterosCard from "./westeros-card/WesterosCard";
import {fireMadeFlesh, westerosCardTypes} from "./westeros-card/westerosCardTypes";
import unitTypes, { ship } from "./unitTypes";
import unitTypes, { dragon, knight, ship } from "./unitTypes";
import Game from "./Game";
import WildlingCard from "./wildling-card/WildlingCard";
import wildlingCardTypes from "./wildling-card/wildlingCardTypes";
Expand All @@ -20,8 +20,9 @@ import IronBank from "./IronBank";
import loanCardTypes from "./loan-card/loanCardTypes";
import LoanCard from "./loan-card/LoanCard";
import { specialObjectiveCards } from "./static-data-structure/objectiveCards";
import popRandom from "../../../utils/popRandom";
import popRandom, { pickRandom } from "../../../utils/popRandom";
import { HouseCardDecks } from "../../../common/EntireGame";
import Unit from "./Unit";

interface HouseCardContainer {
houseCards: {[key: string]: HouseCardData};
Expand Down Expand Up @@ -591,4 +592,45 @@ export function applyChangesForDanceWithMotherOfDragons(ingame: IngameGameState)
while (_.some(_.take(game.westerosDecks[3], 2), wc => wc.type == fireMadeFlesh)) {
shuffleInPlace(game.westerosDecks[3]);
}
}

export function replaceKnightsByDragons(ingame: IngameGameState): void {
const game = ingame.game;
const houses = _.without(game.houses.values, game.targaryen) as House[];

for (const house of houses) {
let knightToReplace: Unit;
const capital = ingame.world.getCapitalOfHouse(house) as Region;
const knightInCapital = _.first(capital.units.values.filter(u => u.type == knight));

if (knightInCapital) {
knightToReplace = knightInCapital;
} else {
const knights = ingame.world.getUnitsOfHouse(house).filter(u => u.type == knight);
if (knights.length == 0) {
throw new Error("Each house starts with at least one knight!");
}
knightToReplace = pickRandom(knights) as Unit;
}

const region = knightToReplace.region;
region.units.delete(knightToReplace.id);
const newDragon = game.createUnit(region, dragon, house);
region.units.set(newDragon.id, newDragon);
}

if (game.dragonStrengthTokens.length == 0) {
game.dragonStrengthTokens = [2, 4, 6, 8, 10];
}

const balon = game.draftableHouseCards.has("balon-greyjoy")
? game.draftableHouseCards.get("balon-greyjoy")
: _.flatMap(game.houses.values.map(h => h.houseCards.values)).find(hc => hc.id == "balon-greyjoy");

if (balon) {
balon.id = "balon-greyjoy-nerved";
balon.ability = houseCardAbilities.get("jaqen-h-ghar");
}

game.world.regions.values.filter(r => r.superControlPowerToken != null && r.garrison == 2).forEach(r => r.garrison = 3);
}

0 comments on commit 7ffcdb4

Please sign in to comment.