Merge branch 'main' into defenseposture

This commit is contained in:
1brucben
2025-04-19 01:54:00 +02:00
22 changed files with 247 additions and 79 deletions
+12 -12
View File
@@ -31,6 +31,7 @@ REGION=$1
VERSION_TAG="latest" VERSION_TAG="latest"
DOCKER_REPO="" DOCKER_REPO=""
ENV="" ENV=""
SSH_KEY=""
# Set environment-specific variables # Set environment-specific variables
if [ "$REGION" == "staging" ]; then if [ "$REGION" == "staging" ]; then
@@ -38,15 +39,18 @@ if [ "$REGION" == "staging" ]; then
SERVER_HOST=$SERVER_HOST_STAGING SERVER_HOST=$SERVER_HOST_STAGING
DOCKER_REPO=$DOCKER_REPO_STAGING DOCKER_REPO=$DOCKER_REPO_STAGING
ENV="staging" ENV="staging"
SSH_KEY=$SSH_KEY_STAGING
elif [ "$REGION" == "us" ]; then elif [ "$REGION" == "us" ]; then
print_header "DEPLOYING TO US ENVIRONMENT" print_header "DEPLOYING TO US ENVIRONMENT"
SERVER_HOST=$SERVER_HOST_US SERVER_HOST=$SERVER_HOST_US
DOCKER_REPO=$DOCKER_REPO_PROD # Uses prod Docker repo for alt environment DOCKER_REPO=$DOCKER_REPO_PROD # Uses prod Docker repo for alt environment
SSH_KEY=$SSH_KEY_PROD
ENV="prod" ENV="prod"
else else
print_header "DEPLOYING TO EU ENVIRONMENT" print_header "DEPLOYING TO EU ENVIRONMENT"
SERVER_HOST=$SERVER_HOST_EU SERVER_HOST=$SERVER_HOST_EU
DOCKER_REPO=$DOCKER_REPO_PROD DOCKER_REPO=$DOCKER_REPO_PROD
SSH_KEY=$SSH_KEY_PROD
ENV="prod" ENV="prod"
fi fi
@@ -57,10 +61,11 @@ if [ -z "$SERVER_HOST" ]; then
fi fi
# Configuration # Configuration
SSH_KEY=${SSH_KEY:-"~/.ssh/id_rsa"} # Use default or override from .env
DOCKER_USERNAME=${DOCKER_USERNAME} # Docker Hub username DOCKER_USERNAME=${DOCKER_USERNAME} # Docker Hub username
UPDATE_SCRIPT="./update.sh" # Path to your update script UPDATE_SCRIPT="./update.sh" # Path to your update script
REMOTE_UPDATE_SCRIPT="/root/update-openfront.sh" # Where to place the script on server REMOTE_USER="openfront"
REMOTE_UPDATE_PATH="/home/$REMOTE_USER"
REMOTE_UPDATE_SCRIPT="$REMOTE_UPDATE_PATH/update-openfront.sh" # Where to place the script on server
# Check if update script exists # Check if update script exists
if [ ! -f "$UPDATE_SCRIPT" ]; then if [ ! -f "$UPDATE_SCRIPT" ]; then
@@ -90,28 +95,23 @@ if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
if [ $? -ne 0 ]; then
echo "❌ Failed to push image to Docker Hub. Stopping deployment."
exit 1
fi
echo "✅ Docker image built and pushed successfully." echo "✅ Docker image built and pushed successfully."
# Step 2: Copy update script to Hetzner server # Step 2: Copy update script to Hetzner server
print_header "STEP 2: Copying update script to server" print_header "STEP 2: Copying update script to server"
echo "Target: $SERVER_HOST" echo "Target: $REMOTE_USER@$SERVER_HOST"
# Make sure the update script is executable # Make sure the update script is executable
chmod +x $UPDATE_SCRIPT chmod +x $UPDATE_SCRIPT
# Copy the update script to the server # Copy the update script to the server
scp -i $SSH_KEY $UPDATE_SCRIPT $SERVER_HOST:$REMOTE_UPDATE_SCRIPT scp -i $SSH_KEY $UPDATE_SCRIPT $REMOTE_USER@$SERVER_HOST:$REMOTE_UPDATE_SCRIPT
# Copy environment variables if needed # Copy environment variables if needed
if [ -f .env ]; then if [ -f .env ]; then
scp -i $SSH_KEY .env $SERVER_HOST:/root/.env scp -i $SSH_KEY .env $REMOTE_USER@$SERVER_HOST:$REMOTE_UPDATE_PATH/.env
# Secure the .env file # Secure the .env file
ssh -i $SSH_KEY $SERVER_HOST "chmod 600 /root/.env" ssh -i $SSH_KEY $REMOTE_USER@$SERVER_HOST "chmod 600 $REMOTE_UPDATE_PATH/.env"
fi fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@@ -125,7 +125,7 @@ echo "✅ Update script successfully copied to server."
print_header "STEP 3: Executing update script on server" print_header "STEP 3: Executing update script on server"
# Make the script executable on the remote server and execute it with the environment parameter # Make the script executable on the remote server and execute it with the environment parameter
ssh -i $SSH_KEY $SERVER_HOST "chmod +x $REMOTE_UPDATE_SCRIPT && $REMOTE_UPDATE_SCRIPT $REGION $DOCKER_USERNAME $DOCKER_REPO" ssh -i $SSH_KEY $REMOTE_USER@$SERVER_HOST "chmod +x $REMOTE_UPDATE_SCRIPT && $REMOTE_UPDATE_SCRIPT $REGION $DOCKER_USERNAME $DOCKER_REPO"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "❌ Failed to execute update script on server." echo "❌ Failed to execute update script on server."
+18 -12
View File
@@ -1,14 +1,20 @@
# AWS Configuration # Server Configuration
AWS_REGION=region-name SERVER_HOST_STAGING=xxx.xxx.xx.xxx
AWS_ACCOUNT_ID=your-account-id SERVER_HOST_EU=xxx.xxx.xxx.xxx
SERVER_HOST_US=x.xxx.xxx.xxx
SSH_KEY_STAGING=~/.ssh/your-staging-key
SSH_KEY_PROD=~/.ssh/your-prod-key
# ECR (Elastic Container Registry) # Docker Configuration
ECR_REPO_NAME=your-repo-name DOCKER_USERNAME=username
DOCKER_REPO_PROD=your-prod-repo
DOCKER_REPO_STAGING=your-staging-repo
DOCKER_TOKEN=your_docker_token
# EC2 Deployment Hosts # Admin credentials
EC2_HOST_STAGING=ec2-user@your-staging-ip ADMIN_TOKEN=your_admin_token
EC2_HOST_PROD=ec2-user@your-production-ip R2_ACCESS_KEY=your_r2_access_key
EC2_KEY=~/.ssh/your-key-file.pem R2_SECRET_KEY=your_r2_secret_key
R2_ACCOUNT_ID=your_r2_account_id
# Application Secrets R2_PROD_BUCKET=your-prod-bucket
ADMIN_TOKEN=your-admin-token R2_STAGING_BUCKET=your-staging-bucket
+4 -2
View File
@@ -1,5 +1,5 @@
ownerdomain=openfront.io ownerdomain=openfront.io
managerdomain=venatus.com managerdomain=adinplay.com
#V 01.04.2025 VH #V 01.04.2025 VH
#V #V
@@ -994,4 +994,6 @@ smartadserver.com, 3490, DIRECT
################################## ##################################
# AdinPlay.com ads.txt - 2025-04-16 # AdinPlay.com ads.txt - 2025-04-16
################################## ##################################
venatus.com, OFI, DIRECT
+2 -1
View File
@@ -120,7 +120,8 @@
"pangaea": "Pangaea", "pangaea": "Pangaea",
"japan": "Japan and Neighbors", "japan": "Japan and Neighbors",
"betweentwoseas": "Between Two Seas", "betweentwoseas": "Between Two Seas",
"knownworld": "Known World" "knownworld": "Known World",
"faroeislands": "Faroe Islands"
}, },
"private_lobby": { "private_lobby": {
"title": "Join Private Lobby", "title": "Join Private Lobby",
File diff suppressed because one or more lines are too long
+43
View File
@@ -0,0 +1,43 @@
{
"name": "Faroe Islands",
"width": 1600,
"height": 2000,
"nations": [
{
"coordinates": [920, 1780],
"name": "Suduroy Region",
"strength": 2,
"flag": "fo"
},
{
"coordinates": [880, 1070],
"name": "Sandoy Region",
"strength": 2,
"flag": "fo"
},
{
"coordinates": [480, 630],
"name": "Vagar Region",
"strength": 1,
"flag": "fo"
},
{
"coordinates": [735, 580],
"name": "Streymoy Region",
"strength": 2,
"flag": "fo"
},
{
"coordinates": [815, 375],
"name": "Eysturoy Region",
"strength": 2,
"flag": "fo"
},
{
"coordinates": [1115, 265],
"name": "Nordoyar Region",
"strength": 2,
"flag": "fo"
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 663 KiB

File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

+68 -25
View File
@@ -1,37 +1,80 @@
#!/bin/bash #!/bin/bash
# Comprehensive setup script for Hetzner server with Docker and Cloudflare R2 configuration # Comprehensive setup script for Hetzner server with Docker and user setup
# Exit on error # Exit on error
set -e set -e
echo "====================================================="
echo "🚀 STARTING SERVER SETUP"
echo "====================================================="
echo "🔄 Updating system..." echo "🔄 Updating system..."
apt update && apt upgrade -y apt update && apt upgrade -y
echo "🐳 Installing Docker..." # Check if Docker is already installed
# Install Docker using official script if command -v docker &> /dev/null; then
curl -fsSL https://get.docker.com -o get-docker.sh echo "Docker is already installed"
sh get-docker.sh else
systemctl enable --now docker echo "🐳 Installing Docker..."
# Install Docker using official script
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
systemctl enable --now docker
echo "Docker installed successfully"
fi
# Set up Docker Hub credentials echo "👤 Setting up openfront user..."
echo "🔐 Setting up Docker Hub login..." # Create openfront user if it doesn't exist
echo "Enter your Docker Hub username:" if id "openfront" &>/dev/null; then
read DOCKER_USERNAME echo "User openfront already exists"
echo "Enter your Docker Hub password/token:" else
read -s DOCKER_PASSWORD useradd -m -s /bin/bash openfront
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin echo "User openfront created"
echo "✅ Docker Hub login configured" fi
echo "🔄 Installing Node Exporter..." # Check if openfront is already in docker group
if groups openfront | grep -q '\bdocker\b'; then
echo "User openfront is already in the docker group"
else
# Add openfront to docker group
usermod -aG docker openfront
echo "Added openfront to docker group"
fi
docker run -d --name node-exporter --restart=unless-stopped \ # Create .ssh directory for openfront if it doesn't exist
--net="host" \ if [ ! -d "/home/openfront/.ssh" ]; then
--pid="host" \ mkdir -p /home/openfront/.ssh
-v "/:/host:ro,rslave" \ chmod 700 /home/openfront/.ssh
prom/node-exporter:latest \ echo "Created .ssh directory for openfront"
--path.rootfs=/host fi
echo "node-exporter installed" # Copy SSH keys from root if they exist and haven't been copied yet
if [ -f /root/.ssh/authorized_keys ] && [ ! -f /home/openfront/.ssh/authorized_keys ]; then
cp /root/.ssh/authorized_keys /home/openfront/.ssh/
chmod 600 /home/openfront/.ssh/authorized_keys
echo "SSH keys copied from root to openfront"
fi
echo "🎉 Setup complete! You can find helpful Docker and R2 commands in ~/docker-commands.sh" # Check if node-exporter container already exists
echo "Test your R2 connection: aws s3 ls --profile r2" if docker ps -a | grep -q "node-exporter"; then
echo "Node Exporter is already installed"
else
echo "🔄 Installing Node Exporter..."
docker run -d --name node-exporter --restart=unless-stopped \
--net="host" \
--pid="host" \
-v "/:/host:ro,rslave" \
prom/node-exporter:latest \
--path.rootfs=/host
echo "Node Exporter installed successfully"
fi
# Set proper ownership for openfront's home directory
chown -R openfront:openfront /home/openfront
echo "Set proper ownership for openfront's home directory"
echo "====================================================="
echo "🎉 SETUP COMPLETE!"
echo "====================================================="
echo "The openfront user has been set up and has Docker permissions."
echo "You can now deploy using the openfront user."
echo "====================================================="
+26
View File
@@ -12,6 +12,7 @@ import { createGameRecord } from "../core/Util";
import { ServerConfig } from "../core/configuration/Config"; import { ServerConfig } from "../core/configuration/Config";
import { getConfig } from "../core/configuration/ConfigLoader"; import { getConfig } from "../core/configuration/ConfigLoader";
import { Team, UnitType } from "../core/game/Game"; import { Team, UnitType } from "../core/game/Game";
import { TileRef } from "../core/game/GameMap";
import { import {
ErrorUpdate, ErrorUpdate,
GameUpdateType, GameUpdateType,
@@ -28,6 +29,7 @@ import { endGame, startGame, startTime } from "./LocalPersistantStats";
import { getPersistentIDFromCookie } from "./Main"; import { getPersistentIDFromCookie } from "./Main";
import { import {
SendAttackIntentEvent, SendAttackIntentEvent,
SendBoatAttackIntentEvent,
SendHashEvent, SendHashEvent,
SendSpawnIntentEvent, SendSpawnIntentEvent,
Transport, Transport,
@@ -359,6 +361,18 @@ export class ClientGameRunner {
this.myPlayer.troops() * this.renderer.uiState.attackRatio, this.myPlayer.troops() * this.renderer.uiState.attackRatio,
), ),
); );
} else if (
actions.canBoat !== false &&
this.shouldBoat(tile, actions.canBoat) &&
this.gameView.isLand(tile)
) {
this.eventBus.emit(
new SendBoatAttackIntentEvent(
this.gameView.owner(tile).id(),
cell,
this.myPlayer.troops() * this.renderer.uiState.attackRatio,
),
);
} }
const owner = this.gameView.owner(tile); const owner = this.gameView.owner(tile);
@@ -370,6 +384,18 @@ export class ClientGameRunner {
}); });
} }
private shouldBoat(tile: TileRef, src: TileRef) {
// TODO: Global enable flag
// TODO: Global limit autoboat to nearby shore flag
// if (!enableAutoBoat) return false;
// if (!limitAutoBoatNear) return true;
const distanceSquared = this.gameView.euclideanDistSquared(tile, src);
const limit = 100;
const limitSquared = limit * limit;
if (distanceSquared > limitSquared) return false;
return true;
}
private onMouseMove(event: MouseMoveEvent) { private onMouseMove(event: MouseMoveEvent) {
this.lastMousePosition = { x: event.x, y: event.y }; this.lastMousePosition = { x: event.x, y: event.y };
this.checkTileUnderCursor(); this.checkTileUnderCursor();
+1
View File
@@ -23,6 +23,7 @@ export const MapDescription: Record<keyof typeof GameMapType, string> = {
Japan: "Japan", Japan: "Japan",
BetweenTwoSeas: "Between Two Seas", BetweenTwoSeas: "Between Two Seas",
KnownWorld: "Known World", KnownWorld: "Known World",
FaroeIslands: "Faroe Islands",
}; };
@customElement("map-display") @customElement("map-display")
+8 -2
View File
@@ -145,8 +145,14 @@ export class PlayerPanel extends LitElement implements Layer {
this.eventBus.on(MouseUpEvent, (e: MouseEvent) => this.hide()); this.eventBus.on(MouseUpEvent, (e: MouseEvent) => this.hide());
} }
tick() { async tick() {
this.requestUpdate(); if (this.isVisible && this.tile) {
const myPlayer = this.g.myPlayer();
if (myPlayer !== null && myPlayer.isAlive()) {
this.actions = await myPlayer.actions(this.tile);
this.requestUpdate();
}
}
} }
getTotalNukesSent(otherId: PlayerID): number { getTotalNukesSent(otherId: PlayerID): number {
+34 -14
View File
@@ -8,7 +8,7 @@ import swordIcon from "../../../../resources/images/SwordIconWhite.svg";
import traitorIcon from "../../../../resources/images/TraitorIconWhite.svg"; import traitorIcon from "../../../../resources/images/TraitorIconWhite.svg";
import { consolex } from "../../../core/Consolex"; import { consolex } from "../../../core/Consolex";
import { EventBus } from "../../../core/EventBus"; import { EventBus } from "../../../core/EventBus";
import { Cell, PlayerActions } from "../../../core/game/Game"; import { Cell, PlayerActions, TerraNullius } from "../../../core/game/Game";
import { TileRef } from "../../../core/game/GameMap"; import { TileRef } from "../../../core/game/GameMap";
import { GameView, PlayerView } from "../../../core/game/GameView"; import { GameView, PlayerView } from "../../../core/game/GameView";
import { ClientID } from "../../../core/Schemas"; import { ClientID } from "../../../core/Schemas";
@@ -44,6 +44,7 @@ export class RadialMenu implements Layer {
private clickedCell: Cell | null = null; private clickedCell: Cell | null = null;
private lastClosed: number = 0; private lastClosed: number = 0;
private originalTileOwner: PlayerView | TerraNullius;
private menuElement: d3.Selection<HTMLDivElement, unknown, null, undefined>; private menuElement: d3.Selection<HTMLDivElement, unknown, null, undefined>;
private isVisible: boolean = false; private isVisible: boolean = false;
private readonly menuItems = new Map([ private readonly menuItems = new Map([
@@ -267,8 +268,26 @@ export class RadialMenu implements Layer {
.style("pointer-events", "none"); .style("pointer-events", "none");
} }
tick() { async tick() {
// Update logic if needed // Only update when menu is visible
if (!this.isVisible || this.clickedCell === null) return;
const myPlayer = this.g.myPlayer();
if (myPlayer === null || !myPlayer.isAlive()) return;
const tile = this.g.ref(this.clickedCell.x, this.clickedCell.y);
if (this.originalTileOwner.isPlayer()) {
if (this.g.owner(tile) != this.originalTileOwner) {
this.closeMenu();
return;
}
} else {
if (this.g.owner(tile).isPlayer() || this.g.owner(tile) == myPlayer) {
this.closeMenu();
return;
}
}
const actions = await myPlayer.actions(tile);
this.disableAllButtons();
this.handlePlayerActions(myPlayer, actions, tile);
} }
renderLayer(context: CanvasRenderingContext2D) { renderLayer(context: CanvasRenderingContext2D) {
@@ -291,12 +310,7 @@ export class RadialMenu implements Layer {
} else { } else {
this.showRadialMenu(event.x, event.y); this.showRadialMenu(event.x, event.y);
} }
this.enableCenterButton(false); this.disableAllButtons();
for (const item of this.menuItems.values()) {
item.disabled = true;
this.updateMenuItemState(item);
}
this.clickedCell = this.transformHandler.screenToWorldCoordinates( this.clickedCell = this.transformHandler.screenToWorldCoordinates(
event.x, event.x,
event.y, event.y,
@@ -305,7 +319,7 @@ export class RadialMenu implements Layer {
return; return;
} }
const tile = this.g.ref(this.clickedCell.x, this.clickedCell.y); const tile = this.g.ref(this.clickedCell.x, this.clickedCell.y);
this.originalTileOwner = this.g.owner(tile);
if (this.g.inSpawnPhase()) { if (this.g.inSpawnPhase()) {
if (this.g.isLand(tile) && !this.g.hasOwner(tile)) { if (this.g.isLand(tile) && !this.g.hasOwner(tile)) {
this.enableCenterButton(true); this.enableCenterButton(true);
@@ -313,10 +327,8 @@ export class RadialMenu implements Layer {
return; return;
} }
const myPlayer = this.g const myPlayer = this.g.myPlayer();
.playerViews() if (myPlayer === null) {
.find((p) => p.clientID() == this.clientID);
if (!myPlayer) {
consolex.warn("my player not found"); consolex.warn("my player not found");
return; return;
} }
@@ -430,6 +442,14 @@ export class RadialMenu implements Layer {
this.hideRadialMenu(); this.hideRadialMenu();
} }
private disableAllButtons() {
this.enableCenterButton(false);
for (const item of this.menuItems.values()) {
item.disabled = true;
this.updateMenuItemState(item);
}
}
private activateMenuElement( private activateMenuElement(
slot: Slot, slot: Slot,
color: string, color: string,
+3
View File
@@ -5,6 +5,7 @@ import betweenTwoSeas from "../../../resources/maps/BetweenTwoSeasThumb.webp";
import blackSea from "../../../resources/maps/BlackSeaThumb.webp"; import blackSea from "../../../resources/maps/BlackSeaThumb.webp";
import britannia from "../../../resources/maps/BritanniaThumb.webp"; import britannia from "../../../resources/maps/BritanniaThumb.webp";
import europe from "../../../resources/maps/EuropeThumb.webp"; import europe from "../../../resources/maps/EuropeThumb.webp";
import faroeislands from "../../../resources/maps/FaroeIslandsThumb.webp";
import gatewayToTheAtlantic from "../../../resources/maps/GatewayToTheAtlanticThumb.webp"; import gatewayToTheAtlantic from "../../../resources/maps/GatewayToTheAtlanticThumb.webp";
import iceland from "../../../resources/maps/IcelandThumb.webp"; import iceland from "../../../resources/maps/IcelandThumb.webp";
import japan from "../../../resources/maps/JapanThumb.webp"; import japan from "../../../resources/maps/JapanThumb.webp";
@@ -57,6 +58,8 @@ export function getMapsImage(map: GameMapType): string {
return betweenTwoSeas; return betweenTwoSeas;
case GameMapType.KnownWorld: case GameMapType.KnownWorld:
return knownworld; return knownworld;
case GameMapType.FaroeIslands:
return faroeislands;
default: default:
return ""; return "";
} }
+2 -1
View File
@@ -34,7 +34,7 @@ export abstract class DefaultServerConfig implements ServerConfig {
return process.env.GIT_COMMIT; return process.env.GIT_COMMIT;
} }
r2Endpoint(): string { r2Endpoint(): string {
return process.env.R2_ENDPOINT; return `https://${process.env.R2_ACCOUNT_ID}.r2.cloudflarestorage.com`;
} }
r2AccessKey(): string { r2AccessKey(): string {
return process.env.R2_ACCESS_KEY; return process.env.R2_ACCESS_KEY;
@@ -89,6 +89,7 @@ export abstract class DefaultServerConfig implements ServerConfig {
GameMapType.Mars, GameMapType.Mars,
GameMapType.Oceania, GameMapType.Oceania,
GameMapType.Japan, // Japan at this level because its 2/3 water GameMapType.Japan, // Japan at this level because its 2/3 water
GameMapType.FaroeIslands,
].includes(map) ].includes(map)
) { ) {
return Math.random() < 0.2 ? 70 : 40; return Math.random() < 0.2 ? 70 : 40;
+3 -2
View File
@@ -67,6 +67,7 @@ export enum GameMapType {
Japan = "Japan", Japan = "Japan",
BetweenTwoSeas = "Between Two Seas", BetweenTwoSeas = "Between Two Seas",
KnownWorld = "Known World", KnownWorld = "Known World",
FaroeIslands = "FaroeIslands",
} }
export enum GameType { export enum GameType {
@@ -416,7 +417,7 @@ export interface Player {
// Misc // Misc
toUpdate(): PlayerUpdate; toUpdate(): PlayerUpdate;
playerProfile(): PlayerProfile; playerProfile(): PlayerProfile;
canBoat(tile: TileRef): boolean; canBoat(tile: TileRef): TileRef | false;
tradingPorts(port: Unit): Unit[]; tradingPorts(port: Unit): Unit[];
} }
@@ -474,7 +475,7 @@ export interface Game extends GameMap {
} }
export interface PlayerActions { export interface PlayerActions {
canBoat: boolean; canBoat: TileRef | false;
canAttack: boolean; canAttack: boolean;
buildableUnits: BuildableUnit[]; buildableUnits: BuildableUnit[];
canSendEmojiAllPlayers: boolean; canSendEmojiAllPlayers: boolean;
+13 -5
View File
@@ -22,6 +22,7 @@ import {
Attack, Attack,
Cell, Cell,
EmojiMessage, EmojiMessage,
GameMode,
Gold, Gold,
MessageType, MessageType,
MutableAlliance, MutableAlliance,
@@ -518,6 +519,13 @@ export class PlayerImpl implements Player {
} }
canDonate(recipient: Player): boolean { canDonate(recipient: Player): boolean {
if (
recipient.type() == PlayerType.Human &&
this.mg.config().gameConfig().gameMode == GameMode.FFA
) {
return false;
}
if (!this.isFriendly(recipient)) { if (!this.isFriendly(recipient)) {
return false; return false;
} }
@@ -543,7 +551,7 @@ export class PlayerImpl implements Player {
this.id(), this.id(),
); );
this.mg.displayMessage( this.mg.displayMessage(
`Recieved ${renderTroops(troops)} troops from ${this.name()}`, `Received ${renderTroops(troops)} troops from ${this.name()}`,
MessageType.SUCCESS, MessageType.SUCCESS,
recipient.id(), recipient.id(),
); );
@@ -557,7 +565,7 @@ export class PlayerImpl implements Player {
this.id(), this.id(),
); );
this.mg.displayMessage( this.mg.displayMessage(
`Recieved ${renderNumber(gold)} gold from ${this.name()}`, `Received ${renderNumber(gold)} gold from ${this.name()}`,
MessageType.SUCCESS, MessageType.SUCCESS,
recipient.id(), recipient.id(),
); );
@@ -886,7 +894,7 @@ export class PlayerImpl implements Player {
return rel; return rel;
} }
public canBoat(tile: TileRef): boolean { public canBoat(tile: TileRef): TileRef | false {
if ( if (
this.units(UnitType.TransportShip).length >= this.units(UnitType.TransportShip).length >=
this.mg.config().boatMaxNumber() this.mg.config().boatMaxNumber()
@@ -929,7 +937,7 @@ export class PlayerImpl implements Player {
} }
if (myPlayerBordersOcean && otherPlayerBordersOcean) { if (myPlayerBordersOcean && otherPlayerBordersOcean) {
return this.canBuild(UnitType.TransportShip, dst) != false; return this.canBuild(UnitType.TransportShip, dst);
} else { } else {
return false; return false;
} }
@@ -952,7 +960,7 @@ export class PlayerImpl implements Player {
for (const t of sorted) { for (const t of sorted) {
if (this.mg.owner(t) == this) { if (this.mg.owner(t) == this) {
return this.canBuild(UnitType.TransportShip, dst) != false; return this.canBuild(UnitType.TransportShip, dst);
} }
} }
return false; return false;
+1
View File
@@ -41,6 +41,7 @@ const MAP_FILE_NAMES: Record<GameMapType, string> = {
[GameMapType.Japan]: "Japan", [GameMapType.Japan]: "Japan",
[GameMapType.BetweenTwoSeas]: "BetweenTwoSeas", [GameMapType.BetweenTwoSeas]: "BetweenTwoSeas",
[GameMapType.KnownWorld]: "KnownWorld", [GameMapType.KnownWorld]: "KnownWorld",
[GameMapType.FaroeIslands]: "FaroeIslands",
}; };
class GameMapLoader { class GameMapLoader {
+1
View File
@@ -22,6 +22,7 @@ const maps = [
"BetweenTwoSeas", "BetweenTwoSeas",
"Japan", "Japan",
"KnownWorld", "KnownWorld",
"FaroeIslands",
]; ];
const removeSmall = true; const removeSmall = true;
+1
View File
@@ -101,6 +101,7 @@ export class MapPlaylist {
BetweenTwoSeas: 3, BetweenTwoSeas: 3,
Japan: 3, Japan: 3,
BlackSea: 1, BlackSea: 1,
FaroeIslands: 2,
}; };
} }
} }
+5 -3
View File
@@ -26,11 +26,13 @@ echo "Container name: ${CONTAINER_NAME}"
echo "Docker image: ${FULL_IMAGE_NAME}" echo "Docker image: ${FULL_IMAGE_NAME}"
# Load environment variables if .env exists # Load environment variables if .env exists
if [ -f /root/.env ]; then if [ -f /home/openfront/.env ]; then
echo "Loading environment variables from .env file..." echo "Loading environment variables from .env file..."
export $(grep -v '^#' /root/.env | xargs) export $(grep -v '^#' /home/openfront/.env | xargs)
fi fi
docker login -u $DOCKER_USERNAME -p $DOCKER_TOKEN
# Install Loki Docker plugin if not already installed # Install Loki Docker plugin if not already installed
if ! docker plugin ls | grep -q "loki"; then if ! docker plugin ls | grep -q "loki"; then
echo "Installing Loki Docker plugin..." echo "Installing Loki Docker plugin..."
@@ -99,7 +101,7 @@ docker run -d -p 80:80 -p 127.0.0.1:9090:9090 \
--log-opt loki-external-labels="job=docker,environment=${ENV},host=${REGION},region=${REGION}" \ --log-opt loki-external-labels="job=docker,environment=${ENV},host=${REGION},region=${REGION}" \
--env GAME_ENV=${ENV} \ --env GAME_ENV=${ENV} \
--env REGION=${REGION} \ --env REGION=${REGION} \
--env-file /root/.env \ --env-file /home/openfront/.env \
--name ${CONTAINER_NAME} \ --name ${CONTAINER_NAME} \
$FULL_IMAGE_NAME $FULL_IMAGE_NAME