* fix build

* glcanvas is already present

* screen size

* minimize

* add test

* screen size

* cleanup

* use primitives directly

* avoid option in actions because mongo strips null values

* cleanup

* cleanup

* cleanup

* cleanup
This commit is contained in:
Gregor Zeitlinger 2024-12-29 14:20:37 +01:00 • committed by GitHub
commit 0a398584c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
69 changed files with 1581 additions and 310 deletions

View file

@ -19,7 +19,7 @@
- `cd server`
- `cargo install wasm-pack` (if you haven't already)
- `./build-wasm.sh`
- `./build-remote-server.sh`
# Notes

2
client/Cargo.lock generated
View file

@ -202,6 +202,7 @@ dependencies = [
"console_error_panic_hook",
"hex2d",
"itertools",
"js-sys",
"lazy_static",
"log",
"macroquad",
@ -210,6 +211,7 @@ dependencies = [
"server",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
]
[[package]]

View file

@ -27,6 +27,8 @@ log = "0.4.20"
async-std = "1.13.0"
serde-wasm-bindgen = "0.6.5"
console_error_panic_hook = "0.1.7"
web-sys = { version = "0.3.72", features = ["Window"] }
js-sys = "0.3.72"
[[bin]]
name = "local_client"

View file

@ -44,6 +44,10 @@ export class Control extends EventEmitter {
this.emit("ready");
}
get canvas_size() {
return document.getElementById("glcanvas").getBoundingClientRect();
}
get assets_url() {
return this._assets_url;
}
@ -53,9 +57,6 @@ export class Control extends EventEmitter {
}
}
export function get_control() {
return window.clash_control;
}

View file

@ -9,32 +9,24 @@ function dynamicallyLoadScript(url, onload) {
}
export async function run({selector, control}) {
const root = document.querySelector(selector);
const canvas = document.createElement("canvas");
canvas.setAttribute("id", "glcanvas");
canvas.setAttribute("style", `
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
z-index: 0;
`);
root.appendChild(canvas);
dynamicallyLoadScript("https://not-fl3.github.io/miniquad-samples/mq_js_bundle.js", async () => {
let wbg = await init();
miniquad_add_plugin({
register_plugin: (a) => (a.wbg = wbg),
on_init: () => set_wasm(wasm_exports),
version: "0.0.1",
name: "wbg",
});
const src = document.head.getElementsByTagName("script")[0].src;
control.assets_url = src.replace("client.js", "assets/");
const url = src.replace("client.js", "client.wasm");
console.log("Loading wasm from", url);
await load(url);
});
miniquad_add_plugin({
register_plugin: (a) => {
console.log("register_plugin", a);
return (a.wbg = wbg)
},
on_init: () => {
console.log("on_init", wasm_exports);
window.clash_control.send_ready()
return set_wasm(wasm_exports)
},
version: "0.0.1",
name: "wbg",
});
const src = document.body.getElementsByTagName("script")[1].src;
control.assets_url = src.replace("client.js", "assets/");
const url = src.replace("client.js", "client.wasm");
console.log("Loading wasm from", url);
await load(url);
console.log("Loaded wasm");
}

View file

@ -6,7 +6,7 @@ module.exports = {
}, resolve: {
fallback: {"events": require.resolve("events/")}
}, optimization: {
minimize: false
minimize: true
},
};

View file

@ -21,7 +21,9 @@ use crate::status_phase_ui::raze_city_confirm_dialog;
use crate::{combat_ui, dialog_ui, influence_ui, move_ui, recruit_unit_ui, status_phase_ui};
pub async fn init(features: &Features) -> State {
State::new(features).await
let state = State::new(features).await;
root_ui().push_skin(&state.assets.skin);
state
}
pub fn render_and_update(
@ -45,13 +47,14 @@ pub fn render_and_update(
}
fn render(game: &Game, state: &mut State, features: &Features) -> StateUpdate {
root_ui().push_skin(&state.assets.skin);
clear_background(BLACK);
let player = &state.shown_player(game);
let s = state.screen_size;
state.camera = Camera2D {
zoom: vec2(state.zoom, state.zoom * screen_width() / screen_height()),
zoom: vec2(state.zoom, state.zoom * s.x / s.y),
offset: state.offset,
..Default::default()
};

View file

@ -221,6 +221,7 @@ pub struct ShownPlayer {
pub can_play_action: bool,
pub active_dialog: ActiveDialog,
pub pending_update: bool,
pub screen_size: Vec2,
}
impl ShownPlayer {
@ -239,6 +240,7 @@ pub struct State {
pub camera: Camera2D,
pub zoom: f32,
pub offset: Vec2,
pub screen_size: Vec2,
}
pub const ZOOM: f32 = 0.001;
@ -257,6 +259,7 @@ impl State {
},
zoom: ZOOM,
offset: OFFSET,
screen_size: vec2(0., 0.),
}
}
@ -270,6 +273,7 @@ impl State {
can_play_action: control && game.state == GameState::Playing && game.actions_left > 0,
active_dialog: self.active_dialog.clone(),
pending_update: self.pending_update.is_some(),
screen_size: self.screen_size,
}
}
@ -374,7 +378,7 @@ impl State {
GameState::StatusPhase(state) => match state {
StatusPhaseState::CompleteObjectives => ActiveDialog::CompleteObjectives,
StatusPhaseState::FreeAdvance => ActiveDialog::FreeAdvance,
StatusPhaseState::RaseSize1City => ActiveDialog::RazeSize1City,
StatusPhaseState::RazeSize1City => ActiveDialog::RazeSize1City,
StatusPhaseState::ChangeGovernmentType => ActiveDialog::ChangeGovernmentType,
StatusPhaseState::DetermineFirstPlayer => ActiveDialog::DetermineFirstPlayer,
},

View file

@ -1,4 +1,4 @@
use server::action::{Action, CombatAction};
use server::action::{Action, CombatAction, PlayActionCard};
use server::game::Game;
use server::position::Position;
use server::unit::Unit;
@ -105,7 +105,9 @@ pub fn remove_casualties_dialog(
pub fn play_action_card_dialog(player: &ShownPlayer) -> StateUpdate {
active_dialog_window(player, "Play action card", |ui| {
if ui.button(None, "None") {
return StateUpdate::Execute(Action::Combat(CombatAction::PlayActionCard(None)));
return StateUpdate::Execute(Action::Combat(CombatAction::PlayActionCard(
PlayActionCard::None,
)));
}
StateUpdate::None
})

View file

@ -10,7 +10,7 @@ use server::city_pieces::Building;
use server::content::custom_actions::CustomAction;
use server::game::Game;
use server::map::{Map, Terrain};
use server::playing_actions::PlayingAction;
use server::playing_actions::{Construct, PlayingAction};
use server::position::Position;
use server::resource_pile::PaymentOptions;
use server::unit::UnitType;
@ -106,13 +106,13 @@ pub fn pay_construction_dialog(
|cp| cp.payment.get(ResourceType::Discount).selectable.current == 0,
|cp| match &cp.project {
ConstructionProject::Building(b, pos) => StateUpdate::execute_activation(
Action::Playing(PlayingAction::Construct {
Action::Playing(PlayingAction::Construct(Construct {
city_position: cp.city_position,
city_piece: b.clone(),
payment: cp.payment.to_resource_pile(),
port_position: *pos,
temple_bonus: None,
}),
})),
vec![],
game.get_any_city(cp.city_position).unwrap(),
),

View file

@ -2,10 +2,8 @@ use crate::client_state::{PendingUpdate, ShownPlayer, StateUpdate};
use crate::layout_ui::{cancel_pos, ok_only_pos, ok_pos};
use macroquad::hash;
use macroquad::math::{vec2, Vec2};
use macroquad::prelude::screen_height;
use macroquad::ui::widgets::Window;
use macroquad::ui::{root_ui, Ui};
use macroquad::window::screen_width;
pub fn active_dialog_window<F>(player: &ShownPlayer, title: &str, f: F) -> StateUpdate
where
@ -24,11 +22,12 @@ pub fn dialog<F>(player: &ShownPlayer, title: &str, f: F) -> StateUpdate
where
F: FnOnce(&mut Ui) -> StateUpdate,
{
let width = screen_width() - 20.;
let size = player.screen_size;
let width = size.x - 20.;
let size = if player.active_dialog.is_map_dialog() {
vec2(width / 2.0, 270.)
} else {
vec2(width, screen_height() - 40.)
vec2(width, size.y - 40.)
};
custom_dialog(title, vec2(10., 10.), size, f)
}

View file

@ -1,49 +1,58 @@
use crate::client_state::ShownPlayer;
use macroquad::math::{vec2, Vec2};
use macroquad::prelude::screen_height;
use macroquad::ui::root_ui;
use macroquad::window::screen_width;
pub fn top_left_label(p: Vec2, label: &str) {
root_ui().label(p, label);
}
pub fn top_center_label(p: Vec2, label: &str) {
root_ui().label(vec2(screen_width() / 2.0, 0.) + p, label);
pub fn top_center_label(player: &ShownPlayer, p: Vec2, label: &str) {
root_ui().label(vec2(player.screen_size.x / 2.0, 0.) + p, label);
}
pub fn right_center_label(p: Vec2, label: &str) {
root_ui().label(vec2(screen_width(), screen_height() / 2.0) + p, label);
pub fn right_center_label(player: &ShownPlayer, p: Vec2, label: &str) {
root_ui().label(
vec2(player.screen_size.x, player.screen_size.y / 2.0) + p,
label,
);
}
pub fn right_center_button(p: Vec2, label: &str) -> bool {
root_ui().button(vec2(screen_width(), screen_height() / 2.0) + p, label)
pub fn right_center_button(player: &ShownPlayer, p: Vec2, label: &str) -> bool {
root_ui().button(
vec2(player.screen_size.x, player.screen_size.y / 2.0) + p,
label,
)
}
pub fn bottom_left_button(p: Vec2, label: &str) -> bool {
root_ui().button(vec2(0., screen_height()) + p, label)
pub fn bottom_left_button(player: &ShownPlayer, p: Vec2, label: &str) -> bool {
root_ui().button(vec2(0., player.screen_size.y) + p, label)
}
pub fn bottom_right_button(p: Vec2, label: &str) -> bool {
root_ui().button(vec2(screen_width(), screen_height()) + p, label)
pub fn bottom_right_button(player: &ShownPlayer, p: Vec2, label: &str) -> bool {
root_ui().button(vec2(player.screen_size.x, player.screen_size.y) + p, label)
}
pub fn cancel_pos(player: &ShownPlayer) -> Vec2 {
small_dialog(player)
.then(|| Vec2::new(screen_width() / 4.0, 190.))
.unwrap_or_else(|| Vec2::new(screen_width() / 2., screen_height() - 130.))
.then(|| Vec2::new(player.screen_size.x / 4.0, 190.))
.unwrap_or_else(|| Vec2::new(player.screen_size.x / 2., player.screen_size.y - 130.))
}
pub fn ok_pos(player: &ShownPlayer) -> Vec2 {
small_dialog(player)
.then(|| Vec2::new(screen_width() / 4.0 - 150., 190.))
.unwrap_or_else(|| Vec2::new(screen_width() / 2. - 150., screen_height() - 130.))
.then(|| Vec2::new(player.screen_size.x / 4.0 - 150., 190.))
.unwrap_or_else(|| {
Vec2::new(
player.screen_size.x / 2. - 150.,
player.screen_size.y - 130.,
)
})
}
pub fn ok_only_pos(player: &ShownPlayer) -> Vec2 {
small_dialog(player)
.then(|| Vec2::new(screen_width() / 4.0 - 75., 190.))
.unwrap_or_else(|| Vec2::new(screen_width() / 2. - 75., screen_height() - 130.))
.then(|| Vec2::new(player.screen_size.x / 4.0 - 75., 190.))
.unwrap_or_else(|| Vec2::new(player.screen_size.x / 2. - 75., player.screen_size.y - 130.))
}
fn small_dialog(player: &ShownPlayer) -> bool {

View file

@ -2,7 +2,8 @@
use client::client::{init, render_and_update, Features, GameSyncRequest, GameSyncResult};
use macroquad::miniquad::window::set_window_size;
use macroquad::prelude::next_frame;
use macroquad::prelude::{next_frame, screen_width, vec2};
use macroquad::window::screen_height;
use server::city::City;
use server::game::{Game, GameData};
use server::leader::Leader;
@ -39,6 +40,7 @@ pub async fn run(mut game: Game, features: &Features) {
state.show_player = game.active_player();
loop {
state.control_player = Some(game.active_player());
state.screen_size = vec2(screen_width(), screen_height());
let message = render_and_update(&game, &mut state, &sync_result, features);
sync_result = GameSyncResult::None;

View file

@ -36,8 +36,8 @@ pub fn show_globals(game: &Game, player: &ShownPlayer) -> StateUpdate {
let x = -200.;
let label = format!("{prefix}{name}");
if shown {
right_center_label(vec2(x, y), &label);
} else if right_center_button(vec2(x, y), &label) {
right_center_label(player, vec2(x, y), &label);
} else if right_center_button(player, vec2(x, y), &label) {
return StateUpdate::SetShownPlayer(p.index);
}
y += 40.;
@ -49,17 +49,38 @@ pub fn show_globals(game: &Game, player: &ShownPlayer) -> StateUpdate {
fn show_top_center(game: &Game, player: &ShownPlayer) {
let p = game.get_player(player.index);
top_center_label(vec2(-400., 0.), &resource_ui(p, "Fd", |r| r.food));
top_center_label(vec2(-320., 0.), &resource_ui(p, "Wd", |r| r.wood));
top_center_label(vec2(-240., 0.), &resource_ui(p, "Ore", |r| r.ore));
top_center_label(vec2(-160., 0.), &resource_ui(p, "Id", |r| r.ideas));
top_center_label(vec2(-80., 0.), &resource_ui(p, "Gld", |r| r.gold as u32));
top_center_label(vec2(0., 0.), &resource_ui(p, "Md", |r| r.mood_tokens));
top_center_label(vec2(80., 0.), &resource_ui(p, "Cul", |r| r.culture_tokens));
top_center_label(vec2(170., 0.), &format!("Civ {}", p.civilization.name));
top_center_label(vec2(250., 0.), &format!("VP {}", p.victory_points()));
top_center_label(player, vec2(-400., 0.), &resource_ui(p, "Fd", |r| r.food));
top_center_label(player, vec2(-320., 0.), &resource_ui(p, "Wd", |r| r.wood));
top_center_label(player, vec2(-240., 0.), &resource_ui(p, "Ore", |r| r.ore));
top_center_label(player, vec2(-160., 0.), &resource_ui(p, "Id", |r| r.ideas));
top_center_label(
player,
vec2(-80., 0.),
&resource_ui(p, "Gld", |r| r.gold as u32),
);
top_center_label(
player,
vec2(0., 0.),
&resource_ui(p, "Md", |r| r.mood_tokens),
);
top_center_label(
player,
vec2(80., 0.),
&resource_ui(p, "Cul", |r| r.culture_tokens),
);
top_center_label(
player,
vec2(170., 0.),
&format!("Civ {}", p.civilization.name),
);
top_center_label(
player,
vec2(250., 0.),
&format!("VP {}", p.victory_points()),
);
top_center_label(
player,
vec2(300., 0.),
&format!(
"Ldr {}",
@ -162,47 +183,47 @@ fn resource_ui(player: &Player, name: &str, f: impl Fn(&ResourcePile) -> u32) ->
}
pub fn show_global_controls(game: &Game, state: &mut State, features: &Features) -> StateUpdate {
let player = state.shown_player(game);
let player = &state.shown_player(game);
if bottom_left_button(vec2(0., -50.), "+") {
if bottom_left_button(player, vec2(0., -50.), "+") {
state.zoom *= 1.1;
return StateUpdate::None;
}
if bottom_left_button(vec2(70., -50.), "-") {
if bottom_left_button(player, vec2(70., -50.), "-") {
state.zoom /= 1.1;
return StateUpdate::None;
}
if bottom_left_button(vec2(140., -50.), "0") {
if bottom_left_button(player, vec2(140., -50.), "0") {
state.zoom = ZOOM;
state.offset = OFFSET;
return StateUpdate::None;
}
if bottom_left_button(vec2(210., -80.), "") {
if bottom_left_button(player, vec2(210., -80.), "") {
state.offset += vec2(-0.1, 0.);
return StateUpdate::None;
}
if bottom_left_button(vec2(310., -80.), "") {
if bottom_left_button(player, vec2(310., -80.), "") {
state.offset += vec2(0.1, 0.);
return StateUpdate::None;
}
if bottom_left_button(vec2(260., -110.), "") {
if bottom_left_button(player, vec2(260., -110.), "") {
state.offset += vec2(0., 0.1);
return StateUpdate::None;
}
if bottom_left_button(vec2(260., -50.), "") {
if bottom_left_button(player, vec2(260., -50.), "") {
state.offset += vec2(0., -0.1);
return StateUpdate::None;
}
if game.can_undo() && bottom_right_button(vec2(-400., -50.), "Undo") {
if game.can_undo() && bottom_right_button(player, vec2(-400., -50.), "Undo") {
return StateUpdate::Execute(Action::Undo);
}
if game.can_redo() && bottom_right_button(vec2(-300., -50.), "Redo") {
if game.can_redo() && bottom_right_button(player, vec2(-300., -50.), "Redo") {
return StateUpdate::Execute(Action::Redo);
}
if player.can_control
&& matches!(game.state, GameState::Playing)
&& bottom_right_button(vec2(-180., -50.), "End Turn")
&& bottom_right_button(player, vec2(-180., -50.), "End Turn")
{
let left = game.actions_left;
return StateUpdate::execute_with_warning(
@ -215,31 +236,31 @@ pub fn show_global_controls(game: &Game, state: &mut State, features: &Features)
);
}
if player.can_play_action && bottom_left_button(vec2(0., -170.), "Move") {
if player.can_play_action && bottom_left_button(player, vec2(0., -170.), "Move") {
return StateUpdate::execute(Action::Playing(PlayingAction::MoveUnits));
}
if player.can_play_action && bottom_left_button(vec2(0., -140.), "Inc. Hap.") {
return start_increase_happiness(game, &player);
if player.can_play_action && bottom_left_button(player, vec2(0., -140.), "Inc. Hap.") {
return start_increase_happiness(game, player);
}
if bottom_left_button(vec2(0., -110.), "Advances") {
if bottom_left_button(player, vec2(0., -110.), "Advances") {
return StateUpdate::OpenDialog(ActiveDialog::AdvanceMenu);
};
if bottom_left_button(vec2(0., -80.), "Log") {
if bottom_left_button(player, vec2(0., -80.), "Log") {
return StateUpdate::OpenDialog(ActiveDialog::Log);
};
let d = state.game_state_dialog(game, &ActiveDialog::None);
if !matches!(d, ActiveDialog::None)
&& d.title() != state.active_dialog.title()
&& bottom_left_button(vec2(0., -200.), &format!("Back to {}", d.title()))
&& bottom_left_button(player, vec2(0., -200.), &format!("Back to {}", d.title()))
{
return StateUpdate::OpenDialog(d);
}
if features.import_export {
if bottom_right_button(vec2(-300., -100.), "Import") {
if bottom_right_button(player, vec2(-300., -100.), "Import") {
return StateUpdate::Import;
};
if bottom_right_button(vec2(-150., -100.), "Export") {
if bottom_right_button(player, vec2(-150., -100.), "Export") {
return StateUpdate::Export;
};
}

View file

@ -5,6 +5,7 @@ use macroquad::prelude::next_frame;
extern crate console_error_panic_hook;
use client::client::{init, render_and_update, Features, GameSyncRequest, GameSyncResult};
use client::client_state::State;
use macroquad::math::vec2;
use server::action::Action;
use std::panic;
use wasm_bindgen::prelude::*;
@ -15,12 +16,21 @@ extern "C" {
fn log(s: &str);
}
#[wasm_bindgen(module = "/js/src/control.js")]
#[wasm_bindgen]
extern "C" {
type Rect;
#[wasm_bindgen(method, getter)]
fn width(this: &Rect) -> f32;
#[wasm_bindgen(method, getter)]
fn height(this: &Rect) -> f32;
}
#[wasm_bindgen]
extern "C" {
type Control;
fn get_control() -> Control;
#[wasm_bindgen(method)]
fn receive_state(this: &Control) -> JsValue;
@ -35,6 +45,9 @@ extern "C" {
#[wasm_bindgen(method, getter)]
fn assets_url(this: &Control) -> String;
#[wasm_bindgen(method, getter)]
fn canvas_size(this: &Control) -> Rect;
}
enum SyncState {
@ -62,7 +75,11 @@ impl RemoteClient {
pub async fn start() {
log("starting client");
panic::set_hook(Box::new(console_error_panic_hook::hook));
let control = get_control();
let control = web_sys::window()
.unwrap()
.get("clash_control")
.unwrap()
.unchecked_into::<Control>();
let features = Features {
import_export: false,
assets_url: control.assets_url(),
@ -89,6 +106,9 @@ impl RemoteClient {
self.state.show_player = p as usize;
}
let s = self.control.canvas_size();
self.state.screen_size = vec2(s.width(), s.height());
let sync_result = self.update_state();
if let Some(game) = &self.game {

View file

@ -6,7 +6,9 @@ use server::action::Action;
use server::content::advances;
use server::game::Game;
use server::position::Position;
use server::status_phase::{ChangeGovernmentType, StatusPhaseAction};
use server::status_phase::{
ChangeGovernment, ChangeGovernmentType, RazeSize1City, StatusPhaseAction,
};
pub fn determine_first_player_dialog(game: &Game, player: &ShownPlayer) -> StateUpdate {
active_dialog_window(
@ -32,7 +34,9 @@ pub fn raze_city_confirm_dialog(game: &Game, player: &ShownPlayer, pos: Position
if player.get(game).can_raze_city(pos) {
StateUpdate::execute_with_confirm(
vec![format!("Raze {pos} to get 1 gold")],
Action::StatusPhase(StatusPhaseAction::RaseSize1City(Some(pos))),
Action::StatusPhase(StatusPhaseAction::RazeSize1City(RazeSize1City::Position(
pos,
))),
)
} else {
StateUpdate::None
@ -42,7 +46,9 @@ pub fn raze_city_confirm_dialog(game: &Game, player: &ShownPlayer, pos: Position
pub fn raze_city_dialog(player: &ShownPlayer) -> StateUpdate {
active_dialog_window(player, "Select a city to raze - or decline.", |ui| {
if ui.button(None, "Decline") {
return StateUpdate::status_phase(StatusPhaseAction::RaseSize1City(None));
return StateUpdate::status_phase(StatusPhaseAction::RazeSize1City(
RazeSize1City::None,
));
}
StateUpdate::None
})
@ -124,7 +130,9 @@ pub fn change_government_type_dialog(game: &Game, player: &ShownPlayer) -> State
}
if ui.button(None, "Decline") {
return StateUpdate::status_phase(StatusPhaseAction::ChangeGovernmentType(None));
return StateUpdate::status_phase(StatusPhaseAction::ChangeGovernmentType(
ChangeGovernmentType::KeepGovernment,
));
}
StateUpdate::None
})
@ -142,12 +150,12 @@ pub fn choose_additional_advances_dialog(
additional_advances,
|a| StateUpdate::SetDialog(ActiveDialog::ChooseAdditionalAdvances(a)),
|a| {
StateUpdate::status_phase(StatusPhaseAction::ChangeGovernmentType(Some(
ChangeGovernmentType {
StateUpdate::status_phase(StatusPhaseAction::ChangeGovernmentType(
ChangeGovernmentType::ChangeGovernment(ChangeGovernment {
new_government: a.government.clone(),
additional_advances: a.selected.clone(),
},
)))
}),
))
},
)
}

View file

@ -9,7 +9,7 @@ if [ -z "$VERSION" ]; then
fi
echo "Building server..."
./scripts/build-wasm-server.sh --release
./scripts/build-remote-server.sh --release
echo "Publishing server..."
pushd server

View file

@ -75,7 +75,14 @@ impl Action {
#[derive(Serialize, Deserialize, Clone)]
pub enum CombatAction {
PlayActionCard(Option<String>),
PlayActionCard(PlayActionCard),
RemoveCasualties(Vec<u32>),
Retreat(bool),
}
// Can't use Option<String> because of mongo stips null values
#[derive(Serialize, Deserialize, Clone)]
pub enum PlayActionCard {
None,
Card(String),
}

View file

@ -1,4 +1,4 @@
use crate::action::CombatAction;
use crate::action::{CombatAction, PlayActionCard};
use crate::game::GameState::Playing;
use crate::game::{Game, GameState};
use crate::map::Terrain::Water;
@ -130,7 +130,7 @@ pub fn execute_combat_action(game: &mut Game, action: CombatAction, mut c: Comba
game.lock_undo();
match action {
CombatAction::PlayActionCard(card) => {
assert!(card.is_none());
assert!(matches!(card, PlayActionCard::None));
//todo use card
combat_loop(game, c);
return;

View file

@ -78,7 +78,7 @@ impl CustomAction {
#[must_use]
pub fn format_log_item(&self, _game: &Game, player_name: &str) -> String {
match self {
CustomAction::ConstructWonder { city_position, wonder, payment } => format!("{player_name} payed {payment} to construct the {wonder} wonder in the city at {city_position}"),
CustomAction::ConstructWonder { city_position, wonder, payment } => format!("{player_name} paid {payment} to construct the {wonder} wonder in the city at {city_position}"),
}
}
}

View file

@ -1,9 +1,8 @@
#![allow(clippy::pedantic)]
use crate::{game::Game, game_api};
use serde::{Deserialize, Serialize};
use wasm_bindgen::prelude::*;
use crate::{game::Game, game_api};
extern crate console_error_panic_hook;
#[derive(Serialize, Deserialize)]
@ -22,25 +21,20 @@ fn from_game(game: Game) -> JsValue {
#[wasm_bindgen]
pub async fn init(
players: JsValue,
player_amount: usize,
_expansions: JsValue,
_options: JsValue,
seed: JsValue,
seed: String,
_creator: JsValue,
) -> JsValue {
let player_amount = players
.as_f64()
.expect("number of players should be a number") as usize;
let seed = seed.as_string().expect("seed should be a string");
let game = game_api::init(player_amount, seed);
from_game(game)
}
#[wasm_bindgen(js_name = move)]
pub fn execute_move(game: JsValue, move_data: JsValue, player: JsValue) -> JsValue {
pub fn execute_move(game: JsValue, move_data: JsValue, player_index: usize) -> JsValue {
let game = get_game(game);
let action = serde_wasm_bindgen::from_value(move_data).expect("move should be of type action");
let player_index = player.as_f64().expect("player index should be a number") as usize;
let game = game_api::execute_action(game, action, player_index);
from_game(game)
}
@ -59,9 +53,8 @@ pub fn scores(game: JsValue) -> JsValue {
}
#[wasm_bindgen(js_name = "dropPlayer")]
pub async fn drop_player(game: JsValue, player: JsValue) -> JsValue {
pub async fn drop_player(game: JsValue, player_index: usize) -> JsValue {
let game = get_game(game);
let player_index = player.as_f64().expect("player index should be a number") as usize;
let game = game_api::drop_player(game, player_index);
from_game(game)
}
@ -92,11 +85,8 @@ pub fn log_slice(game: JsValue, options: JsValue) -> JsValue {
}
#[wasm_bindgen(js_name = "setPlayerMetaData")]
pub fn set_player_meta_data(game: JsValue, player_index: JsValue, meta_data: JsValue) -> JsValue {
pub fn set_player_meta_data(game: JsValue, player_index: usize, meta_data: JsValue) -> JsValue {
let game = get_game(game);
let player_index = player_index
.as_f64()
.expect("player index should be a number") as usize;
let name = serde_wasm_bindgen::from_value::<PlayerMetaData>(meta_data)
.expect("meta data should be of type player meta data")
.name;
@ -129,9 +119,8 @@ pub fn factions(game: JsValue) -> JsValue {
}
#[wasm_bindgen(js_name = "stripSecret")]
pub fn strip_secret(game: JsValue, player: JsValue) -> JsValue {
pub fn strip_secret(game: JsValue, player_index: Option<usize>) -> JsValue {
let game = get_game(game);
let player_index = player.as_f64().map(|player_index| player_index as usize);
let game = game_api::strip_secret(game, player_index);
from_game(game)
}

View file

@ -3,6 +3,10 @@
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use crate::action::PlayActionCard;
use crate::player::Player;
use crate::playing_actions::Construct;
use crate::status_phase::{ChangeGovernmentType, RazeSize1City};
use crate::{
action::{Action, CombatAction},
game::Game,
@ -76,7 +80,7 @@ pub fn format_action_log_item(action: &Action, game: &Game) -> String {
Action::StatusPhase(action) => format_status_phase_action_log_item(action, game),
Action::Movement(action) => format_movement_action_log_item(action, game),
Action::CulturalInfluenceResolution(action) => format!("{} {}", game.players[game.active_player()].get_name(), match action {
true => format!("payed {} culture tokens to increased the dice roll and proceed with the cultural influence", game.dice_roll_log.last().expect("there should have been at least one dice roll before a cultural influence resolution action") / 2 + 1),
true => format!("paid {} culture tokens to increased the dice roll and proceed with the cultural influence", game.dice_roll_log.last().expect("there should have been at least one dice roll before a cultural influence resolution action") / 2 + 1),
false => String::from("declined to increase the dice roll"),
}),
Action::Combat(action) => format_combat_action_log_item(action, game),
@ -91,20 +95,11 @@ fn format_playing_action_log_item(action: &PlayingAction, game: &Game) -> String
let player = &game.players[game.active_player()];
let player_name = player.get_name();
match action {
PlayingAction::Advance { advance, payment } => format!("{player_name} payed {payment} to get the {advance} advance"),
PlayingAction::Advance { advance, payment } => format!("{player_name} paid {payment} to get the {advance} advance"),
PlayingAction::FoundCity { settler } => format!("{player_name} founded a city at {}", player.get_unit(*settler).expect("The player should have the settler").position),
PlayingAction::Construct { city_position, city_piece, payment, port_position, temple_bonus } => format!("{player_name} payed {payment} to construct a {city_piece:?} in the city at {city_position}{}{}{}", if let Some(port_position) = port_position {
let adjacent_water_tiles = city_position.neighbors().iter().filter(|neighbor| game.map.tiles.get(neighbor).is_some_and(|terrain| terrain == &Terrain::Water)).count();
if adjacent_water_tiles > 1 {
format!(" at the water tile {port_position}")
} else {
String::new()
}
} else { String::new() }, if player.get_city(*city_position).expect("there should be a city at the given position").is_activated() { format!(" making it {:?}", player.get_city(*city_position).expect("there should be a city at the given position").mood_state.clone() - 1) } else { String::new() }, if let Some(temple_bonus) = temple_bonus {
format!(" and chooses to get {temple_bonus}")
} else { String::new() }),
PlayingAction::Collect { city_position, collections } => format!("{player_name} collects {}{} in the city at {city_position}{}", utils::format_list(&collections.iter().map(|(_, collection)| collection.to_string()).collect::<Vec<String>>(), "nothing"), if collections.len() > 1 && collections.iter().permutations(2).unique().any(|permutation| permutation[0].1.has_common_resource(&permutation[1].1)) { format!(" for a total of {}", collections.iter().map(|(_, collection)| collection.clone()).sum::<ResourcePile>()) } else { String::new() }, if player.get_city(*city_position).expect("there should be a city at the given position").is_activated() { format!(" making it {:?}", player.get_city(*city_position).expect("there should be a city at the given position").mood_state.clone() - 1) } else { String::new() }),
PlayingAction::Recruit { units, city_position, payment, leader_index, replaced_units } => format!("{player_name} payed {payment} to recruit {}{} in the city at {city_position}{}{}", units.iter().cloned().collect::<Units>(), leader_index.map_or(String::new(), |leader_index| format!(" {} {} as his leader", if player.available_leaders.len() > 1 { "choosing" } else { "getting" }, &player.available_leaders[leader_index].name)), if player.get_city(*city_position).expect("there should be a city at the given position").is_activated() { format!(" making it {:?}", player.get_city(*city_position).expect("there should be a city at the given position").mood_state.clone() - 1) } else { String::new() }, format_args!("{}{}", match replaced_units.len() { 0 => "", 1 => " and replaces the unit at ", _ => " and replaces units at " }, utils::format_list(&replaced_units.iter().map(|unit_id| player.get_unit(*unit_id).expect("the player should have the replaced units").position.to_string()).unique().collect::<Vec<String>>(), ""))),
PlayingAction::Construct(c) => format_construct_log_item(game, player, &player_name, c),
PlayingAction::Collect { city_position, collections } => format_collect_log_item(player, &player_name, *city_position, collections),
PlayingAction::Recruit { units, city_position, payment, leader_index, replaced_units } => format!("{player_name} paid {payment} to recruit {}{} in the city at {city_position}{}{}", units.iter().cloned().collect::<Units>(), leader_index.map_or(String::new(), |leader_index| format!(" {} {} as his leader", if player.available_leaders.len() > 1 { "choosing" } else { "getting" }, &player.available_leaders[leader_index].name)), if player.get_city(*city_position).expect("there should be a city at the given position").is_activated() { format!(" making it {:?}", player.get_city(*city_position).expect("there should be a city at the given position").mood_state.clone() - 1) } else { String::new() }, format_args!("{}{}", match replaced_units.len() { 0 => "", 1 => " and replaces the unit at ", _ => " and replaces units at " }, utils::format_list(&replaced_units.iter().map(|unit_id| player.get_unit(*unit_id).expect("the player should have the replaced units").position.to_string()).unique().collect::<Vec<String>>(), ""))),
PlayingAction::MoveUnits => format!("{player_name} used a move units action"),
PlayingAction::IncreaseHappiness { happiness_increases } => {
let happiness_increases = happiness_increases.iter().filter_map(|(position, steps)| if *steps > 0 { Some(format!("the city at {position} by {steps} steps, making it {:?}", player.get_city(*position).expect("player should have a city at this position").mood_state.clone() + *steps)) } else { None }).collect::<Vec<String>>();
@ -119,6 +114,112 @@ fn format_playing_action_log_item(action: &PlayingAction, game: &Game) -> String
}
}
fn format_collect_log_item(
player: &Player,
player_name: &String,
city_position: Position,
collections: &[(Position, ResourcePile)],
) -> String {
let res = utils::format_list(
&collections
.iter()
.map(|(_, collection)| collection.to_string())
.collect::<Vec<String>>(),
"nothing",
);
let total = if collections.len() > 1
&& collections
.iter()
.permutations(2)
.unique()
.any(|permutation| permutation[0].1.has_common_resource(&permutation[1].1))
{
format!(
" for a total of {}",
collections
.iter()
.map(|(_, collection)| collection.clone())
.sum::<ResourcePile>()
)
} else {
String::new()
};
let mood = if player
.get_city(city_position)
.expect("there should be a city at the given position")
.is_activated()
{
format!(
" making it {:?}",
player
.get_city(city_position)
.expect("there should be a city at the given position")
.mood_state
.clone()
- 1
)
} else {
String::new()
};
format!("{player_name} collects {res}{total} in the city at {city_position}{mood}")
}
fn format_construct_log_item(
game: &Game,
player: &Player,
player_name: &String,
c: &Construct,
) -> String {
let port_pos = if let Some(port_position) = c.port_position {
let adjacent_water_tiles = c
.city_position
.neighbors()
.iter()
.filter(|neighbor| {
game.map
.tiles
.get(neighbor)
.is_some_and(|terrain| terrain == &Terrain::Water)
})
.count();
if adjacent_water_tiles > 1 {
format!(" at the water tile {port_position}")
} else {
String::new()
}
} else {
String::new()
};
let city_piece = &c.city_piece;
let payment = &c.payment;
let city_position = &c.city_position;
let mood = if player
.get_city(*city_position)
.expect("there should be a city at the given position")
.is_activated()
{
format!(
" making it {:?}",
player
.get_city(*city_position)
.expect("there should be a city at the given position")
.mood_state
.clone()
- 1
)
} else {
String::new()
};
let temple = if let Some(temple_bonus) = &c.temple_bonus {
format!(" and chooses to get {temple_bonus}")
} else {
String::new()
};
format!("{player_name} paid {payment} to construct a {city_piece:?} in the city at {city_position}{port_pos}{mood}{temple}")
}
fn format_movement_action_log_item(action: &MovementAction, game: &Game) -> String {
let player = &game.players[game.active_player()];
let player_name = player.get_name();
@ -161,12 +262,13 @@ fn format_status_phase_action_log_item(action: &StatusPhaseAction, game: &Game)
StatusPhaseAction::FreeAdvance(advance) => {
format!("{player_name} advanced {advance} for free")
}
StatusPhaseAction::RaseSize1City(city) => {
StatusPhaseAction::RazeSize1City(city) => {
format!(
"{player_name} {}",
match city {
Some(city) => format!("rased the city at {city} and gained 1 gold"),
None => String::from("did not rase a city"),
RazeSize1City::Position(city) =>
format!("razed the city at {city} and gained 1 gold"),
RazeSize1City::None => String::from("did not rase a city"),
}
)
}
@ -174,7 +276,7 @@ fn format_status_phase_action_log_item(action: &StatusPhaseAction, game: &Game)
format!(
"{player_name} {}",
match new_government {
Some(new_government_advance) => format!(
ChangeGovernmentType::ChangeGovernment(new_government_advance) => format!(
"changed his government from {} to {} - additional advances: {}",
game.players[game.active_player()]
.government()
@ -182,7 +284,8 @@ fn format_status_phase_action_log_item(action: &StatusPhaseAction, game: &Game)
new_government_advance.new_government,
new_government_advance.additional_advances.join(", ")
),
None => String::from("did not change his government"),
ChangeGovernmentType::KeepGovernment =>
String::from("did not change his government"),
}
)
}
@ -219,10 +322,10 @@ fn format_combat_action_log_item(action: &CombatAction, game: &Game) -> String {
match action {
CombatAction::PlayActionCard(card) => format!(
"{player_name} {}",
card.as_ref()
.map_or(String::from("did not play a tactics card"), |card| format!(
"played the {card} tactics card"
))
match card {
PlayActionCard::Card(card) => format!("played the {card} tactics card"),
PlayActionCard::None => String::from("did not play a tactics card"),
}
),
CombatAction::RemoveCasualties(casualties) => format!(
"{player_name} removed {}",

View file

@ -18,6 +18,15 @@ use crate::{
unit::UnitType,
};
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone)]
pub struct Construct {
pub city_position: Position,
pub city_piece: Building,
pub payment: ResourcePile,
pub port_position: Option<Position>,
pub temple_bonus: Option<ResourcePile>,
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone)]
pub enum PlayingAction {
Advance {
@ -27,13 +36,7 @@ pub enum PlayingAction {
FoundCity {
settler: u32,
},
Construct {
city_position: Position,
city_piece: Building,
payment: ResourcePile,
port_position: Option<Position>,
temple_bonus: Option<ResourcePile>,
},
Construct(Construct),
Collect {
city_position: Position,
collections: Vec<(Position, ResourcePile)>,
@ -95,42 +98,36 @@ impl PlayingAction {
game.undo_context_stack
.push(UndoContext::FoundCity { settler });
}
Construct {
city_position,
city_piece,
payment,
port_position,
temple_bonus,
} => {
Construct(c) => {
let player = &mut game.players[player_index];
let city = player.get_city(city_position).expect("Illegal action");
let cost = player.construct_cost(&city_piece, city);
let city = player.get_city(c.city_position).expect("Illegal action");
let cost = player.construct_cost(&c.city_piece, city);
assert!(
city.can_construct(&city_piece, player) && cost.is_valid_payment(&payment),
city.can_construct(&c.city_piece, player) && cost.is_valid_payment(&c.payment),
"Illegal action"
);
if matches!(&city_piece, Port) {
let port_position = port_position.as_ref().expect("Illegal action");
if matches!(&c.city_piece, Port) {
let port_position = c.port_position.as_ref().expect("Illegal action");
assert!(
city.position.neighbors().contains(port_position),
"Illegal action"
);
} else if port_position.is_some() {
} else if c.port_position.is_some() {
panic!("Illegal action");
}
if matches!(&city_piece, Temple) {
let building_bonus = temple_bonus.expect("Illegal action");
if matches!(&c.city_piece, Temple) {
let building_bonus = c.temple_bonus.expect("Illegal action");
assert!(
building_bonus == ResourcePile::mood_tokens(1)
|| building_bonus == ResourcePile::culture_tokens(1),
"Illegal action"
);
player.gain_resources(building_bonus);
} else if temple_bonus.is_some() {
} else if c.temple_bonus.is_some() {
panic!("Illegal action");
}
player.loose_resources(payment);
player.construct(&city_piece, city_position, port_position);
player.loose_resources(c.payment);
player.construct(&c.city_piece, c.city_position, c.port_position);
}
Collect {
city_position,
@ -296,19 +293,14 @@ impl PlayingAction {
.pop()
.expect("The player should have a city after founding one");
}
Construct {
city_position,
city_piece,
payment,
port_position: _,
temple_bonus,
} => {
Construct(c) => {
let player = &mut game.players[player_index];
player.undo_construct(&city_piece, city_position);
player.gain_resources(payment);
if matches!(&city_piece, Temple) {
player.undo_construct(&c.city_piece, c.city_position);
player.gain_resources(c.payment);
if matches!(&c.city_piece, Temple) {
player.loose_resources(
temple_bonus.expect("build data should contain temple bonus"),
c.temple_bonus
.expect("build data should contain temple bonus"),
);
}
}

View file

@ -11,17 +11,31 @@ use crate::{
};
#[derive(Serialize, Deserialize, Clone)]
pub struct ChangeGovernmentType {
pub struct ChangeGovernment {
pub new_government: String,
pub additional_advances: Vec<String>,
}
// Can't use Option<String> because of mongo stips null values
#[derive(Serialize, Deserialize, Clone)]
pub enum ChangeGovernmentType {
ChangeGovernment(ChangeGovernment),
KeepGovernment,
}
// Can't use Option<String> because of mongo stips null values
#[derive(Serialize, Deserialize, Clone)]
pub enum RazeSize1City {
None,
Position(Position),
}
#[derive(Serialize, Deserialize, Clone)]
pub enum StatusPhaseAction {
CompleteObjectives(Vec<String>),
FreeAdvance(String),
RaseSize1City(Option<Position>),
ChangeGovernmentType(Option<ChangeGovernmentType>),
RazeSize1City(RazeSize1City),
ChangeGovernmentType(ChangeGovernmentType),
DetermineFirstPlayer(usize),
}
@ -31,7 +45,7 @@ impl StatusPhaseAction {
match self {
StatusPhaseAction::CompleteObjectives(_) => StatusPhaseState::CompleteObjectives,
StatusPhaseAction::FreeAdvance(_) => StatusPhaseState::FreeAdvance,
StatusPhaseAction::RaseSize1City(_) => StatusPhaseState::RaseSize1City,
StatusPhaseAction::RazeSize1City(_) => StatusPhaseState::RazeSize1City,
StatusPhaseAction::ChangeGovernmentType(_) => StatusPhaseState::ChangeGovernmentType,
StatusPhaseAction::DetermineFirstPlayer(_) => StatusPhaseState::DetermineFirstPlayer,
}
@ -54,8 +68,8 @@ impl StatusPhaseAction {
);
game.advance(advance, player_index);
}
StatusPhaseAction::RaseSize1City(ref city) => {
if let Some(city) = *city {
StatusPhaseAction::RazeSize1City(ref city) => {
if let RazeSize1City::Position(city) = *city {
assert!(
game.players[player_index].can_raze_city(city),
"Illegal action"
@ -65,7 +79,9 @@ impl StatusPhaseAction {
}
}
StatusPhaseAction::ChangeGovernmentType(ref new_government_advance) => {
if let Some(new_government) = new_government_advance {
if let ChangeGovernmentType::ChangeGovernment(new_government) =
new_government_advance
{
change_government_type(game, player_index, new_government);
}
}
@ -80,11 +96,7 @@ impl StatusPhaseAction {
}
}
fn change_government_type(
game: &mut Game,
player_index: usize,
new_government: &ChangeGovernmentType,
) {
fn change_government_type(game: &mut Game, player_index: usize, new_government: &ChangeGovernment) {
let government = &new_government.new_government;
if advances::get_leading_government_advance(government)
.expect("government should exist")
@ -177,7 +189,7 @@ fn skip_player(game: &Game, player_index: usize, state: &StatusPhaseState) -> bo
StatusPhaseState::FreeAdvance => !advances::get_all()
.into_iter()
.any(|advance| player.can_advance_free(&advance.name)),
StatusPhaseState::RaseSize1City => !player.cities.iter().any(|city| city.size() == 1),
StatusPhaseState::RazeSize1City => !player.cities.iter().any(|city| city.size() == 1),
StatusPhaseState::ChangeGovernmentType => {
player.government().is_none()
|| player.government().is_some_and(|government| {
@ -195,7 +207,7 @@ pub enum StatusPhaseState {
CompleteObjectives,
FreeAdvance,
//draw new cards (after free advance)
RaseSize1City,
RazeSize1City,
ChangeGovernmentType,
DetermineFirstPlayer,
}
@ -206,8 +218,8 @@ pub fn next_status_phase(phase: Option<StatusPhaseState>) -> StatusPhaseState {
if let Some(phase) = phase {
match phase {
CompleteObjectives => FreeAdvance,
FreeAdvance => RaseSize1City,
RaseSize1City => ChangeGovernmentType,
FreeAdvance => RazeSize1City,
RazeSize1City => ChangeGovernmentType,
ChangeGovernmentType => DetermineFirstPlayer,
DetermineFirstPlayer => {
unreachable!("function should return early with this action")

View file

@ -8,7 +8,9 @@ use std::{
use server::action::CombatAction;
use server::game::{CulturalInfluenceResolution, GameState};
use server::status_phase::{ChangeGovernmentType, StatusPhaseAction};
use server::status_phase::{
ChangeGovernment, ChangeGovernmentType, RazeSize1City, StatusPhaseAction,
};
use server::{
action::Action,
city::{City, MoodState::*},
@ -20,6 +22,7 @@ use server::{
game::Game,
game_api,
map::Terrain::*,
playing_actions,
playing_actions::PlayingAction::*,
position::Position,
resource_pile::ResourcePile,
@ -71,13 +74,13 @@ fn basic_actions() {
.cities
.push(City::new(0, Position::new(0, 2)));
let construct_action = Action::Playing(Construct {
let construct_action = Action::Playing(Construct(playing_actions::Construct {
city_position,
city_piece: Building::Observatory,
payment: ResourcePile::new(1, 1, 1, 0, 0, 0, 0),
port_position: None,
temple_bonus: None,
});
}));
let game = game_api::execute_action(game, construct_action, 0);
let player = &game.players[0];
@ -415,13 +418,15 @@ fn test_action(
undoable: bool,
illegal_action_test: bool,
) {
let a = serde_json::to_string(&action).expect("action should be serializable");
let a2 = serde_json::from_str(&a).expect("action should be deserializable");
let path = game_path(name);
let original_game =
fs::read_to_string(path).expect("game file should exist in the test games folder");
let game = Game::from_data(
serde_json::from_str(&original_game).expect("the game file should be deserializable"),
);
let game = game_api::execute_action(game, action, player_index);
let game = game_api::execute_action(game, a2, player_index);
if illegal_action_test {
println!(
"execute action was successful but should have panicked because the action is illegal"
@ -590,13 +595,13 @@ fn test_collect() {
fn test_construct() {
test_action(
"construct",
Action::Playing(Construct {
Action::Playing(Construct(playing_actions::Construct {
city_position: Position::from_offset("C2"),
city_piece: Observatory,
payment: ResourcePile::new(1, 1, 1, 0, 0, 0, 0),
port_position: None,
temple_bonus: None,
}),
})),
0,
true,
false,
@ -607,13 +612,13 @@ fn test_construct() {
fn test_construct_port() {
test_action(
"construct_port",
Action::Playing(Construct {
Action::Playing(Construct(playing_actions::Construct {
city_position: Position::from_offset("A1"),
city_piece: Port,
payment: ResourcePile::new(1, 1, 1, 0, 0, 0, 0),
port_position: Some(Position::from_offset("A2")),
temple_bonus: None,
}),
})),
0,
true,
false,
@ -625,7 +630,7 @@ fn test_construct_port() {
fn test_wrong_status_phase_action() {
test_action(
"illegal_free_advance",
Action::StatusPhase(StatusPhaseAction::RaseSize1City(None)),
Action::StatusPhase(StatusPhaseAction::RazeSize1City(RazeSize1City::None)),
0,
false,
true,
@ -649,7 +654,7 @@ fn test_free_advance() {
fn test_raze_city() {
test_action(
"raze_city",
Action::StatusPhase(StatusPhaseAction::RaseSize1City(Some(
Action::StatusPhase(StatusPhaseAction::RazeSize1City(RazeSize1City::Position(
Position::from_offset("A1"),
))),
0,
@ -658,6 +663,17 @@ fn test_raze_city() {
);
}
#[test]
fn test_raze_city_decline() {
test_action(
"raze_city_decline",
Action::StatusPhase(StatusPhaseAction::RazeSize1City(RazeSize1City::None)),
0,
false,
false,
);
}
#[test]
fn test_determine_first_player() {
test_action(
@ -673,12 +689,12 @@ fn test_determine_first_player() {
fn test_change_government() {
test_action(
"change_government",
Action::StatusPhase(StatusPhaseAction::ChangeGovernmentType(Some(
ChangeGovernmentType {
Action::StatusPhase(StatusPhaseAction::ChangeGovernmentType(
ChangeGovernmentType::ChangeGovernment(ChangeGovernment {
new_government: String::from("Theocracy"),
additional_advances: vec![String::from("Theocracy 2")],
},
))),
}),
)),
0,
false,
false,

View file

@ -471,12 +471,12 @@
},
{
"StatusPhase": {
"RaseSize1City": null
"RazeSize1City": "None"
}
},
{
"StatusPhase": {
"RaseSize1City": null
"RazeSize1City": "None"
}
}
],
@ -485,8 +485,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Voting advance",
"Player1 payed 2 ideas to get the Democracy 2 advance",
"Player1 paid 2 ideas to get the Voting advance",
"Player1 paid 2 ideas to get the Democracy 2 advance",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",

View file

@ -471,21 +471,23 @@
},
{
"StatusPhase": {
"RaseSize1City": null
"RazeSize1City": "None"
}
},
{
"StatusPhase": {
"RaseSize1City": null
"RazeSize1City": "None"
}
},
{
"StatusPhase": {
"ChangeGovernmentType": {
"new_government": "Theocracy",
"additional_advances": [
"Theocracy 2"
]
"ChangeGovernment": {
"new_government": "Theocracy",
"additional_advances": [
"Theocracy 2"
]
}
}
}
}
@ -495,8 +497,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Voting advance",
"Player1 payed 2 ideas to get the Democracy 2 advance",
"Player1 paid 2 ideas to get the Voting advance",
"Player1 paid 2 ideas to get the Democracy 2 advance",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",

View file

@ -452,8 +452,8 @@
"Age 1 has started",
"Round 1/3",
"Player1 increased happiness in the city at C2 by 1 steps, making it Happy",
"Player1 payed 2 ideas to get the Math advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Observatory in the city at C2 making it Neutral",
"Player1 paid 2 ideas to get the Math advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Observatory in the city at C2 making it Neutral",
"Player1 ended his turn",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",

View file

@ -485,8 +485,8 @@
"Age 1 has started",
"Round 1/3",
"Player1 increased happiness in the city at C2 by 1 steps, making it Happy",
"Player1 payed 2 ideas to get the Math advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Observatory in the city at C2 making it Neutral",
"Player1 paid 2 ideas to get the Math advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Observatory in the city at C2 making it Neutral",
"Player1 ended his turn",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",

View file

@ -427,7 +427,7 @@
"Age 1 has started",
"Round 1/3",
"Player1 increased happiness in the city at C2 by 1 steps, making it Happy",
"Player1 payed 2 ideas to get the Math advance"
"Player1 paid 2 ideas to get the Math advance"
],
"undo_limit": 0,
"played_once_per_turn_actions": [],

View file

@ -446,8 +446,8 @@
"Age 1 has started",
"Round 1/3",
"Player1 increased happiness in the city at C2 by 1 steps, making it Happy",
"Player1 payed 2 ideas to get the Math advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Observatory in the city at C2 making it Neutral"
"Player1 paid 2 ideas to get the Math advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Observatory in the city at C2 making it Neutral"
],
"undo_limit": 0,
"played_once_per_turn_actions": [],

View file

@ -464,8 +464,8 @@
"Age 1 has started",
"Round 1/3",
"Player1 increased happiness in the city at C2 by 1 steps, making it Happy",
"Player1 payed 2 ideas to get the Math advance",
"Player1 payed 2 ideas to get the Fishing advance",
"Player1 paid 2 ideas to get the Math advance",
"Player1 paid 2 ideas to get the Fishing advance",
"Player1 ended his turn",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",

View file

@ -483,14 +483,14 @@
"Age 1 has started",
"Round 1/3",
"Player1 increased happiness in the city at C2 by 1 steps, making it Happy",
"Player1 payed 2 ideas to get the Math advance",
"Player1 payed 2 ideas to get the Fishing advance",
"Player1 paid 2 ideas to get the Math advance",
"Player1 paid 2 ideas to get the Fishing advance",
"Player1 ended his turn",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",
"It's Player1's turn",
"Round 2/3",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Port in the city at A1"
"Player1 paid 1 food, 1 wood and 1 ore to construct a Port in the city at A1"
],
"undo_limit": 5,
"played_once_per_turn_actions": [],

View file

@ -391,8 +391,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn"
],

View file

@ -402,8 +402,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1 and succeeded (rolled 6)"

View file

@ -409,8 +409,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1and rolled a 1. Player2 now has the option to pay 4 culture tokens to increase the dice roll and proceed with the cultural influence"

View file

@ -405,12 +405,12 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1and rolled a 1. Player2 now has the option to pay 4 culture tokens to increase the dice roll and proceed with the cultural influence",
"Player2 payed 1 culture tokens to increased the dice roll and proceed with the cultural influence"
"Player2 paid 1 culture tokens to increased the dice roll and proceed with the cultural influence"
],
"undo_limit": 1,
"played_once_per_turn_actions": [],

View file

@ -398,12 +398,14 @@
},
{
"StatusPhase": {
"RaseSize1City": "A1"
"RazeSize1City": {
"Position": "A1"
}
}
},
{
"StatusPhase": {
"RaseSize1City": null
"RazeSize1City": "None"
}
}
],
@ -412,8 +414,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1 and succeeded (rolled 6)",
@ -434,7 +436,7 @@
"It's Player2's turn",
"Player2 advanced Philosophy for free",
"It's Player1's turn",
"Player1 rased the city at A1 and gained 1 gold",
"Player1 razed the city at A1 and gained 1 gold",
"It's Player2's turn",
"Player2 did not rase a city",
"It's Player1's turn"

View file

@ -396,12 +396,14 @@
},
{
"StatusPhase": {
"RaseSize1City": "A1"
"RazeSize1City": {
"Position": "A1"
}
}
},
{
"StatusPhase": {
"RaseSize1City": null
"RazeSize1City": "None"
}
},
{
@ -415,8 +417,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1 and succeeded (rolled 6)",
@ -437,7 +439,7 @@
"It's Player2's turn",
"Player2 advanced Philosophy for free",
"It's Player1's turn",
"Player1 rased the city at A1 and gained 1 gold",
"Player1 razed the city at A1 and gained 1 gold",
"It's Player2's turn",
"Player2 did not rase a city",
"It's Player1's turn",

View file

@ -418,7 +418,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action"
],
"undo_limit": 0,

View file

@ -420,7 +420,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry, 1 cavalry, 1 elephant and a leader from C2 to C1",
"\nCombat round 1",

View file

@ -444,7 +444,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry from C2 to C1",
"\nCombat round 1",

View file

@ -455,7 +455,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry from C2 to C1",
"\nCombat round 1",
@ -555,4 +555,4 @@
}
}
]
}
}

View file

@ -418,7 +418,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action"
],
"undo_limit": 0,

View file

@ -444,7 +444,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry from C2 to C1",
"\nCombat round 1",

View file

@ -393,8 +393,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1 and succeeded (rolled 6)",

View file

@ -400,8 +400,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1 and succeeded (rolled 6)",

View file

@ -393,8 +393,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1 and succeeded (rolled 6)",

View file

@ -1,6 +1,6 @@
{
"state": {
"StatusPhase": "RaseSize1City"
"StatusPhase": "RazeSize1City"
},
"players": [
{
@ -420,8 +420,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1 and succeeded (rolled 6)",

View file

@ -1,6 +1,6 @@
{
"state": {
"StatusPhase": "RaseSize1City"
"StatusPhase": "RazeSize1City"
},
"players": [
{
@ -398,7 +398,9 @@
},
{
"StatusPhase": {
"RaseSize1City": "A1"
"RazeSize1City": {
"Position": "A1"
}
}
}
],
@ -407,8 +409,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1 and succeeded (rolled 6)",
@ -429,7 +431,7 @@
"It's Player2's turn",
"Player2 advanced Philosophy for free",
"It's Player1's turn",
"Player1 rased the city at A1 and gained 1 gold",
"Player1 razed the city at A1 and gained 1 gold",
"It's Player2's turn"
],
"undo_limit": 3,

View file

@ -0,0 +1,536 @@
{
"state": {
"StatusPhase": "RazeSize1City"
},
"players": [
{
"name": null,
"id": 0,
"resources": {
"food": 1,
"wood": 6,
"ore": 6,
"ideas": 5,
"gold": 6,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"city_pieces": {
"academy": null,
"market": null,
"obelisk": null,
"observatory": null,
"fortress": null,
"port": null,
"temple": null,
"wonders": []
},
"mood_state": "Happy",
"activations": 0,
"angry_activation": false,
"player_index": 0,
"position": "A1",
"port_position": null
},
{
"city_pieces": {
"academy": null,
"market": null,
"obelisk": null,
"observatory": null,
"fortress": 1,
"port": null,
"temple": null,
"wonders": []
},
"mood_state": "Angry",
"activations": 0,
"angry_activation": false,
"player_index": 0,
"position": "C2",
"port_position": null
}
],
"units": [
{
"player_index": 0,
"position": "C2",
"unit_type": "Infantry",
"movement_restriction": "None",
"id": 0
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Cavalry",
"movement_restriction": "None",
"id": 1
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Leader",
"movement_restriction": "None",
"id": 2
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Elephant",
"movement_restriction": "None",
"id": 3
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"id": 4
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"id": 5
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"id": 6
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"id": 7
}
],
"civilization": "test0",
"active_leader": null,
"available_leaders": [],
"advances": [
"Farming",
"Fishing",
"Mining",
"Tactics"
],
"unlocked_special_advance": [],
"wonders": [],
"wonders_build": 0,
"leader_position": null,
"game_event_tokens": 1,
"influenced_buildings": 0,
"completed_objectives": [],
"captured_leaders": [],
"event_victory_points": 0.0,
"wonder_cards": [],
"available_settlements": 7,
"available_buildings": {
"academies": 5,
"markets": 5,
"obelisks": 5,
"observatories": 5,
"fortresses": 5,
"ports": 5,
"temples": 5
},
"available_units": {
"settlers": 0,
"infantry": 15,
"ships": 4,
"cavalry": 3,
"elephants": 3,
"leaders": 0
},
"collect_options": [
[
"Mountain",
[
{
"food": 0,
"wood": 0,
"ore": 1,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Fertile",
[
{
"food": 1,
"wood": 0,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Forest",
[
{
"food": 0,
"wood": 1,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Water",
[
{
"food": 1,
"wood": 0,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
]
],
"next_unit_id": 8
},
{
"name": null,
"id": 1,
"resources": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"city_pieces": {
"academy": null,
"market": null,
"obelisk": null,
"observatory": null,
"fortress": null,
"port": null,
"temple": null,
"wonders": []
},
"mood_state": "Angry",
"activations": 0,
"angry_activation": false,
"player_index": 1,
"position": "C1",
"port_position": null
}
],
"units": [
{
"player_index": 1,
"position": "C1",
"unit_type": "Infantry",
"movement_restriction": "None",
"id": 0
},
{
"player_index": 1,
"position": "C1",
"unit_type": "Infantry",
"movement_restriction": "None",
"id": 1
}
],
"civilization": "test1",
"active_leader": null,
"available_leaders": [],
"advances": [
"Farming",
"Mining",
"Philosophy"
],
"unlocked_special_advance": [],
"wonders": [],
"wonders_build": 0,
"leader_position": null,
"game_event_tokens": 2,
"influenced_buildings": 1,
"completed_objectives": [],
"captured_leaders": [],
"event_victory_points": 0.0,
"wonder_cards": [],
"available_settlements": 7,
"available_buildings": {
"academies": 5,
"markets": 5,
"obelisks": 5,
"observatories": 5,
"fortresses": 4,
"ports": 5,
"temples": 5
},
"available_units": {
"settlers": 4,
"infantry": 14,
"ships": 4,
"cavalry": 4,
"elephants": 4,
"leaders": 1
},
"collect_options": [
[
"Mountain",
[
{
"food": 0,
"wood": 0,
"ore": 1,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Fertile",
[
{
"food": 1,
"wood": 0,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Forest",
[
{
"food": 0,
"wood": 1,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
]
],
"next_unit_id": 2
}
],
"map": {
"tiles": [
[
"A1",
"Fertile"
],
[
"A2",
"Water"
],
[
"A3",
"Mountain"
],
[
"B1",
"Mountain"
],
[
"B2",
"Forest"
],
[
"B3",
"Fertile"
],
[
"C1",
"Barren"
],
[
"C2",
"Forest"
],
[
"C3",
"Water"
],
[
"D2",
"Water"
]
]
},
"starting_player_index": 0,
"current_player_index": 0,
"action_log": [
{
"StatusPhase": {
"FreeAdvance": "Fishing"
}
},
{
"StatusPhase": {
"FreeAdvance": "Philosophy"
}
}
],
"action_log_index": 2,
"log": [
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1 and succeeded (rolled 6)",
"Player2 ended his turn with 2 actions left",
"It's Player1's turn",
"Round 2/3",
"Player1 ended his turn with 3 actions left",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",
"It's Player1's turn",
"Round 3/3",
"Player1 ended his turn with 3 actions left",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",
"It's Player1's turn",
"The game has entered the 1st status phase",
"Player1 advanced Fishing for free",
"It's Player2's turn",
"Player2 advanced Philosophy for free",
"It's Player1's turn"
],
"undo_limit": 2,
"played_once_per_turn_actions": [],
"actions_left": 3,
"successful_cultural_influence": false,
"round": 1,
"age": 1,
"messages": [
"The game has started"
],
"dice_roll_outcomes": [
1,
1,
10,
10,
10,
10,
10,
10,
10
],
"dice_roll_log": [
10
],
"dropped_players": [],
"wonders_left": [
"X"
],
"wonder_amount_left": 1,
"undo_context_stack": [
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
}
]
}

View file

@ -0,0 +1,543 @@
{
"state": {
"StatusPhase": "RazeSize1City"
},
"players": [
{
"name": null,
"id": 0,
"resources": {
"food": 1,
"wood": 6,
"ore": 6,
"ideas": 5,
"gold": 6,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"city_pieces": {
"academy": null,
"market": null,
"obelisk": null,
"observatory": null,
"fortress": null,
"port": null,
"temple": null,
"wonders": []
},
"mood_state": "Happy",
"activations": 0,
"angry_activation": false,
"player_index": 0,
"position": "A1",
"port_position": null
},
{
"city_pieces": {
"academy": null,
"market": null,
"obelisk": null,
"observatory": null,
"fortress": 1,
"port": null,
"temple": null,
"wonders": []
},
"mood_state": "Angry",
"activations": 0,
"angry_activation": false,
"player_index": 0,
"position": "C2",
"port_position": null
}
],
"units": [
{
"player_index": 0,
"position": "C2",
"unit_type": "Infantry",
"movement_restriction": "None",
"id": 0
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Cavalry",
"movement_restriction": "None",
"id": 1
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Leader",
"movement_restriction": "None",
"id": 2
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Elephant",
"movement_restriction": "None",
"id": 3
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"id": 4
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"id": 5
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"id": 6
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"id": 7
}
],
"civilization": "test0",
"active_leader": null,
"available_leaders": [],
"advances": [
"Farming",
"Fishing",
"Mining",
"Tactics"
],
"unlocked_special_advance": [],
"wonders": [],
"wonders_build": 0,
"leader_position": null,
"game_event_tokens": 1,
"influenced_buildings": 0,
"completed_objectives": [],
"captured_leaders": [],
"event_victory_points": 0.0,
"wonder_cards": [],
"available_settlements": 7,
"available_buildings": {
"academies": 5,
"markets": 5,
"obelisks": 5,
"observatories": 5,
"fortresses": 5,
"ports": 5,
"temples": 5
},
"available_units": {
"settlers": 0,
"infantry": 15,
"ships": 4,
"cavalry": 3,
"elephants": 3,
"leaders": 0
},
"collect_options": [
[
"Mountain",
[
{
"food": 0,
"wood": 0,
"ore": 1,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Fertile",
[
{
"food": 1,
"wood": 0,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Forest",
[
{
"food": 0,
"wood": 1,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Water",
[
{
"food": 1,
"wood": 0,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
]
],
"next_unit_id": 8
},
{
"name": null,
"id": 1,
"resources": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"city_pieces": {
"academy": null,
"market": null,
"obelisk": null,
"observatory": null,
"fortress": null,
"port": null,
"temple": null,
"wonders": []
},
"mood_state": "Angry",
"activations": 0,
"angry_activation": false,
"player_index": 1,
"position": "C1",
"port_position": null
}
],
"units": [
{
"player_index": 1,
"position": "C1",
"unit_type": "Infantry",
"movement_restriction": "None",
"id": 0
},
{
"player_index": 1,
"position": "C1",
"unit_type": "Infantry",
"movement_restriction": "None",
"id": 1
}
],
"civilization": "test1",
"active_leader": null,
"available_leaders": [],
"advances": [
"Farming",
"Mining",
"Philosophy"
],
"unlocked_special_advance": [],
"wonders": [],
"wonders_build": 0,
"leader_position": null,
"game_event_tokens": 2,
"influenced_buildings": 1,
"completed_objectives": [],
"captured_leaders": [],
"event_victory_points": 0.0,
"wonder_cards": [],
"available_settlements": 7,
"available_buildings": {
"academies": 5,
"markets": 5,
"obelisks": 5,
"observatories": 5,
"fortresses": 4,
"ports": 5,
"temples": 5
},
"available_units": {
"settlers": 4,
"infantry": 14,
"ships": 4,
"cavalry": 4,
"elephants": 4,
"leaders": 1
},
"collect_options": [
[
"Mountain",
[
{
"food": 0,
"wood": 0,
"ore": 1,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Fertile",
[
{
"food": 1,
"wood": 0,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Forest",
[
{
"food": 0,
"wood": 1,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
]
],
"next_unit_id": 2
}
],
"map": {
"tiles": [
[
"A1",
"Fertile"
],
[
"A2",
"Water"
],
[
"A3",
"Mountain"
],
[
"B1",
"Mountain"
],
[
"B2",
"Forest"
],
[
"B3",
"Fertile"
],
[
"C1",
"Barren"
],
[
"C2",
"Forest"
],
[
"C3",
"Water"
],
[
"D2",
"Water"
]
]
},
"starting_player_index": 0,
"current_player_index": 1,
"action_log": [
{
"StatusPhase": {
"FreeAdvance": "Fishing"
}
},
{
"StatusPhase": {
"FreeAdvance": "Philosophy"
}
},
{
"StatusPhase": {
"RazeSize1City": "None"
}
}
],
"action_log_index": 3,
"log": [
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1 and succeeded (rolled 6)",
"Player2 ended his turn with 2 actions left",
"It's Player1's turn",
"Round 2/3",
"Player1 ended his turn with 3 actions left",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",
"It's Player1's turn",
"Round 3/3",
"Player1 ended his turn with 3 actions left",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",
"It's Player1's turn",
"The game has entered the 1st status phase",
"Player1 advanced Fishing for free",
"It's Player2's turn",
"Player2 advanced Philosophy for free",
"It's Player1's turn",
"Player1 did not rase a city",
"It's Player2's turn"
],
"undo_limit": 3,
"played_once_per_turn_actions": [],
"actions_left": 3,
"successful_cultural_influence": false,
"round": 1,
"age": 1,
"messages": [
"The game has started"
],
"dice_roll_outcomes": [
1,
1,
10,
10,
10,
10,
10,
10,
10
],
"dice_roll_log": [
10
],
"dropped_players": [],
"wonders_left": [
"X"
],
"wonder_amount_left": 1,
"undo_context_stack": [
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
}
]
}

View file

@ -485,8 +485,8 @@
"Age 1 has started",
"Round 1/3",
"Player1 increased happiness in the city at C2 by 1 steps, making it Happy",
"Player1 payed 2 ideas to get the Math advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Observatory in the city at C2 making it Neutral",
"Player1 paid 2 ideas to get the Math advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Observatory in the city at C2 making it Neutral",
"Player1 ended his turn",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",

View file

@ -516,15 +516,15 @@
"Age 1 has started",
"Round 1/3",
"Player1 increased happiness in the city at C2 by 1 steps, making it Happy",
"Player1 payed 2 ideas to get the Math advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Observatory in the city at C2 making it Neutral",
"Player1 paid 2 ideas to get the Math advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Observatory in the city at C2 making it Neutral",
"Player1 ended his turn",
"It's Player2's turn",
"Player2 ended his turn with 3 actions left",
"It's Player1's turn",
"Round 2/3",
"Player1 collects 1 wood and 1 ore in the city at C2",
"Player1 payed 1 food, 1 ore and 2 gold to recruit 1 settler and 1 infantry in the city at A1 and replaces the unit at C2"
"Player1 paid 1 food, 1 ore and 2 gold to recruit 1 settler and 1 infantry in the city at A1 and replaces the unit at C2"
],
"undo_limit": 5,
"played_once_per_turn_actions": [],

View file

@ -443,8 +443,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Fishing advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Port in the city at C2 at the water tile C3 making it Angry"
"Player1 paid 2 ideas to get the Fishing advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Port in the city at C2 at the water tile C3 making it Angry"
],
"undo_limit": 0,
"played_once_per_turn_actions": [],

View file

@ -457,9 +457,9 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Fishing advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Port in the city at C2 at the water tile C3 making it Angry",
"Player1 payed 2 wood to recruit 1 ship in the city at C2 making it Angry",
"Player1 paid 2 ideas to get the Fishing advance",
"Player1 paid 1 food, 1 wood and 1 ore to construct a Port in the city at C2 at the water tile C3 making it Angry",
"Player1 paid 2 wood to recruit 1 ship in the city at C2 making it Angry",
"\nCombat round 1",
"\tPlayer1 rolled a combined combat value of 6 and gets 1 hits against defending units. Player2 rolled a combined combat value of 6 and gets 1 hits against attacking units.",
"\tAll attacking and defending units where eliminated, ending the battle in a draw"
@ -560,4 +560,4 @@
}
}
]
}
}

View file

@ -444,7 +444,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry, 1 cavalry, 1 elephant and a leader from C2 to C1",
"\nCombat round 1",

View file

@ -414,7 +414,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry, 1 cavalry, 1 elephant and a leader from C2 to C1",
"\nCombat round 1",
@ -513,4 +513,4 @@
}
}
]
}
}

View file

@ -450,7 +450,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry from C2 to C1",
"\nCombat round 1",

View file

@ -423,7 +423,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry from C2 to C1",
"\nCombat round 1",
@ -518,4 +518,4 @@
}
}
]
}
}

View file

@ -444,7 +444,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry from C2 to C1",
"\nCombat round 1",

View file

@ -449,7 +449,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry from C2 to C1",
"\nCombat round 1",

View file

@ -418,7 +418,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action"
],
"undo_limit": 0,

View file

@ -444,7 +444,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry, 1 cavalry, 1 elephant and a leader from C2 to C1",
"\nCombat round 1",
@ -541,4 +541,4 @@
}
}
]
}
}

View file

@ -418,7 +418,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action"
],
"undo_limit": 0,

View file

@ -450,7 +450,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 paid 2 ideas to get the Tactics advance",
"Player1 used a move units action",
"\tPlayer1 moved 1 infantry from C2 to C1",
"\nCombat round 1",
@ -543,4 +543,4 @@
}
}
]
}
}

View file

@ -412,7 +412,7 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Engineering advance"
"Player1 paid 2 ideas to get the Engineering advance"
],
"undo_limit": 1,
"played_once_per_turn_actions": [],

View file

@ -433,8 +433,8 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Engineering advance",
"Player1 payed 2 food, 3 wood, 3 ore and 4 culture tokens to construct the X wonder in the city at A1"
"Player1 paid 2 ideas to get the Engineering advance",
"Player1 paid 2 food, 3 wood, 3 ore and 4 culture tokens to construct the X wonder in the city at A1"
],
"undo_limit": 1,
"played_once_per_turn_actions": [],