diff --git a/resources/lang/en.json b/resources/lang/en.json index c31101bc9..a8a130767 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -500,7 +500,7 @@ }, "win_modal": { "support_openfront": "Support OpenFront!", - "territory_pattern": "Purchase a territory pattern to support OpenFront!", + "territory_pattern": "Purchase a territory skin to go ad-free!", "died": "You died", "your_team": "Your team won!", "other_team": "{team} team has won!", diff --git a/src/client/GutterAds.ts b/src/client/GutterAds.ts index f0f2f779f..b47f2939b 100644 --- a/src/client/GutterAds.ts +++ b/src/client/GutterAds.ts @@ -49,6 +49,7 @@ export class GutterAds extends LitElement { } public hide(): void { + this.isVisible = false; console.log("hiding GutterAds"); this.destroyAds(); this.requestUpdate(); diff --git a/src/client/Main.ts b/src/client/Main.ts index 37ae29027..2d61e78b6 100644 --- a/src/client/Main.ts +++ b/src/client/Main.ts @@ -350,6 +350,13 @@ class Client { "Sharing this ID will allow others to view your game history and stats.", ); this.patternsModal.onUserMe(userMeResponse); + const flares = (userMeResponse.player.flares ?? []).filter((flare) => + flare.startsWith("pattern:"), + ); + if (flares.length > 0) { + console.log("Hiding gutter ads because you have patterns"); + this.gutterAds.hide(); + } } }; diff --git a/src/client/Transport.ts b/src/client/Transport.ts index de1e3e7dc..e525aaf7f 100644 --- a/src/client/Transport.ts +++ b/src/client/Transport.ts @@ -496,7 +496,7 @@ export class Transport { type: "donate_gold", clientID: this.lobbyConfig.clientID, recipient: event.recipient.id(), - gold: event.gold, + gold: event.gold ? Number(event.gold) : null, }); } diff --git a/src/core/Schemas.ts b/src/core/Schemas.ts index 270cc2297..b13f8ac17 100644 --- a/src/core/Schemas.ts +++ b/src/core/Schemas.ts @@ -278,7 +278,7 @@ export const EmbargoIntentSchema = BaseIntentSchema.extend({ export const DonateGoldIntentSchema = BaseIntentSchema.extend({ type: z.literal("donate_gold"), recipient: ID, - gold: z.bigint().nullable(), + gold: z.number().nullable(), }); export const DonateTroopIntentSchema = BaseIntentSchema.extend({ diff --git a/src/core/execution/DonateGoldExecution.ts b/src/core/execution/DonateGoldExecution.ts index 214c7e915..51b60ce0a 100644 --- a/src/core/execution/DonateGoldExecution.ts +++ b/src/core/execution/DonateGoldExecution.ts @@ -1,15 +1,19 @@ import { Execution, Game, Gold, Player, PlayerID } from "../game/Game"; +import { toInt } from "../Util"; export class DonateGoldExecution implements Execution { private recipient: Player; private active = true; + private gold: Gold; constructor( private sender: Player, private recipientID: PlayerID, - private gold: Gold | null, - ) {} + goldNum: number | null, + ) { + this.gold = toInt(goldNum ?? 0); + } init(mg: Game, ticks: number): void { if (!mg.hasPlayer(this.recipientID)) { diff --git a/src/core/execution/WarshipExecution.ts b/src/core/execution/WarshipExecution.ts index f573a8a47..67cb17aef 100644 --- a/src/core/execution/WarshipExecution.ts +++ b/src/core/execution/WarshipExecution.ts @@ -55,6 +55,11 @@ export class WarshipExecution implements Execution { this.warship.delete(); return; } + if (this.warship.owner().isDisconnected()) { + this.warship.delete(); + return; + } + const hasPort = this.warship.owner().unitCount(UnitType.Port) > 0; if (hasPort) { this.warship.modifyHealth(1); diff --git a/src/server/MapPlaylist.ts b/src/server/MapPlaylist.ts index 3ce5dfd65..acb14cce0 100644 --- a/src/server/MapPlaylist.ts +++ b/src/server/MapPlaylist.ts @@ -79,8 +79,8 @@ export class MapPlaylist { // Create the default public game config (from your GameManager) return { - donateGold: false, - donateTroops: false, + donateGold: mode === GameMode.Team, + donateTroops: mode === GameMode.Team, gameMap: map, maxPlayers: config.lobbyMaxPlayers(map, mode, playerTeams), gameType: GameType.Public, diff --git a/src/server/Privilege.ts b/src/server/Privilege.ts index 380dcfb14..402b4c3c7 100644 --- a/src/server/Privilege.ts +++ b/src/server/Privilege.ts @@ -41,6 +41,12 @@ export class PrivilegeCheckerImpl implements PrivilegeChecker { return { type: "forbidden", reason: "invalid color: " + e.message }; } } + if (refs.flag) { + cosmetics.flag = cosmetics.flag = refs.flag.replace( + /[^a-z0-9-_ ()]/gi, + "", + ); + } return { type: "allowed", cosmetics }; } diff --git a/tests/Donate.test.ts b/tests/Donate.test.ts index bbbccd4f9..966f9d493 100644 --- a/tests/Donate.test.ts +++ b/tests/Donate.test.ts @@ -120,7 +120,7 @@ describe("Donate gold to an ally", () => { donor.addGold(6000n); const donorGoldBefore = donor.gold(); const recipientGoldBefore = recipient.gold(); - game.addExecution(new DonateGoldExecution(donor, recipientInfo.id, 5000n)); + game.addExecution(new DonateGoldExecution(donor, recipientInfo.id, 5000)); for (let i = 0; i < 5; i++) { game.executeNextTick(); @@ -242,7 +242,7 @@ describe("Donate Gold to a non ally", () => { const donorGoldBefore = donor.gold(); const recipientGoldBefore = donor.gold(); - game.addExecution(new DonateGoldExecution(donor, recipientInfo.id, 5000n)); + game.addExecution(new DonateGoldExecution(donor, recipientInfo.id, 5000)); game.executeNextTick(); // Gold should not be donated since they are not allies