Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gereon77 committed Jul 6, 2024
1 parent 31b597f commit b33e945
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
4 changes: 2 additions & 2 deletions agot-bg-game-server/src/client/EntireGameComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ export default class EntireGameComponent extends Component<EntireGameComponentPr
<div className="text-center">
{this.settings.dragonWar && <>
<p>
<h6>Dragon war</h6>
<h6>Dragon War</h6>
<small>Balon Greyjoy and Aeron Damphair (DwD) have been nerfed!</small>
</p>
</>}
{this.settings.dragonRevenge && <>
<p>
<h6>Dragon revenge</h6>
<h6>Dragon Revenge</h6>
<small>The last remaining non-dragon land unit will transform into a dragon!</small>
</p>
</>}
Expand Down
21 changes: 18 additions & 3 deletions agot-bg-game-server/src/client/MapComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import _ from "lodash";
import PartialRecursive from "../utils/PartialRecursive";
import { land, sea } from "../common/ingame-game-state/game-data-structure/regionTypes";
import PlaceOrdersGameState from "../common/ingame-game-state/planning-game-state/place-orders-game-state/PlaceOrdersGameState";
import PlaceOrdersForVassalsGameState from "../common/ingame-game-state/planning-game-state/place-orders-for-vassals-game-state/PlaceOrdersForVassalsGameState";
import UseRavenGameState from "../common/ingame-game-state/action-game-state/use-raven-game-state/UseRavenGameState";
import { renderRegionTooltip } from "./regionTooltip";
import getGarrisonToken from "./garrisonTokens";
Expand Down Expand Up @@ -377,10 +378,24 @@ export default class MapComponent extends Component<MapComponentProps> {
}

const clickable = property.onClick != undefined;
const dragonStrength = this.ingame.game.currentDragonStrength;

const dragonPrefix = u.type.id == "dragon"
? dragonStrength <= -1
? <></>
: dragonStrength <= 1
? <>Baby </>
: dragonStrength <= 3
? <></>
: dragonStrength <= 5
? <>Monster </>
: <></>
: <>
</>;

return <OverlayTrigger
overlay={<Tooltip id={"unit-tooltip-" + u.id} className="tooltip-w-100">
<div className="text-center"><b>{u.type.name}</b><small> of <b>{controller?.name ?? "Unknown"}</b><br /><b>{r.name}</b></small></div>
<div className="text-center"><b>{dragonPrefix}{u.type.name}</b><small> of <b>{controller?.name ?? "Unknown"}</b><br /><b>{r.name}</b></small></div>
</Tooltip>}
key={`map-unit-_${controller?.id ?? "must-be-controlled"}_${u.id}`}
delay={{ show: 500, hide: 100 }}
Expand All @@ -405,7 +420,7 @@ export default class MapComponent extends Component<MapComponentProps> {
"pulsate-bck_fade-in": property.animateFadeIn,
"pulsate-bck_fade-out": property.animateFadeOut,
},
getClassNameForDragonStrength(u.type.id, this.ingame.game.currentDragonStrength)
getClassNameForDragonStrength(u.type.id, dragonStrength)
)}
style={{
backgroundImage: `url(${unitImages.get(u.allegiance.id).get(u.upgradedType ? u.upgradedType.id : u.type.id)})`,
Expand Down Expand Up @@ -597,7 +612,7 @@ export default class MapComponent extends Component<MapComponentProps> {
}

const drawBorder = order?.type.restrictedTo == sea.kind;
const hasPlaceOrders = this.ingame.hasChildGameState(PlaceOrdersGameState);
const hasPlaceOrders = this.ingame.hasChildGameState(PlaceOrdersGameState) || this.ingame.hasChildGameState(PlaceOrdersForVassalsGameState);
const controller = drawBorder || hasPlaceOrders ? region.getController() : null;
const color = drawBorder && controller
? controller.id != "greyjoy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CombatGameState from "../action-game-state/resolve-march-order-game-state
import ClaimVassalsGameState from "../planning-game-state/claim-vassals-game-state/ClaimVassalsGameState";
import { getTimeDeltaInSeconds } from "../../../utils/getElapsedSeconds";
import BiddingGameState from "../westeros-game-state/bidding-game-state/BiddingGameState";
import PlaceOrdersGameState from "../planning-game-state/place-orders-game-state/PlaceOrdersGameState";
import PlanningGameState from "../planning-game-state/PlanningGameState";

export enum VoteState {
ONGOING,
Expand Down Expand Up @@ -79,9 +79,9 @@ export default class Vote {
}

const swapHousesVoteType = this.type;
if (this.ingame.hasChildGameState(PlaceOrdersGameState)) {
const placeOrders = this.ingame.getChildGameState(PlaceOrdersGameState) as PlaceOrdersGameState;
if (placeOrders.placedOrders.keys.some(r => {
if (this.ingame.hasChildGameState(PlanningGameState)) {
const planning = this.ingame.getChildGameState(PlanningGameState) as PlanningGameState;
if (planning.placedOrders.keys.some(r => {
const controller = r.getController();
return controller == swapHousesVoteType.initiatorHouse || controller == swapHousesVoteType.swappingHouse})
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Order from "../game-data-structure/Order";
import _ from "lodash";
import GameEndedGameState from "../game-ended-game-state/GameEndedGameState";
import ChooseInitialObjectivesGameState from "../choose-initial-objectives-game-state/ChooseInitialObjectivesGameState";
import PlanningGameState from "../planning-game-state/PlanningGameState";
import PlaceOrdersForVassalsGameState from "../planning-game-state/place-orders-for-vassals-game-state/PlaceOrdersForVassalsGameState";

export type SerializedVoteType = SerializedCancelGame | SerializedEndGame
| SerializedReplacePlayer | SerializedReplacePlayerByVassal | SerializedReplaceVassalByPlayer
Expand Down Expand Up @@ -266,9 +268,9 @@ export class CancelGame extends VoteType {
ingame.resumeGame(true);
}

if (ingame.hasChildGameState(PlaceOrdersGameState)) {
const placeOrders = vote.ingame.getChildGameState(PlaceOrdersGameState) as PlaceOrdersGameState;
ingame.ordersOnBoard = placeOrders.placedOrders as BetterMap<Region, Order>;
if (ingame.hasChildGameState(PlanningGameState)) {
const planning = vote.ingame.getChildGameState(PlanningGameState) as PlanningGameState;
ingame.ordersOnBoard = planning.placedOrders as BetterMap<Region, Order>;
ingame.entireGame.broadcastToClients({
type: "reveal-orders",
orders: vote.ingame.ordersOnBoard.mapOver(r => r.id, o => o.id)
Expand Down Expand Up @@ -595,9 +597,10 @@ export class ReplaceVassalByPlayer extends VoteType {
houseCards: vote.ingame.game.oldPlayerHouseCards.entries.map(([h, hcs]) => [h.id, hcs.values.map(hc => hc.id)])
});

const placeOrders = vote.ingame.leafState instanceof PlaceOrdersGameState ? vote.ingame.leafState : null;
if (placeOrders) {
const planning = placeOrders.parentGameState;
const hasPlaceOrders = vote.ingame.hasChildGameState(PlanningGameState)
&& (vote.ingame.hasChildGameState(PlaceOrdersGameState) || vote.ingame.hasChildGameState(PlaceOrdersForVassalsGameState));
if (hasPlaceOrders) {
const planning = vote.ingame.getChildGameState(PlanningGameState) as PlanningGameState;

// Reset waitedFor data, to properly call ingame.setWaitedForPlayers() by the game-state-change
vote.ingame.resetAllWaitedForData();
Expand Down

0 comments on commit b33e945

Please sign in to comment.