This commit is contained in:
Gregor Zeitlinger 2025-09-06 10:45:15 +02:00 • committed by GitHub
commit dcbd743942
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
310 changed files with 6821 additions and 3767 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View file

@ -11,7 +11,7 @@ use crate::render_context::RenderContext;
use itertools::Itertools;
use server::action::Action;
use server::city::City;
use server::content::custom_actions::{CustomAction, CustomActionInfo};
use server::content::custom_actions::{CustomAction, SpecialActionInfo};
use server::cultural_influence::available_influence_actions;
use server::happiness::available_happiness_actions;
use server::playing_actions::{PlayingAction, PlayingActionType};
@ -65,7 +65,7 @@ pub(crate) fn action_buttons(rc: &RenderContext) -> RenderResult {
&MultilineText::of(rc, "Cultural Influence"),
)
{
return base_or_custom_action(rc, &influence, "Influence culture", |d| {
return base_or_modified_action(rc, &influence, "Influence culture", |d| {
new_cultural_influence_dialog(rc.game, rc.shown_player.index, d)
});
}
@ -74,7 +74,7 @@ pub(crate) fn action_buttons(rc: &RenderContext) -> RenderResult {
if let Some(action) = generic_custom_action(rc, &c, None) {
if bottom_left_texture(
rc,
&assets.custom_actions[&c.action],
&assets.custom_actions[&c.custom_action_type()],
icon_pos(i as i8, -1),
&event_help_tooltip(rc, &c.event_origin),
) {
@ -103,7 +103,7 @@ pub(crate) fn custom_action_buttons<'a>(
.filter_map(|c| {
generic_custom_action(rc, &c, city).map(|action| {
IconAction::new(
&rc.assets().custom_actions[&c.action],
&rc.assets().custom_actions[&c.custom_action_type()],
false,
event_help_tooltip(rc, &c.event_origin),
Box::new(move || action.clone()),
@ -128,10 +128,10 @@ fn global_move(rc: &RenderContext) -> RenderResult {
fn generic_custom_action(
rc: &RenderContext,
c: &CustomActionInfo,
c: &SpecialActionInfo,
city: Option<&City>,
) -> Option<RenderResult> {
let custom_action_type = c.action;
let custom_action_type = c.custom_action_type();
if let Some(city) = city {
c.is_city_available(rc.game, city)
@ -147,7 +147,7 @@ fn generic_custom_action(
}
}
pub(crate) fn base_or_custom_action(
pub(crate) fn base_or_modified_action(
rc: &RenderContext,
action_types: &[PlayingActionType],
title: &str,
@ -158,8 +158,8 @@ pub(crate) fn base_or_custom_action(
action_types
.iter()
.map(|action_type| match action_type {
PlayingActionType::Custom(c) => {
let origin = &rc.shown_player.custom_action_info(*c).event_origin;
PlayingActionType::Special(s) => {
let origin = &rc.shown_player.special_action_info(s).event_origin;
(
Some(origin.clone()),
execute(BaseOrCustomDialog {

View file

@ -60,6 +60,9 @@ pub(crate) struct Assets {
pub custom_actions: HashMap<CustomActionType, Texture2D>,
pub civ: HashMap<String, CivAssets>,
pub default_civ: CivAssets,
// Log
pub hex: Texture2D,
}
impl Assets {
@ -116,6 +119,9 @@ impl Assets {
export: load_png(include_bytes!("../assets/export-2-svgrepo-com.png")),
play: load_png(include_bytes!("../assets/play-1003-svgrepo-com.png")),
pause: load_png(include_bytes!("../assets/pause-1006-svgrepo-com.png")),
// Log
hex: load_png(include_bytes!("../assets/hex-svgrepo-com.png")),
}
}

View file

@ -1,4 +1,4 @@
use crate::action_buttons::{base_or_custom_action, custom_action_buttons};
use crate::action_buttons::{base_or_modified_action, custom_action_buttons};
use crate::client_state::{ActiveDialog, NO_UPDATE, RenderResult, StateUpdate};
use crate::collect_ui::CollectResources;
use crate::construct_ui::{ConstructionPayment, ConstructionProject};
@ -241,7 +241,7 @@ fn collect_resources_button<'a>(rc: &'a RenderContext, city: &'a City) -> Option
false,
MultilineText::of(rc, "Collect Resources"),
Box::new(move || {
base_or_custom_action(rc, &actions, "Collect resources", |custom| {
base_or_modified_action(rc, &actions, "Collect resources", |custom| {
let i = possible_resource_collections(
rc.game,
city.position,
@ -345,27 +345,27 @@ pub(crate) fn draw_city(rc: &RenderContext, city: &City) -> RenderResult {
{
draw_selected_state(rc, c, 15., h)?;
} else {
draw_mood_state(rc, city, c);
let mood = match &rc.state.active_dialog {
ActiveDialog::IncreaseHappiness(increase) => {
let steps = increase
.steps
.iter()
.find(|(p, _)| p == &city.position)
.map_or(&0, |(_, s)| s);
&city.mood_state.clone().add(*steps)
}
_ => &city.mood_state,
};
draw_mood_state(rc, c, mood);
}
let i = draw_wonders(rc, city, c, owner, highlighted)?;
draw_buildings(rc, city, c, highlighted, i)
}
fn draw_mood_state(rc: &RenderContext, city: &City, c: Vec2) {
let state = &rc.state;
let mood = match &state.active_dialog {
ActiveDialog::IncreaseHappiness(increase) => {
let steps = increase
.steps
.iter()
.find(|(p, _)| p == &city.position)
.map_or(&0, |(_, s)| s);
&city.mood_state.clone().add(*steps)
}
_ => &city.mood_state,
};
let t = match mood {
pub(crate) fn draw_mood_state(rc: &RenderContext, c: Vec2, mood_state: &MoodState) {
let t = match mood_state {
MoodState::Happy => Some(&rc.assets().resources[&ResourceType::MoodTokens]),
MoodState::Neutral => None,
MoodState::Angry => Some(&rc.assets().angry),
@ -375,7 +375,7 @@ fn draw_mood_state(rc: &RenderContext, city: &City, c: Vec2) {
draw_scaled_icon(
rc,
t,
&format!("Happiness: {}", city.mood_state),
&format!("Happiness: {mood_state}"),
c + vec2(-size / 2., -size / 2.),
size,
);

View file

@ -111,11 +111,11 @@ impl ActiveDialog {
ActiveDialog::StructuresRequest(d, r) => {
if let Some(b) = d {
let v = vec!["Click on a building to influence its culture".to_string()];
if let PlayingActionType::Custom(c) = &b.action_type {
if let PlayingActionType::Special(c) = &b.action_type {
let mut r = v.clone();
r.extend(event_help(
rc,
&rc.shown_player.custom_action_info(*c).event_origin,
&rc.shown_player.special_action_info(c).event_origin,
));
}
v
@ -586,17 +586,17 @@ impl State {
}
pub(crate) fn draw_text(&self, text: &str, x: f32, y: f32) {
self.draw_text_with_color(text, x, y, BLACK);
self.draw_text_ex(text, x, y, BLACK, FONT_SIZE);
}
pub(crate) fn draw_text_with_color(&self, text: &str, x: f32, y: f32, color: Color) {
pub(crate) fn draw_text_ex(&self, text: &str, x: f32, y: f32, color: Color, font_size: u16) {
draw_text_ex(
text,
x,
y,
TextParams {
font: Some(&self.assets.font),
font_size: FONT_SIZE,
font_size,
color,
..Default::default()
},

View file

@ -1,4 +1,4 @@
use crate::action_buttons::base_or_custom_action;
use crate::action_buttons::base_or_modified_action;
use crate::client_state::{ActiveDialog, NO_UPDATE, RenderResult, StateUpdate};
use crate::dialog_ui::BaseOrCustomDialog;
use crate::payment_ui::{Payment, payment_dialog};
@ -66,7 +66,7 @@ pub(crate) fn open_increase_happiness_dialog(
actions: &[PlayingActionType],
init: impl Fn(IncreaseHappinessConfig) -> IncreaseHappinessConfig,
) -> RenderResult {
base_or_custom_action(rc, actions, "Increase happiness", |custom| {
base_or_modified_action(rc, actions, "Increase happiness", |custom| {
ActiveDialog::IncreaseHappiness(init(IncreaseHappinessConfig::new(rc, custom)))
})
}

View file

@ -1,6 +1,6 @@
use std::f32::consts::PI;
use crate::layout_ui::draw_scaled_icon;
use crate::layout_ui::{FONT_SIZE, draw_scaled_icon};
use crate::render_context::RenderContext;
use hex2d::{Coordinate, Spacing};
use macroquad::color::Color;
@ -58,12 +58,13 @@ pub(crate) fn draw_hex(
}
draw_hexagon(c.x, c.y, SIZE, 2.0, false, DARKGRAY, overlay);
let text_y = c.y - 35.0;
rc.draw_text_with_color(&p.to_string(), c.x - 30.0, text_y, text_color);
rc.draw_text_with_color(
rc.draw_text_ex(&p.to_string(), c.x - 30.0, text_y, text_color, FONT_SIZE);
rc.draw_text_ex(
&block_for_position(rc.game, p).0.to_string(),
c.x + 10.0,
text_y,
text_color,
FONT_SIZE,
);
}

View file

@ -26,6 +26,7 @@ mod hex_ui;
mod influence_ui;
mod info_ui;
mod layout_ui;
mod log_collector;
mod log_ui;
mod map_ui;
mod move_ui;

118
client/src/log_collector.rs Normal file
View file

@ -0,0 +1,118 @@
use crate::log_ui::{LogBody, LogEntry, multiline_label};
use crate::render_context::RenderContext;
use server::action::Action;
use server::events::EventOrigin;
use server::game_setup::setup_event_origin;
use server::log::{ActionLogAge, TurnType};
use server::status_phase::StatusPhaseStateType;
struct LogCollector {
log_entries: Vec<LogEntry>,
active_origin: Option<EventOrigin>,
}
impl LogCollector {
fn new() -> Self {
Self {
log_entries: Vec::new(),
active_origin: None,
}
}
fn add_log_entry(&mut self, body: LogBody, indent: usize) {
self.log_entries
.push(LogEntry::new(body, self.active_origin.clone(), indent));
}
fn add_message(&mut self, message: &str, indent: usize) {
self.add_log_entry(LogBody::Message(message.to_string()), indent);
}
}
pub(crate) fn collect_log_entries(rc: &RenderContext) -> Vec<LogEntry> {
let mut c = LogCollector::new();
for age in &rc.game.log {
if age.age == 0 {
c.add_message("Game Start", 0);
}
for round in &age.rounds {
if round.round > 0 {
c.add_message(&format!("Age {}, Round {}", age.age, round.round), 0);
}
for turn in &round.turns {
c.active_origin = None;
let indent = match turn.turn_type {
TurnType::Player(p) => {
c.add_log_entry(
LogBody::PlayerTurn {
age: age.age,
round: round.round,
player: p,
},
1,
);
2
}
TurnType::Setup(p) => {
c.active_origin = Some(setup_event_origin());
c.add_log_entry(
LogBody::PlayerSetup {
player: p,
civilization: rc.game.player(p).civilization.name.clone(),
},
1,
);
2
}
TurnType::StatusPhase(t) => status_phase_title(age, t, &mut c),
};
for action in &turn.actions {
let origin = &action.origin;
if origin.is_some() {
c.active_origin.clone_from(origin);
}
let indent = if matches!(action.action, Action::StartTurn) {
indent
} else {
c.add_log_entry(LogBody::Action(action.clone()), indent);
indent + 1
};
for item in &action.items {
c.add_log_entry(LogBody::Item(item.clone()), indent);
}
for message in &action.log {
// Simulate multiline labels to get accurate line count
multiline_label(rc.state, message, max_width(rc), |label: &str| {
c.add_message(label, indent);
});
}
}
}
}
}
c.log_entries
}
fn status_phase_title(age: &ActionLogAge, t: StatusPhaseStateType, c: &mut LogCollector) -> usize {
if matches!(t, StatusPhaseStateType::CompleteObjectives) {
c.add_message(&format!("Status Phase (Age {})", age.age), 2);
}
c.add_message(
match t {
StatusPhaseStateType::CompleteObjectives => "Complete Objectives",
StatusPhaseStateType::FreeAdvance => "Free Advance",
StatusPhaseStateType::DrawCards => "Draw Cards",
StatusPhaseStateType::RazeSize1City => "Raze Size 1 City",
StatusPhaseStateType::ChangeGovernmentType => "Change Government Type",
StatusPhaseStateType::DetermineFirstPlayer => "Determine First Player",
},
3,
);
4
}
fn max_width(rc: &RenderContext) -> f32 {
rc.state.screen_size.x - 300.
}

View file

@ -1,24 +1,47 @@
use crate::city_ui::draw_mood_state;
use crate::client_state::{ActiveDialog, NO_UPDATE, RenderResult, State, StateUpdate};
use crate::layout_ui::bottom_center_texture;
use crate::layout_ui::{FONT_SIZE, bottom_center_texture, draw_scaled_icon};
use crate::log_collector::collect_log_entries;
use crate::render_context::RenderContext;
use macroquad::math::vec2;
use server::log::TurnType;
use macroquad::math::{Vec2, vec2};
use macroquad::prelude::{BLACK, Color, Texture2D};
use server::action::Action;
use server::card::hand_card_message;
use server::content::persistent_events::EventResponse;
use server::events::EventOrigin;
use server::log::{
ActionLogAction, ActionLogBalance, ActionLogEntry, ActionLogEntryMove, ActionLogEntryStructure,
ActionLogIncidentToken, ActionLogItem,
};
use server::movement::MovementAction;
use server::playing_actions::PlayingAction;
use server::position::Position;
use server::resource_pile::ResourcePile;
use server::structure::Structure;
use server::unit::Units;
#[derive(Clone, Debug)]
pub(crate) enum LogBody {
Message(String),
Item(ActionLogItem),
PlayerSetup { player: usize, civilization: String },
PlayerTurn { age: u32, round: u32, player: usize },
Action(ActionLogAction),
}
#[derive(Clone, Debug)]
pub(crate) struct LogEntry {
pub age: Option<String>,
pub round: Option<String>,
pub name: String,
pub message: String,
body: LogBody,
active_origin: Option<EventOrigin>,
indent: usize,
}
impl LogEntry {
pub(crate) fn new(age: Option<u32>, round: Option<u32>, name: &str, message: String) -> Self {
pub(crate) fn new(body: LogBody, active_origin: Option<EventOrigin>, indent: usize) -> Self {
LogEntry {
age: age.map(|a| a.to_string()),
round: round.map(|r| r.to_string()),
name: name.to_string(),
message,
body,
active_origin,
indent,
}
}
}
@ -35,47 +58,7 @@ impl LogDialog {
pub(crate) fn new(rc: &RenderContext) -> Self {
let lines_per_page = (rc.state.screen_size.y - 150.) as usize / 25;
// Build structured log entries with age, round, player, and message
let mut log_entries = Vec::new();
for age in &rc.game.log {
for round in &age.rounds {
for turn in &round.turns {
for action in &turn.actions {
for message in &action.log {
// Simulate multiline labels to get accurate line count
multiline_label(
rc.state,
message,
Self::max_width(rc),
|label: &str| {
log_entries.push(match turn.turn_type {
TurnType::Player(p) => LogEntry::new(
Some(age.age),
Some(round.round),
&rc.game.player_name(p),
label.to_string(),
),
TurnType::Setup => LogEntry::new(
None,
None,
"Game Started",
label.to_string(),
),
TurnType::StatusPhase => LogEntry::new(
None,
Some(round.round),
"Status Phase",
label.to_string(),
),
});
},
);
}
}
}
}
}
let log_entries = collect_log_entries(rc);
let total_lines = log_entries.len();
let pages = if total_lines == 0 {
@ -91,68 +74,18 @@ impl LogDialog {
log_entries,
}
}
fn max_width(rc: &RenderContext) -> f32 {
rc.state.screen_size.x - 300.
}
}
pub(crate) fn show_log(rc: &RenderContext, d: &LogDialog) -> RenderResult {
let state = &rc.state;
let state = rc.state;
// Use the pre-calculated log entries
let start = d.current_page * d.lines_per_page;
let end = usize::min(start + d.lines_per_page, d.log_entries.len());
let mut y = 0.;
// Draw column headers
let age_pos = vec2(30., 20.);
let round_pos = vec2(80., 20.);
let player_pos = vec2(140., 20.);
let message_pos = vec2(280., 20.);
rc.draw_text("Age", age_pos.x, age_pos.y);
rc.draw_text("Round", round_pos.x, round_pos.y);
rc.draw_text("Player", player_pos.x, player_pos.y);
rc.draw_text("Message", message_pos.x, message_pos.y);
y += 1.5; // Add some space after headers
// Track previous values to only show when they change
let mut prev_age: Option<String> = None;
let mut prev_round: Option<String> = None;
let mut prev_name: Option<String> = None;
let mut y = 1.5;
for entry in &d.log_entries[start..end] {
let message_text = &entry.message;
// Calculate positions for each column
let age_pos = vec2(30., y * 25. + 20.);
let round_pos = vec2(80., y * 25. + 20.);
let player_pos = vec2(140., y * 25. + 20.);
let message_pos = vec2(280., y * 25. + 20.);
// Draw each column
if let Some(age) = &entry.age
&& entry.age != prev_age
{
rc.draw_text(age, age_pos.x, age_pos.y);
}
if let Some(round) = &entry.round
&& entry.round != prev_round
{
rc.draw_text(round, round_pos.x, round_pos.y);
}
if Some(&entry.name) != prev_name.as_ref() {
rc.draw_text(&entry.name, player_pos.x, player_pos.y);
}
rc.draw_text(message_text, message_pos.x, message_pos.y);
// Update previous values
prev_age.clone_from(&entry.age);
prev_round.clone_from(&entry.round);
prev_name = Some(entry.name.clone());
draw_line(rc, y, entry);
y += 1.;
}
// Bottom center navigation
@ -199,6 +132,287 @@ pub(crate) fn show_log(rc: &RenderContext, d: &LogDialog) -> RenderResult {
NO_UPDATE
}
fn draw_line(rc: &RenderContext, y: f32, entry: &LogEntry) {
let message_pos = vec2(20. + entry.indent as f32 * 20.0, y * 25. + 20.);
let mut drawer = RichTextDrawer::new(rc, message_pos);
match &entry.body {
LogBody::Message(m) => rc.draw_text(m, message_pos.x, message_pos.y),
LogBody::Item(item) => {
drawer.player(item.player);
let balance = item.entry.balance();
if let Some(b) = &balance {
drawer.text(match b {
ActionLogBalance::Gain => "gains",
ActionLogBalance::Loss => "loses",
ActionLogBalance::Pay => "pays",
});
}
draw_item(&mut drawer, item);
if entry
.active_origin
.as_ref()
.is_none_or(|o| o != &item.origin)
{
drawer.modifier(&item.origin.name(drawer.rc.game), balance);
}
item.modifiers.iter().for_each(|m| {
drawer.modifier(&m.name(drawer.rc.game), balance);
});
}
LogBody::PlayerSetup {
player,
civilization,
} => {
drawer.player(*player);
drawer.text(&format!("plays as {civilization}"));
}
LogBody::PlayerTurn { age, round, player } => {
drawer.player(*player);
drawer.text(&format!("starts their turn (Age {age}, Round {round})"));
}
LogBody::Action(a) => {
drawer.player(a.player);
draw_action_log_entry(&mut drawer, a);
}
}
}
struct RichTextDrawer<'a> {
rc: &'a RenderContext<'a>,
current_pos: Vec2,
space: f32,
}
impl RichTextDrawer<'_> {
fn new<'a>(rc: &'a RenderContext<'_>, start_pos: Vec2) -> RichTextDrawer<'a> {
RichTextDrawer {
rc,
current_pos: start_pos,
space: rc.state.measure_text(" ").width,
}
}
fn text(&mut self, text: &str) {
self.text_ex(text, BLACK, FONT_SIZE);
}
fn text_ex(&mut self, text: &str, color: Color, font_size: u16) {
self.rc.draw_text_ex(
text,
self.current_pos.x,
self.current_pos.y,
color,
font_size,
);
self.current_pos.x += self.rc.state.measure_text(text).width + self.space;
}
fn modifier(&mut self, modifier: &str, balance: Option<&ActionLogBalance>) {
let verb = match balance {
None | Some(ActionLogBalance::Gain) => "using",
Some(ActionLogBalance::Loss) => "to",
Some(ActionLogBalance::Pay) => "for",
};
self.text(&format!("{verb} {modifier}"));
}
fn icon(&mut self, texture: &Texture2D) {
self.icon_with_size(texture, 20.0);
}
fn icon_with_size(&mut self, texture: &Texture2D, size: f32) {
draw_scaled_icon(
&self.rc.no_icon_background(),
texture,
"",
vec2(self.current_pos.x, self.current_pos.y - size / 2.0 - 5.0),
size,
);
self.current_pos.x += size + self.space;
}
fn player(&mut self, player: usize) {
self.text_ex(
&self.rc.game.player_name(player),
self.rc.player_color(player),
FONT_SIZE,
);
self.current_pos.x += self.space;
}
fn at_location(&mut self, position: Position) {
self.text("at");
self.location(position);
}
fn location(&mut self, position: Position) {
self.icon_with_size(&self.rc.assets().hex, 35.0);
self.current_pos.x -= 31.0;
self.text_ex(&format!("{position}"), BLACK, 17);
}
fn resources(&mut self, resources: &ResourcePile) {
for (resource, amount) in resources.clone() {
if amount > 0
&& let Some(texture) = self.rc.assets().resources.get(&resource)
{
self.icon(texture);
self.text(&amount.to_string());
}
}
}
fn units(&mut self, units: &Units) {
for (unit, amount) in units.clone() {
if amount > 0 {
let texture = self.rc.assets().unit(unit, self.rc.shown_player);
self.icon(texture);
let mut u = Units::empty();
for _ in 0..amount {
u += &unit;
}
self.text(&u.to_string(Some(self.rc.game)));
}
}
}
}
fn draw_item(drawer: &mut RichTextDrawer, item: &ActionLogItem) {
match &item.entry {
ActionLogEntry::Action { balance: _, amount } => {
if let Some(a) = amount {
drawer.text(&a.to_string());
}
drawer.icon(&drawer.rc.assets().end_turn);
}
ActionLogEntry::Resources {
resources,
balance: _,
} => {
drawer.resources(resources);
}
ActionLogEntry::Advance {
advance,
balance: _,
incident_token,
} => {
drawer.icon(&drawer.rc.assets().advances);
drawer.text(advance.name(drawer.rc.game));
if let ActionLogIncidentToken::Take(t) = incident_token {
if *t > 0 {
drawer.text(&format!("and take an event token ({t} left)"));
} else {
drawer.text("and take an event token (triggering an incident)");
}
}
}
ActionLogEntry::Units {
units,
balance: _,
position,
} => {
drawer.units(units);
drawer.at_location(*position);
}
ActionLogEntry::Structure(s) => {
draw_structure(drawer, item, s);
}
ActionLogEntry::HandCard { card, from, to } => {
let (_, message) = hand_card_message(drawer.rc.game, card, from, to);
drawer.text(&message);
}
ActionLogEntry::MoodChange { city, mood } => {
drawer.text("City");
drawer.at_location(*city);
drawer.text(&format!("becomes {mood}"));
let c = center(drawer.current_pos);
drawer
.rc
.draw_circle(c, RADIUS, drawer.rc.player_color(item.player));
draw_mood_state(drawer.rc, c, mood);
drawer.current_pos.x += 35.0;
}
ActionLogEntry::Move(m) => draw_move(drawer, m),
ActionLogEntry::Explore { tiles } => {
drawer.text("explores:");
for (p, t) in tiles {
drawer.location(*p);
drawer.text(&format!("is {t}"));
}
}
}
}
fn draw_move(drawer: &mut RichTextDrawer, m: &ActionLogEntryMove) {
let game = drawer.rc.game;
let t = game
.map
.get(m.destination)
.expect("the destination position should be on the map");
let (verb, suffix) = if game.map.is_sea(m.start) {
if t.is_unexplored() || t.is_water() {
("sailed", "")
} else {
("disembarked", "")
}
} else if m.embark_carrier_id.is_some() {
("embarked", "")
} else if m.start.is_neighbor(m.destination) {
("marched", "")
} else {
("marched", " on roads")
};
drawer.text(verb);
drawer.units(&m.units);
drawer.text("from");
drawer.location(m.start);
drawer.text("to");
drawer.location(m.destination);
if !suffix.is_empty() {
drawer.text(suffix);
}
}
fn draw_structure(drawer: &mut RichTextDrawer, item: &ActionLogItem, s: &ActionLogEntryStructure) {
// Draw structure icon or circle
let c = center(drawer.current_pos);
let r = RADIUS;
match &s.structure {
Structure::CityCenter => {
drawer
.rc
.draw_circle(c, r, drawer.rc.player_color(item.player));
drawer.current_pos.x += 35.0;
drawer.text("City");
}
Structure::Building(b) => {
draw_scaled_icon(drawer.rc, &drawer.rc.assets().buildings[b], "", c, r);
drawer.current_pos.x += 35.0;
drawer.text(b.name());
}
Structure::Wonder(w) => {
draw_scaled_icon(drawer.rc, &drawer.rc.assets().wonders[w], "", c, r);
drawer.current_pos.x += 35.0;
drawer.text(&w.name());
}
}
drawer.at_location(s.position);
if let Some(port_pos) = s.port_position {
drawer.text(" at the water tile");
drawer.at_location(port_pos);
}
}
const RADIUS: f32 = 15.0;
fn center(message_pos: Vec2) -> Vec2 {
vec2(message_pos.x + 15.0, message_pos.y - RADIUS / 2.0)
}
pub(crate) fn multiline_label(state: &State, label: &str, len: f32, mut print: impl FnMut(&str)) {
let mut line = String::new();
label.split(' ').for_each(|s| {
@ -251,3 +465,102 @@ impl MultilineText {
});
}
}
fn draw_action_log_entry(drawer: &mut RichTextDrawer, a: &ActionLogAction) {
match &a.action {
Action::Playing(p) => draw_playing_action(drawer, p, a),
Action::Movement(m) => match m {
MovementAction::Move(_) => {
drawer.text("performs a move action");
}
MovementAction::Stop => {
drawer.text("stops movement");
}
},
Action::Response(r) => draw_response_action(drawer, r),
Action::Undo => panic!("Unexpected undo in log"),
Action::Redo => panic!("Unexpected redo in log"),
Action::StartTurn => panic!("Unexpected start turn in log"),
Action::ChooseCivilization(c) => {
drawer.text(&format!("Choose Civilization: {c}"));
}
}
}
fn draw_response_action(drawer: &mut RichTextDrawer, r: &EventResponse) {
match r {
EventResponse::SelectAdvance(_) => drawer.text("selects advance"),
EventResponse::Payment(_) => drawer.text("selects payment"),
EventResponse::ResourceReward(_) => drawer.text("receives"),
EventResponse::SelectPlayer(p) => drawer.text(&format!(
"selects player: {}",
drawer.rc.game.player_name(*p)
)),
EventResponse::SelectPositions(p) => drawer.text(&format!("selects positions: {p:?}")),
EventResponse::SelectUnitType(u) => {
drawer.text(&format!("select unit type: {}", u.name(drawer.rc.game)));
}
EventResponse::SelectUnits(_u) => drawer.text("selects units"),
EventResponse::SelectHandCards(_h) => drawer.text("selects hand cards"),
EventResponse::SelectStructures(_s) => drawer.text("select structures"),
EventResponse::Bool(b) => {
if *b {
drawer.text("accepts");
} else {
drawer.text("declines");
}
}
EventResponse::ChangeGovernmentType(c) => {
drawer.text(&format!("changes government to {}", c.new_government));
}
EventResponse::ExploreResolution(_) => drawer.text("chooses rotation"),
}
}
fn draw_playing_action(drawer: &mut RichTextDrawer, p: &PlayingAction, a: &ActionLogAction) {
match p {
PlayingAction::Advance(_) => {
drawer.text("advances");
}
PlayingAction::FoundCity { .. } => {
drawer.text("founds a city");
}
PlayingAction::Construct(_) => {
drawer.text("builds");
}
PlayingAction::Collect(c) => {
drawer.text("collects");
drawer.at_location(c.city_position);
}
PlayingAction::Recruit(_) => {
drawer.text("recruits");
}
PlayingAction::IncreaseHappiness(_) => {
drawer.text("increases happiness");
}
PlayingAction::InfluenceCultureAttempt(_) => {
drawer.text("attempts cultural influence");
}
PlayingAction::Custom(c) => {
drawer.text(&format!(
"starts {}",
a.items[0].origin.name(drawer.rc.game)
));
if let Some(pos) = c.city {
drawer.at_location(pos);
}
}
PlayingAction::ActionCard(a) => {
drawer.text(&format!(
"plays Action Card: {}",
drawer.rc.game.cache.get_action_card(*a).name()
));
}
PlayingAction::WonderCard(w) => {
drawer.text(&format!("plays Wonder Card: {}", w.name()));
}
PlayingAction::EndTurn => {
drawer.text("ends their turn");
}
}
}

View file

@ -27,7 +27,7 @@ use server::player::Player;
use server::playing_actions::PlayingAction;
use server::position::Position;
use server::resource::ResourceType;
use server::status_phase::get_status_phase;
use server::status_phase::{get_status_phase, status_phase_type};
use server::victory_points::victory_points_parts;
pub(crate) fn player_select(rc: &RenderContext) -> RenderResult {
@ -68,7 +68,7 @@ pub(crate) fn player_select(rc: &RenderContext) -> RenderResult {
}
let tooltip = if rc.state.control_player.is_some_and(|p| p == pl.index) {
format!("{pl} (You)")
format!("{} (You)", pl.get_name())
} else {
pl.get_name()
};
@ -185,7 +185,7 @@ pub(crate) fn show_top_left(rc: &RenderContext, painter: &mut ColumnLabelPainter
_ => painter.label(&format!("Age {}", game.age)),
}
if let Some(s) = get_status_phase(game) {
painter.label(&format!("Status Phase: {s}"));
painter.label(&format!("Status Phase: {}", status_phase_type(s)));
} else {
painter.label(&format!("Round {}", game.round));
}

View file

@ -2,10 +2,10 @@ use crate::assets::Assets;
use crate::client_state::{CameraMode, RenderResult, State};
use crate::layout_ui::{IconBackground, limit_str};
use crate::payment_ui::Payment;
use macroquad::color::{Color, PINK, YELLOW};
use macroquad::color::{Color, PINK};
use macroquad::input::mouse_position;
use macroquad::math::{Vec2, bool};
use macroquad::prelude::{BLACK, LIME, Rect, SKYBLUE, WHITE, set_camera};
use macroquad::prelude::{BLACK, LIME, ORANGE, Rect, SKYBLUE, WHITE, set_camera};
use server::game::Game;
use server::payment::PaymentOptions;
use server::player::Player;
@ -159,7 +159,7 @@ impl RenderContext<'_> {
return BLACK;
}
match player_index {
0 => YELLOW,
0 => ORANGE,
1 => PINK,
2 => SKYBLUE,
3 => LIME,
@ -187,9 +187,9 @@ impl RenderContext<'_> {
}
}
pub(crate) fn draw_text_with_color(&self, text: &str, x: f32, y: f32, color: Color) {
pub(crate) fn draw_text_ex(&self, text: &str, x: f32, y: f32, color: Color, font_size: u16) {
if self.stage.is_main() {
self.state.draw_text_with_color(text, x, y, color);
self.state.draw_text_ex(text, x, y, color, font_size);
}
}

View file

@ -1,6 +1,8 @@
use crate::client_state::{NO_UPDATE, RenderResult, StateUpdate};
use crate::dialog_ui::{OkTooltip, cancel_button, ok_button};
use crate::layout_ui::{ICON_SIZE, UI_BACKGROUND, bottom_center_anchor, bottom_center_texture};
use crate::layout_ui::{
FONT_SIZE, ICON_SIZE, UI_BACKGROUND, bottom_center_anchor, bottom_center_texture,
};
use crate::render_context::RenderContext;
use macroquad::color::{BLACK, BLUE, Color, WHITE};
use macroquad::math::{Vec2, bool, vec2};
@ -48,11 +50,12 @@ pub(crate) fn count_dialog<C, O: HasCountSelectableObject>(
rc.draw_circle(point, SELECT_RADIUS, UI_BACKGROUND);
draw(&rc.no_icon_background(), o, point);
let current_pos = vec2(x + 13., -40.) + anchor + offset;
rc.draw_text_with_color(
rc.draw_text_ex(
&format!("{}", c.current),
current_pos.x,
current_pos.y,
BLACK,
FONT_SIZE,
);
let small = &rc.small_background();
if c.current > c.min

View file

@ -21,7 +21,7 @@ dir = "server"
[tasks.update-tests]
description = "Run server tests and update JSON files"
run = 'cargo test --jobs 5 {{arg(name="test", default="")}}'
run = 'cargo nextest run {{arg(name="test", default="")}}'
env = { UPDATE_EXPECTED = "true", RUSTFLAGS = '' }
dir = "server"

View file

@ -6,7 +6,8 @@ use crate::combat::{Combat, update_combat_strength};
use crate::combat_listeners::CombatStrength;
use crate::content::ability::{Ability, AbilityBuilder};
use crate::content::custom_actions::{
CustomActionActionExecution, CustomActionExecution, CustomActionInfo,
CustomActionActionExecution, PlayingActionModifier, SpecialAction, SpecialActionExecution,
SpecialActionInfo,
};
use crate::content::persistent_events::{
AdvanceRequest, EventResponse, HandCardsRequest, MultiRequest, PaymentRequest,
@ -35,7 +36,6 @@ pub(crate) type AbilityInitializerWithPrioDelta = Arc<dyn Fn(&mut Game, usize, i
pub(crate) struct SelectedChoice<A, C> {
pub player_index: usize,
pub player_name: String,
pub origin: EventOrigin,
pub actively_selected: bool,
pub choices: A,
@ -46,7 +46,6 @@ impl<A, C> SelectedChoice<A, C> {
pub fn new(p: &EventPlayer, actively_selected: bool, choices: A, choice: C) -> Self {
Self {
player_index: p.index,
player_name: p.name.clone(),
origin: p.origin.clone(),
actively_selected,
choices,
@ -55,15 +54,11 @@ impl<A, C> SelectedChoice<A, C> {
}
pub fn player(&self) -> EventPlayer {
EventPlayer::new(
self.player_index,
self.player_name.clone(),
self.origin.clone(),
)
EventPlayer::new(self.player_index, self.origin.clone())
}
pub fn other_player(&self, player_index: usize, game: &Game) -> EventPlayer {
EventPlayer::from_player(player_index, game, self.origin.clone())
pub fn other_player(&self, player_index: usize) -> EventPlayer {
EventPlayer::new(player_index, self.origin.clone())
}
pub fn log(&self, game: &mut Game, message: &str) {
@ -181,7 +176,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
.add_initializer(move |game, player_index, prio_delta| {
initializer(
game,
&EventPlayer::from_player(player_index, game, key.clone()),
&EventPlayer::new(player_index, key.clone()),
prio_delta,
);
});
@ -194,10 +189,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
{
let key = self.get_key().clone();
self.builder().add_deinitializer(move |game, player_index| {
deinitializer(
game,
&EventPlayer::from_player(player_index, game, key.clone()),
);
deinitializer(game, &EventPlayer::new(player_index, key.clone()));
});
self
}
@ -209,10 +201,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
let key = self.get_key().clone();
self.builder()
.add_once_initializer(move |game, player_index| {
initializer(
game,
&EventPlayer::from_player(player_index, game, key.clone()),
);
initializer(game, &EventPlayer::new(player_index, key.clone()));
});
self
}
@ -224,10 +213,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
let key = self.get_key().clone();
self.builder()
.add_once_deinitializer(move |game, player_index| {
deinitializer(
game,
&EventPlayer::from_player(player_index, game, key.clone()),
);
deinitializer(game, &EventPlayer::new(player_index, key.clone()));
});
self
}
@ -972,10 +958,10 @@ pub(crate) trait AbilityInitializerSetup: Sized {
) -> Self {
let name = self.name();
let desc = self.description();
self.add_custom_action_execution(
action,
self.add_special_action_execution(
SpecialAction::Custom(action),
cost,
CustomActionExecution::Action(CustomActionActionExecution::new(
SpecialActionExecution::Action(CustomActionActionExecution::new(
ability(Ability::builder(&name, &desc)).build(),
Arc::new(can_play),
None,
@ -993,10 +979,10 @@ pub(crate) trait AbilityInitializerSetup: Sized {
) -> Self {
let name = self.name();
let desc = self.description();
self.add_custom_action_execution(
action,
self.add_special_action_execution(
SpecialAction::Custom(action),
cost,
CustomActionExecution::Action(CustomActionActionExecution::new(
SpecialActionExecution::Action(CustomActionActionExecution::new(
ability(Ability::builder(&name, &desc)).build(),
Arc::new(can_play),
Some(Arc::new(city_checker)),
@ -1006,25 +992,29 @@ pub(crate) trait AbilityInitializerSetup: Sized {
fn add_action_modifier(
self,
action: CustomActionType,
modifier: PlayingActionModifier,
info: impl Fn(ActionCostOncePerTurnBuilder) -> ActionCostOncePerTurn + Send + Sync + 'static,
base_action: PlayingActionType,
) -> Self {
self.add_custom_action_execution(action, info, CustomActionExecution::Modifier(base_action))
self.add_special_action_execution(
SpecialAction::Modifier(modifier),
info,
SpecialActionExecution::Modifier(base_action),
)
}
fn add_custom_action_execution(
fn add_special_action_execution(
self,
action: CustomActionType,
action: SpecialAction,
cost: impl Fn(ActionCostOncePerTurnBuilder) -> ActionCostOncePerTurn + Send + Sync + 'static,
execution: CustomActionExecution,
execution: SpecialActionExecution,
) -> Self {
let deinitializer_action = action;
let exec = execution.clone();
self.add_initializer(move |game, player, _prio_delta| {
player.get_mut(game).custom_actions.insert(
player.get_mut(game).special_actions.insert(
action,
CustomActionInfo::new(
SpecialActionInfo::new(
action,
exec.clone(),
player.origin.clone(),
@ -1035,7 +1025,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
.add_deinitializer(move |game, player| {
player
.get_mut(game)
.custom_actions
.special_actions
.remove(&deinitializer_action);
})
}

View file

@ -24,7 +24,7 @@ use crate::playing_actions::{PlayingAction, PlayingActionType};
use crate::position::Position;
use crate::recruit::on_recruit;
use crate::resource::check_for_waste;
use crate::status_phase::play_status_phase;
use crate::status_phase::status_phase_response;
use crate::undo::{clean_patch, redo, to_serde_value, undo};
use crate::unit::units_killed;
use crate::victory_points::add_dynamic_victory_points;
@ -38,8 +38,7 @@ pub enum Action {
Response(EventResponse),
Undo,
Redo,
StartTurn, // created for trade routes
Setup, // Game setup
StartTurn, // created for trade routes and status phase
ChooseCivilization(String),
}
@ -264,7 +263,7 @@ pub(crate) fn execute_custom_phase_action(
CombatEnd(s) => {
on_end_combat(game, s);
}
StatusPhase(s) => play_status_phase(game, s),
StatusPhase(s) => status_phase_response(game, s),
TurnStart => game.on_start_turn(),
PayAction(a) => {
a.on_pay_action(game, player, game.current_event().origin_override.clone())?;
@ -354,24 +353,21 @@ pub(crate) fn gain_action(game: &mut Game, player: &EventPlayer) {
add_action_log_item(
game,
player.index,
ActionLogEntry::action(ActionLogBalance::Gain),
ActionLogEntry::action(ActionLogBalance::Gain, 1),
player.origin.clone(),
vec![],
);
player.log(game, "Gain 1 action");
}
pub(crate) fn lose_action(game: &mut Game, player: &EventPlayer) {
subtract_action(game, player);
player.log(game, "Lose 1 action");
subtract_action(game, player, ActionLogBalance::Loss);
}
pub(crate) fn pay_action(game: &mut Game, player: &EventPlayer) {
subtract_action(game, player);
player.log(game, "Pay 1 action");
subtract_action(game, player, ActionLogBalance::Pay);
}
fn subtract_action(game: &mut Game, player: &EventPlayer) {
fn subtract_action(game: &mut Game, player: &EventPlayer, balance: ActionLogBalance) {
if game.actions_left == 0 && game.context == GameContext::Replay {
return;
}
@ -380,7 +376,7 @@ fn subtract_action(game: &mut Game, player: &EventPlayer) {
add_action_log_item(
game,
player.index,
ActionLogEntry::action(ActionLogBalance::Loss),
ActionLogEntry::action(balance, 1),
player.origin.clone(),
vec![],
);

View file

@ -1,5 +1,5 @@
use crate::advance::base_advance_cost;
use crate::content::custom_actions::CustomActionType;
use crate::content::custom_actions::SpecialAction;
use crate::events::{EventOrigin, check_event_origin};
use crate::game::{Game, GameContext};
use crate::payment::PaymentOptions;
@ -81,12 +81,12 @@ impl ActionCost {
}
pub(crate) struct ActionCostOncePerTurnBuilder {
action: CustomActionType,
action: SpecialAction,
}
impl ActionCostOncePerTurnBuilder {
#[must_use]
pub fn new(action: CustomActionType) -> Self {
pub fn new(action: SpecialAction) -> Self {
Self { action }
}
@ -105,19 +105,19 @@ impl ActionCostOncePerTurnBuilder {
#[must_use]
pub fn once_per_turn_mutually_exclusive(
self,
mutually_exclusive: CustomActionType,
mutually_exclusive: SpecialAction,
) -> ActionCostBuilder {
ActionCostBuilder::new(Some(mutually_exclusive))
}
}
pub(crate) struct ActionCostBuilder {
once_per_turn: Option<CustomActionType>,
once_per_turn: Option<SpecialAction>,
}
impl ActionCostBuilder {
#[must_use]
pub(crate) fn new(once_per_turn: Option<CustomActionType>) -> Self {
pub(crate) fn new(once_per_turn: Option<SpecialAction>) -> Self {
Self { once_per_turn }
}
@ -133,13 +133,13 @@ impl ActionCostBuilder {
}
pub(crate) struct ActionResourceCostBuilder {
once_per_turn: Option<CustomActionType>,
once_per_turn: Option<SpecialAction>,
free: bool,
}
impl ActionResourceCostBuilder {
#[must_use]
fn new(once_per_turn: Option<CustomActionType>, free: bool) -> ActionResourceCostBuilder {
fn new(once_per_turn: Option<SpecialAction>, free: bool) -> ActionResourceCostBuilder {
ActionResourceCostBuilder {
once_per_turn,
free,
@ -187,14 +187,14 @@ impl ActionResourceCostBuilder {
#[derive(Clone, Debug, PartialEq)]
pub struct ActionCostOncePerTurn {
pub cost: ActionCost,
pub once_per_turn: Option<CustomActionType>,
pub once_per_turn: Option<SpecialAction>,
}
impl ActionCostOncePerTurn {
#[must_use]
pub(crate) fn new(
free: bool,
once_per_turn: Option<CustomActionType>,
once_per_turn: Option<SpecialAction>,
cost: ActionResourceCost,
) -> ActionCostOncePerTurn {
ActionCostOncePerTurn {

View file

@ -6,7 +6,7 @@ use crate::content::persistent_events::PersistentEventType;
use crate::events::{EventOrigin, EventPlayer};
use crate::game::Game;
use crate::incident::trigger_incident;
use crate::log::{ActionLogBalance, ActionLogEntry, add_action_log_item};
use crate::log::{ActionLogBalance, ActionLogEntry, ActionLogIncidentToken, add_action_log_item};
use crate::payment::PaymentOptions;
use crate::player::Player;
use crate::player_events::OnAdvanceInfo;
@ -285,27 +285,18 @@ pub(crate) fn do_advance(
p.advances.insert(advance);
let t = p.incident_tokens;
player.log(
game,
&format!(
"Gain {} {}",
advance.name(game),
if take_incident_token {
(if t > 1 {
format!("and take an event token ({} left)", t - 1)
} else {
"and take an event token (triggering an incident)".to_string()
})
.to_string()
} else {
"without taking an event token".to_string()
}
),
);
add_action_log_item(
game,
player_index,
ActionLogEntry::advance(advance, ActionLogBalance::Gain, take_incident_token),
ActionLogEntry::advance(
advance,
ActionLogBalance::Gain,
if take_incident_token {
ActionLogIncidentToken::Take(t - 1)
} else {
ActionLogIncidentToken::NoChange
},
),
player.origin.clone(),
vec![],
);
@ -391,7 +382,7 @@ pub(crate) fn execute_advance_action(
gain_advance_without_payment(
game,
advance,
&EventPlayer::from_player(player_index, game, advance_event_origin()),
&EventPlayer::new(player_index, advance_event_origin()),
a.payment.clone(),
true,
);
@ -456,13 +447,18 @@ pub(crate) fn remove_advance(game: &mut Game, advance: Advance, player: &EventPl
advance_bonus.resources(),
EventOrigin::Advance(advance),
vec![],
ActionLogBalance::Loss,
);
}
game.player_mut(player_index).advances.remove(advance);
add_action_log_item(
game,
player_index,
ActionLogEntry::advance(advance, ActionLogBalance::Loss, false),
ActionLogEntry::advance(
advance,
ActionLogBalance::Loss,
ActionLogIncidentToken::NoChange,
),
player.origin.clone(),
vec![],
);

View file

@ -5,7 +5,7 @@ use crate::card::validate_card_selection;
use crate::city::{City, MoodState};
use crate::collect::{Collect, available_collect_actions, possible_resource_collections};
use crate::construct::{Construct, available_buildings, new_building_positions};
use crate::content::custom_actions::{CustomAction, CustomActionType};
use crate::content::custom_actions::{CustomAction, CustomActionType, SpecialAction};
use crate::content::persistent_events::{
EventResponse, HandCardsRequest, MultiRequest, PersistentEventRequest, PersistentEventState,
PositionRequest, SelectedStructure, is_selected_structures_valid,
@ -195,7 +195,8 @@ fn base_actions(ai: &mut AiActions, game: &Game) -> Vec<(ActionType, Vec<Action>
}
for info in game.available_custom_actions(p.index) {
if info.action == CustomActionType::ImperialArmy {
let t = info.custom_action_type();
if t == CustomActionType::ImperialArmy {
// buggy
continue;
}
@ -212,12 +213,11 @@ fn base_actions(ai: &mut AiActions, game: &Game) -> Vec<(ActionType, Vec<Action>
vec![None]
};
let a = info.action;
for c in cities {
actions.push((
ActionType::Playing(PlayingActionType::Custom(a)),
ActionType::Playing(PlayingActionType::Special(info.action)),
vec![Action::Playing(PlayingAction::Custom(CustomAction::new(
a, c,
t, c,
)))],
));
}
@ -497,11 +497,11 @@ fn calculate_increase_happiness(
fn prefer_custom_action(actions: &[PlayingActionType]) -> PlayingActionType {
actions
.iter()
.find(|a| matches!(a, PlayingActionType::Custom(_)))
.find(|a| matches!(a, PlayingActionType::Special(SpecialAction::Modifier(_))))
.or_else(|| {
actions
.iter()
.find(|a| !matches!(a, PlayingActionType::Custom(_)))
.find(|a| !matches!(a, PlayingActionType::Special(SpecialAction::Modifier(_))))
})
.cloned()
.expect("expected at least one action type, either custom or base")

View file

@ -584,7 +584,7 @@ fn cities_in_land_range(
#[must_use]
pub(crate) fn get_barbarians_event_player(game: &Game, origin: &EventOrigin) -> EventPlayer {
let player = get_barbarians_player(game);
EventPlayer::new(player.index, player.get_name(), origin.clone())
EventPlayer::new(player.index, origin.clone())
}
///

View file

@ -4,7 +4,7 @@ use crate::city_pieces::Building;
use crate::civilization::Civilization;
use crate::content::ability::Ability;
use crate::content::advances::{AdvanceGroup, AdvanceGroupInfo};
use crate::content::custom_actions::CustomActionExecution;
use crate::content::custom_actions::SpecialActionExecution;
use crate::content::{
ability, action_cards, advances, civilizations, incidents, objective_cards, objectives, wonders,
};
@ -13,10 +13,9 @@ use crate::incident::Incident;
use crate::leader::{Leader, LeaderInfo};
use crate::objective_card::{Objective, ObjectiveCard};
use crate::special_advance::{SpecialAdvance, SpecialAdvanceInfo};
use crate::status_phase::StatusPhaseState::{ChangeGovernmentType, DetermineFirstPlayer};
use crate::status_phase::{
StatusPhaseState, complete_objectives, determine_first_player, draw_cards, free_advance,
get_status_phase, may_change_government, use_raze_city,
StatusPhaseStateType, complete_objectives, determine_first_player, draw_cards, free_advance,
get_status_phase, may_change_government, status_phase_type, use_raze_city,
};
use crate::tactics_card::TacticsCard;
use crate::wonder::{Wonder, WonderInfo};
@ -27,7 +26,7 @@ use std::collections::HashMap;
pub struct Cache {
all_abilities: Vec<Ability>,
abilities_by_name: HashMap<String, Ability>,
status_phase_handlers: HashMap<StatusPhaseState, Ability>,
status_phase_handlers: HashMap<StatusPhaseStateType, Ability>,
all_advance_groups: Vec<AdvanceGroupInfo>,
advance_groups_by_name: HashMap<AdvanceGroup, AdvanceGroupInfo>,
@ -129,7 +128,7 @@ impl Cache {
all_civilizations: civilizations::get_all_uncached()
.into_iter()
.filter(super::civilization::Civilization::can_choose)
.filter(Civilization::can_choose)
.sorted_by_key(|c| c.name.clone())
.collect_vec(),
civilizations_by_name: civilizations::get_all_uncached()
@ -220,8 +219,8 @@ impl Cache {
.get(name)
.map_or_else(
|| {
for c in game.player(game.active_player()).custom_actions.values() {
if let CustomActionExecution::Action(e) = &c.execution
for c in game.player(game.active_player()).special_actions.values() {
if let SpecialActionExecution::Action(e) = &c.execution
&& e.ability.name == name
{
return Some(t(&e.ability));
@ -229,7 +228,7 @@ impl Cache {
}
if let Some(p) = get_status_phase(game) {
return Some(t(self.status_phase_handler(p)));
return Some(t(self.status_phase_handler(&status_phase_type(p))));
}
None
},
@ -244,12 +243,8 @@ impl Cache {
}
#[must_use]
pub fn status_phase_handler(&self, p: &StatusPhaseState) -> &Ability {
match p {
DetermineFirstPlayer(_) => &self.status_phase_handlers[&DetermineFirstPlayer(0)],
ChangeGovernmentType(_) => &self.status_phase_handlers[&ChangeGovernmentType(false)],
_ => &self.status_phase_handlers[p],
}
pub fn status_phase_handler(&self, p: &StatusPhaseStateType) -> &Ability {
&self.status_phase_handlers[p]
}
#[must_use]
@ -371,15 +366,15 @@ impl Cache {
}
}
fn status_phase_handlers() -> HashMap<StatusPhaseState, Ability> {
use StatusPhaseState::*;
fn status_phase_handlers() -> HashMap<StatusPhaseStateType, Ability> {
use StatusPhaseStateType::*;
HashMap::from([
(CompleteObjectives, complete_objectives()),
(FreeAdvance, free_advance()),
(DrawCards, draw_cards()),
(RazeSize1City, use_raze_city()),
(ChangeGovernmentType(false), may_change_government()),
(DetermineFirstPlayer(0), determine_first_player()),
(ChangeGovernmentType, may_change_government()),
(DetermineFirstPlayer, determine_first_player()),
])
}

View file

@ -70,9 +70,27 @@ impl HandCard {
#[must_use]
pub fn name(&self, game: &Game) -> String {
match self {
HandCard::ActionCard(id) => game.cache.get_action_card(*id).name(),
HandCard::ObjectiveCard(id) => game.cache.get_objective_card(*id).name(),
HandCard::Wonder(wonder) => wonder.name(),
HandCard::ActionCard(id) => {
if *id == 0 {
"an action card".to_string()
} else {
game.cache.get_action_card(*id).name()
}
}
HandCard::ObjectiveCard(id) => {
if *id == 0 {
"an objective card".to_string()
} else {
game.cache.get_objective_card(*id).name()
}
}
HandCard::Wonder(wonder) => {
if wonder == &Wonder::Hidden {
"a wonder card".to_string()
} else {
wonder.name()
}
}
}
}
}
@ -261,58 +279,7 @@ pub(crate) fn log_card_transfer(
to: HandCardLocation,
origin: &EventOrigin,
) {
let (player_index, message): (usize, &str) = if let HandCardLocation::Hand(p) = to {
let name = card_name(card, &from, game);
(
p,
match from {
HandCardLocation::DrawPile => &format!("Draw {name}"),
HandCardLocation::Hand(from) | HandCardLocation::RevealedHand(from) => {
&format!("Gain {name} from {}", game.player_name(from))
}
HandCardLocation::DiscardPile => &format!("Gain {name} from discard pile"),
HandCardLocation::Public => &format!("Gain {name} from the public area"),
HandCardLocation::GreatSeer(_) => &format!("Gain {name} from Great Seer"),
HandCardLocation::Incident => &format!("Gain {name} from the current event"),
_ => {
panic!(
"Cannot transfer card from played to hand: {card:?} from {from:?} to {to:?}"
)
}
},
)
} else if let HandCardLocation::Hand(p) = from {
let name = card_name(card, &to, game);
(
p,
match to {
HandCardLocation::DiscardPile => &format!("Discard {name}"),
HandCardLocation::DrawPile => &format!("Shuffle {name} back into the draw pile"),
HandCardLocation::PlayToDiscard | HandCardLocation::PlayToKeep => {
&format!("Play {name}")
}
HandCardLocation::CompleteObjective(ref o) => &format!("Complete {o} using {name}"),
HandCardLocation::PlayToDiscardFaceDown => &format!("Play {name} face down"),
HandCardLocation::Public => &format!("Place {name} in public area"),
_ => panic!(
"Cannot transfer card from hand to draw pile: {card:?} from {from:?} to {to:?}"
),
},
)
} else if let HandCardLocation::GreatSeer(p) = to {
assert_eq!(from, HandCardLocation::DrawPile);
(p, "Placed a card from the draw pile in the Great Seer")
} else if let HandCardLocation::DrawPilePeeked(p) = from {
assert_eq!(to, HandCardLocation::DrawPile);
(
p,
"Reshuffled a card from the draw pile back into the draw pile",
)
} else {
panic!("Invalid card transfer from {from:?} to {to:?}");
};
game.log(player_index, origin, message);
let (player_index, _message) = hand_card_message(game, card, &from, &to);
add_action_log_item(
game,
player_index,
@ -322,10 +289,65 @@ pub(crate) fn log_card_transfer(
);
}
fn card_name(card: &HandCard, l: &HandCardLocation, game: &mut Game) -> String {
if l.is_public() {
card.name(game)
///
/// # Panics
/// Panics if the transfer is invalid
#[must_use]
pub fn hand_card_message(
game: &Game,
card: &HandCard,
from: &HandCardLocation,
to: &HandCardLocation,
) -> (usize, String) {
let (player_index, message): (usize, &str) = if let HandCardLocation::Hand(p) = to {
let name = card.name(game);
(
*p,
match from {
HandCardLocation::DrawPile => &format!("draws {name}"),
HandCardLocation::Hand(from) | HandCardLocation::RevealedHand(from) => {
&format!("gains {name} from {}", game.player_name(*from))
}
HandCardLocation::DiscardPile => &format!("gains {name} from discard pile"),
HandCardLocation::Public => &format!("gains {name} from the public area"),
HandCardLocation::GreatSeer(_) => &format!("gains {name} from Great Seer"),
HandCardLocation::Incident => &format!("gains {name} from the current event"),
_ => {
panic!(
"Cannot transfer card from played to hand: {card:?} from {from:?} to {to:?}"
)
}
},
)
} else if let HandCardLocation::Hand(p) = from {
let name = card.name(game);
(
*p,
match to {
HandCardLocation::DiscardPile => &format!("Discard {name}"),
HandCardLocation::DrawPile => &format!("Shuffle {name} back into the draw pile"),
HandCardLocation::PlayToDiscard | HandCardLocation::PlayToKeep => {
&format!("Play {name}")
}
HandCardLocation::CompleteObjective(o) => &format!("Complete {o} using {name}"),
HandCardLocation::PlayToDiscardFaceDown => &format!("Play {name} face down"),
HandCardLocation::Public => &format!("Place {name} in public area"),
_ => panic!(
"Cannot transfer card from hand to draw pile: {card:?} from {from:?} to {to:?}"
),
},
)
} else if let HandCardLocation::GreatSeer(p) = to {
assert_eq!(*from, HandCardLocation::DrawPile);
(*p, "Placed a card from the draw pile in the Great Seer")
} else if let HandCardLocation::DrawPilePeeked(p) = from {
assert_eq!(*to, HandCardLocation::DrawPile);
(
*p,
"Reshuffled a card from the draw pile back into the draw pile",
)
} else {
card.card_type().to_string()
}
panic!("Invalid card transfer from {from:?} to {to:?}");
};
(player_index, message.to_string())
}

View file

@ -4,6 +4,7 @@ use std::ops::{Add, Sub};
use crate::city_pieces::lose_building;
use crate::content::custom_actions::CustomActionType::ForcedLabor;
use crate::content::custom_actions::SpecialAction;
use crate::content::persistent_events::PersistentEventType;
use crate::events::{EventOrigin, EventPlayer};
use crate::log::{ActionLogBalance, ActionLogEntry, add_action_log_item};
@ -112,7 +113,10 @@ impl City {
Happy => self.size() + 1,
Neutral => self.size(),
Angry => {
if player.played_once_per_turn_actions.contains(&ForcedLabor) {
if player
.played_once_per_turn_actions
.contains(&SpecialAction::Custom(ForcedLabor))
{
self.size()
} else {
1
@ -234,7 +238,7 @@ pub(crate) fn execute_found_city_action(
add_action_log_item(
game,
player_index,
ActionLogEntry::units(u, ActionLogBalance::Loss),
ActionLogEntry::units(u, ActionLogBalance::Pay, settler.position),
origin.clone(),
vec![],
);
@ -243,7 +247,7 @@ pub(crate) fn execute_found_city_action(
}
found_city(
game,
&EventPlayer::from_player(player_index, game, origin),
&EventPlayer::new(player_index, origin),
settler.position,
);
Ok(())
@ -331,12 +335,6 @@ pub(crate) fn set_city_mood(
return;
}
city.mood_state = new_state.clone();
game.log(
player,
origin,
&format!("City {position} became {new_state}"),
);
add_action_log_item(
game,
player,

View file

@ -345,7 +345,7 @@ pub(crate) fn gain_building(
position: Position,
) {
if let Some(old) = game.get_any_city(position).pieces.building_owner(building) {
let old = EventPlayer::from_player(old, game, player.origin.clone());
let old = EventPlayer::new(old, player.origin.clone());
lose_building(game, &old, building, position);
}
game.get_any_city_mut(position)
@ -360,27 +360,13 @@ pub(crate) fn log_gain_building(
building: Building,
position: Position,
) {
let port_pos = if building == Port {
format!(
" at the water tile {}",
game.get_any_city(position)
.port_position
.expect("Port must have a port position",)
)
} else {
String::new()
};
player.log(
game,
&format!("Gain {} at {position}{port_pos}", building.name()),
);
log_structure(
game,
player,
Structure::Building(building),
ActionLogBalance::Gain,
position,
log_port_position(game, building, position),
);
}
@ -390,12 +376,18 @@ pub(crate) fn log_lose_building(
building: Building,
position: Position,
) {
player.log(game, &format!("Lose {} at {}", building.name(), position));
log_structure(
game,
player,
Structure::Building(building),
ActionLogBalance::Loss,
position,
log_port_position(game, building, position),
);
}
fn log_port_position(game: &Game, building: Building, position: Position) -> Option<Position> {
(building == Port)
.then_some(game.get_any_city(position).port_position)
.flatten()
}

View file

@ -8,7 +8,7 @@ use crate::map::Terrain;
use crate::map::Terrain::{Fertile, Forest, Mountain};
use crate::player::{CostTrigger, Player};
use crate::player_events::ActionInfo;
use crate::playing_actions::{PlayingActionType, base_or_custom_available};
use crate::playing_actions::{PlayingActionType, base_or_modified_available};
use crate::position::Position;
use crate::resource::gain_resources_with_modifiers;
use crate::resource_pile::ResourcePile;
@ -164,11 +164,6 @@ pub(crate) fn execute_collect(
c: &Collect,
) -> Result<(), String> {
let origin = collect_event_origin(&c.action_type, game.player(player_index));
game.log(
player_index,
&origin,
&format!("Use city {}", c.city_position),
);
let mut i = get_total_collection(
game,
@ -368,7 +363,7 @@ pub fn available_collect_actions_for_city(
#[must_use]
pub fn available_collect_actions(game: &Game, player: usize) -> Vec<PlayingActionType> {
base_or_custom_available(game, player, &PlayingActionType::Collect)
base_or_modified_available(game, player, &PlayingActionType::Collect)
}
pub(crate) fn collect_event_origin(

View file

@ -431,7 +431,7 @@ fn take_over_city(
}
pub(crate) fn capture_position(game: &mut Game, stats: &mut CombatStats) {
let p = &EventPlayer::from_player(stats.attacker.player, game, combat_event_origin());
let p = &EventPlayer::new(stats.attacker.player, combat_event_origin());
let old_player = stats.defender.player;
let position = stats.defender.position;
let captured_settlers = game.players[old_player]
@ -451,7 +451,7 @@ pub(crate) fn capture_position(game: &mut Game, stats: &mut CombatStats) {
}
kill_units_with_stats(stats, game, old_player, &captured_settlers);
if game.player(old_player).try_get_city(position).is_some() {
let d = &EventPlayer::from_player(old_player, game, combat_event_origin());
let d = &EventPlayer::new(old_player, combat_event_origin());
conquer_city(game, position, p, d);
}
}
@ -545,9 +545,8 @@ fn apply_battle_movement_restriction(game: &mut Game, player_index: usize, unit_
}
if used_longships {
EventPlayer::from_player(
EventPlayer::new(
player_index,
game,
EventOrigin::SpecialAdvance(SpecialAdvance::Longships),
)
.log(game, "Ignore battle movement restrictions");

View file

@ -120,7 +120,7 @@ impl CombatRoundStats {
);
let hits = combat_hits.hits();
let p = EventPlayer::from_player(self.player, game, combat_event_origin());
let p = EventPlayer::new(self.player, combat_event_origin());
p.log(
game,
&format!(

View file

@ -179,7 +179,7 @@ pub(crate) fn construct(
}
gain_building(
game,
&EventPlayer::from_player(player, game, origin.clone()),
&EventPlayer::new(player, origin.clone()),
building,
city_position,
);
@ -227,7 +227,7 @@ pub(crate) fn on_construct(game: &mut Game, player_index: usize, info: Construct
gain_advance_without_payment(
game,
b.advance,
&EventPlayer::from_player(player_index, game, b.origin),
&EventPlayer::new(player_index, b.origin),
ResourcePile::empty(),
true,
);

View file

@ -8,7 +8,8 @@ use crate::content::civilizations::rome::owner_of_sulla_in_range;
use crate::content::persistent_events::{PaymentRequest, PositionRequest};
use crate::content::tactics_cards::TacticsCardFactory;
use crate::game::Game;
use crate::movement::{MoveUnits, move_action_log};
use crate::log::ActionLogEntry;
use crate::movement::MoveUnits;
use crate::player::Player;
use crate::position::Position;
use crate::resource::ResourceType;
@ -153,7 +154,8 @@ fn move_army(b: ActionCardBuilder, i: i32) -> ActionCardBuilder {
let units = b.get_units(from).iter().map(|u| u.id).collect_vec();
let m = MoveUnits::new(units, to, None, ResourcePile::empty());
s.log(game, &move_action_log(game, b, &m));
s.player()
.add_action_log_item(game, ActionLogEntry::move_units(b, &m));
move_with_possible_combat(game, barbarian, &m);
},
@ -192,7 +194,8 @@ fn barbarian_army_positions_in_range2(
.is_some_and(|sulla_owner| player.index != sulla_owner)
{
log.push(format!(
"{player} cannot move Barbarian army at {p} because Sulla is in range",
"{} cannot move Barbarian army at {p} because Sulla is in range",
player.get_name()
));
return false;
}

View file

@ -95,7 +95,7 @@ pub(crate) fn use_negotiations() -> Ability {
}
}
}
add_start_turn_action_if_needed(game);
add_start_turn_action_if_needed(game, p.index);
// must be in reverse order to not mess up the indices during deletion
for i in delete.iter().rev() {
p.log(game, &format!("May attack {partner_name} again.",));
@ -195,7 +195,7 @@ pub(crate) fn use_assassination() -> Ability {
if remove_element_by(&mut game.permanent_effects, |e| is_assassinated(e, p.index))
.is_some()
{
add_start_turn_action_if_needed(game);
add_start_turn_action_if_needed(game, p.index);
lose_action(game, p);
}
},

View file

@ -237,7 +237,8 @@ fn has_any_card(p: &Player, game: &Game) -> bool {
fn get_swap_secrets(other: &Player, game: &Game) -> Vec<String> {
vec![
format!(
"{other} has the following action cards: {}",
"{} has the following action cards: {}",
other.get_name(),
other
.action_cards
.iter()
@ -245,7 +246,8 @@ fn get_swap_secrets(other: &Player, game: &Game) -> Vec<String> {
.join(", ")
),
format!(
"{other} has the following objective cards: {}",
"{} has the following objective cards: {}",
other.get_name(),
other
.objective_cards
.iter()
@ -253,7 +255,8 @@ fn get_swap_secrets(other: &Player, game: &Game) -> Vec<String> {
.join(", ")
),
format!(
"{other} has the following wonder cards: {}",
"{} has the following wonder cards: {}",
other.get_name(),
other.wonder_cards.iter().map(Wonder::name).join(", ")
),
]

View file

@ -2,7 +2,7 @@ use crate::ability_initializer::AbilityInitializerSetup;
use crate::advance::Bonus::{CultureToken, MoodToken};
use crate::advance::{Advance, AdvanceBuilder, AdvanceInfo};
use crate::content::advances::{AdvanceGroup, AdvanceGroupInfo, advance_group_builder};
use crate::content::custom_actions::CustomActionType;
use crate::content::custom_actions::PlayingActionModifier;
use crate::game::GameOptions;
use crate::payment::PaymentConversion;
use crate::playing_actions::PlayingActionType;
@ -90,5 +90,5 @@ fn city_planning() -> AdvanceBuilder {
"Once per turn, as a free action, you may pay 1 idea and 1 wood to get a free Construct action.",
)
.replaces(Advance::Sanitation)
.add_action_modifier(CustomActionType::CityPlanning, |cost| cost.once_per_turn().free_action().resources(ResourcePile::ideas(1) + ResourcePile::wood(1)), PlayingActionType::Construct)
.add_action_modifier(PlayingActionModifier::CityPlanning, |cost| cost.once_per_turn().free_action().resources(ResourcePile::ideas(1) + ResourcePile::wood(1)), PlayingActionType::Construct)
}

View file

@ -5,7 +5,7 @@ use crate::city::{City, MoodState};
use crate::city_pieces::Building::Obelisk;
use crate::content::ability::AbilityBuilder;
use crate::content::advances::{AdvanceGroup, AdvanceGroupInfo, advance_group_builder};
use crate::content::custom_actions::{CustomActionType, any_non_happy};
use crate::content::custom_actions::{CustomActionType, PlayingActionModifier, any_non_happy};
use crate::content::persistent_events::PaymentRequest;
use crate::events::{EventOrigin, check_event_origin};
use crate::game::GameOptions;
@ -37,7 +37,7 @@ fn arts() -> AdvanceBuilder {
.with_advance_bonus(CultureToken)
.with_unlocked_building(Obelisk)
.add_action_modifier(
CustomActionType::ArtsInfluenceCultureAttempt,
PlayingActionModifier::ArtsInfluenceCultureAttempt,
|c| {
c.once_per_turn()
.free_action()

View file

@ -3,9 +3,8 @@ use crate::action::Action;
use crate::advance::{Advance, AdvanceBuilder, AdvanceInfo};
use crate::city::{self, MoodState};
use crate::content::advances::{AdvanceGroup, AdvanceGroupInfo, advance_group_builder};
use crate::content::custom_actions::CustomActionType::{
self, CivilLiberties, FreeEconomyCollect, VotingIncreaseHappiness,
};
use crate::content::custom_actions::CustomActionType::{self, CivilLiberties};
use crate::content::custom_actions::{PlayingActionModifier, SpecialAction};
use crate::content::persistent_events::PositionRequest;
use crate::game::GameOptions;
use crate::log::current_turn_log_without_redo;
@ -34,7 +33,7 @@ fn voting() -> AdvanceBuilder {
"As a free action, you may spend 1 mood token to use 'Increase happiness'",
)
.add_action_modifier(
VotingIncreaseHappiness,
PlayingActionModifier::VotingIncreaseHappiness,
|c| {
c.any_times()
.free_action()
@ -94,7 +93,7 @@ fn free_economy() -> AdvanceBuilder {
resources in one city. This must be your only collect action this turn",
)
.add_action_modifier(
FreeEconomyCollect,
PlayingActionModifier::FreeEconomyCollect,
|c| {
c.once_per_turn()
.free_action()
@ -109,12 +108,14 @@ fn free_economy() -> AdvanceBuilder {
PlayingActionType::Collect
if p.get(game)
.played_once_per_turn_actions
.contains(&FreeEconomyCollect) =>
.contains(&SpecialAction::Modifier(
PlayingActionModifier::FreeEconomyCollect,
)) =>
{
*available = Err("Cannot collect when Free Economy Collect was used".to_string());
}
PlayingActionType::Custom(i)
if *i == FreeEconomyCollect
PlayingActionType::Special(SpecialAction::Modifier(m))
if *m == PlayingActionModifier::FreeEconomyCollect
&& current_turn_log_without_redo(game)
.actions
.iter()

View file

@ -159,7 +159,7 @@ where
if !p.get(game).can_use_advance(Advance::TradeRoutes) {
return None;
}
add_start_turn_action_if_needed(game);
add_start_turn_action_if_needed(game, p.index);
trade_route_reward(game, p).map(|(reward, routes)| {
gain_market_bonus(game, &routes);
ResourceRewardRequest::new(reward, "Collect trade routes reward".to_string())

View file

@ -6,10 +6,10 @@ use crate::card::HandCardLocation;
use crate::city_pieces::Building;
use crate::content::ability::Ability;
use crate::content::advances::{AdvanceGroup, AdvanceGroupInfo, advance_group_builder};
use crate::content::custom_actions::CustomActionType;
use crate::content::custom_actions::PlayingActionModifier;
use crate::content::persistent_events::PaymentRequest;
use crate::game::GameOptions;
use crate::log::{self, ActionLogEntry};
use crate::log::{ActionLogEntry, current_turn_log_mut};
use crate::objective_card::draw_objective_card_from_pile;
use crate::playing_actions::PlayingActionType;
use crate::resource::gain_resources;
@ -50,8 +50,10 @@ fn writing() -> AdvanceBuilder {
|event| &mut event.after_action,
1,
|game, (), (), p| {
if game.is_update_patch() {
let count = log::current_action_log_mut(game)
if game.is_update_patch()
&& let Some(a) = current_turn_log_mut(game).actions.last()
{
let count = a
.items
.iter()
.filter(|item| {
@ -64,7 +66,9 @@ fn writing() -> AdvanceBuilder {
)
})
.count();
p.gain_resources(game, ResourcePile::ideas(count as u8));
if count > 0 {
p.gain_resources(game, ResourcePile::ideas(count as u8));
}
}
},
)
@ -190,7 +194,7 @@ fn philosophy_patched() -> AdvanceBuilder {
)
.replaces(Advance::Philosophy)
.add_action_modifier(
CustomActionType::Philosophy,
PlayingActionModifier::Philosophy,
|cost| {
cost.any_times()
.free_action()

View file

@ -7,6 +7,7 @@ use crate::content::ability::Ability;
use crate::content::advances::{AdvanceGroup, AdvanceGroupInfo, advance_group_builder};
use crate::content::persistent_events::ResourceRewardRequest;
use crate::game::GameOptions;
use crate::log::ActionLogBalance;
use crate::resource::ResourceType;
use crate::resource_pile::ResourcePile;
@ -116,7 +117,8 @@ fn metallurgy() -> AdvanceBuilder {
},
move |game, s, _| {
if s.choice {
s.player().lose_resources(game, ResourcePile::ore(1));
s.player()
.lose_resources(game, ResourcePile::ore(1), ActionLogBalance::Pay);
s.player().gain_resources(game, ResourcePile::gold(1));
} else {
s.log(game, "Did not convert ore to gold");

View file

@ -9,7 +9,7 @@ use crate::combat_listeners::CombatStrength;
use crate::content::ability::AbilityBuilder;
use crate::content::advances::AdvanceGroup;
use crate::content::advances::warfare::draft_cost;
use crate::content::custom_actions::CustomActionType;
use crate::content::custom_actions::{CustomActionType, PlayingActionModifier, SpecialAction};
use crate::content::persistent_events::{HandCardsRequest, PositionRequest};
use crate::events::check_event_origin;
use crate::game::Game;
@ -109,11 +109,13 @@ fn hellenistic_culture() -> SpecialAdvanceInfo {
You may replace the cost of Arts with 2 mood tokens.",
)
.add_action_modifier(
CustomActionType::HellenisticInfluenceCultureAttempt,
PlayingActionModifier::HellenisticInfluenceCultureAttempt,
|c| {
c.once_per_turn_mutually_exclusive(CustomActionType::ArtsInfluenceCultureAttempt)
.free_action()
.resources(ResourcePile::mood_tokens(2))
c.once_per_turn_mutually_exclusive(SpecialAction::Modifier(
PlayingActionModifier::ArtsInfluenceCultureAttempt,
))
.free_action()
.resources(ResourcePile::mood_tokens(2))
},
PlayingActionType::InfluenceCultureAttempt,
)

View file

@ -5,7 +5,7 @@ use crate::card::{HandCard, HandCardLocation, all_action_hand_cards, all_objecti
use crate::city::{MoodState, set_city_mood};
use crate::civilization::Civilization;
use crate::content::ability::AbilityBuilder;
use crate::content::custom_actions::CustomActionType;
use crate::content::custom_actions::{CustomActionType, PlayingActionModifier};
use crate::content::persistent_events::{HandCardsRequest, PaymentRequest, PositionRequest};
use crate::game::Game;
use crate::leader::{Leader, LeaderInfo, leader_position};
@ -268,7 +268,7 @@ fn caesar() -> LeaderInfo {
to increase happiness in the leader city.",
)
.add_action_modifier(
CustomActionType::StatesmanIncreaseHappiness,
PlayingActionModifier::StatesmanIncreaseHappiness,
|c| c.any_times().free_action().no_resources(),
PlayingActionType::IncreaseHappiness,
)

View file

@ -8,15 +8,15 @@ use crate::consts::STACK_LIMIT;
use crate::content::ability::{Ability, AbilityBuilder};
use crate::content::advances::economy::use_taxes;
use crate::content::advances::trade_routes::TradeRoute;
use crate::content::custom_actions::CustomActionType;
use crate::content::custom_actions::{CustomActionType, SpecialAction};
use crate::content::persistent_events::{PaymentRequest, PositionRequest, UnitsRequest};
use crate::events::EventOrigin;
use crate::game::Game;
use crate::leader::{Leader, LeaderInfo, leader_position};
use crate::leader_ability::{LeaderAbility, activate_leader_city, can_activate_leader_city};
use crate::log::add_start_turn_action_if_needed;
use crate::log::{ActionLogEntry, add_start_turn_action_if_needed};
use crate::map::{Block, Terrain, block_for_position, capital_city_position};
use crate::movement::{MoveUnits, move_action_log};
use crate::movement::MoveUnits;
use crate::player::{Data, Player};
use crate::position::Position;
use crate::resource::ResourceType;
@ -223,7 +223,7 @@ pub(crate) fn lose_raid_resource() -> Ability {
.then_some(vec![PaymentRequest::mandatory(c, "Pay 1 resource")])
},
|game, s, ()| {
add_start_turn_action_if_needed(game);
add_start_turn_action_if_needed(game, s.player_index);
s.log(game, &format!("Lose {}", s.choice[0]));
},
)
@ -304,7 +304,7 @@ fn danegeld() -> LeaderAbility {
.add_custom_action(
CustomActionType::Danegeld,
|c| {
c.once_per_turn_mutually_exclusive(CustomActionType::Taxes)
c.once_per_turn_mutually_exclusive(SpecialAction::Custom(CustomActionType::Taxes))
.action()
.no_resources()
},
@ -382,7 +382,8 @@ fn new_colonies() -> LeaderAbility {
.collect_vec();
let m = MoveUnits::new(units, to, None, ResourcePile::empty());
s.log(game, &move_action_log(game, p, &m));
s.player()
.add_action_log_item(game, ActionLogEntry::move_units(p, &m));
move_with_possible_combat(game, s.player_index, &m);
},

View file

@ -4,7 +4,7 @@ use crate::content::ability::Ability;
use crate::content::persistent_events::{
PersistentEventType, TriggerPersistentEventParams, trigger_persistent_event_with_listener,
};
use crate::events::{EventOrigin, EventPlayer};
use crate::events::EventOrigin;
use crate::player::Player;
use crate::playing_actions::PlayingActionType;
use crate::position::Position;
@ -45,22 +45,22 @@ impl CustomActionActivation {
}
#[derive(Clone)]
pub struct CustomActionInfo {
pub action: CustomActionType,
pub execution: CustomActionExecution,
pub struct SpecialActionInfo {
pub action: SpecialAction,
pub execution: SpecialActionExecution,
pub event_origin: EventOrigin,
pub cost: ActionCostOncePerTurn,
}
impl CustomActionInfo {
impl SpecialActionInfo {
#[must_use]
pub fn new(
action: CustomActionType,
execution: CustomActionExecution,
action: SpecialAction,
execution: SpecialActionExecution,
event_origin: EventOrigin,
cost: ActionCostOncePerTurn,
) -> CustomActionInfo {
CustomActionInfo {
) -> SpecialActionInfo {
SpecialActionInfo {
action,
execution,
event_origin,
@ -75,12 +75,36 @@ impl CustomActionInfo {
#[must_use]
pub fn city_bound(&self) -> Option<&CustomActionCityChecker> {
if let CustomActionExecution::Action(a) = &self.execution {
if let SpecialActionExecution::Action(a) = &self.execution {
a.city_checker.as_ref()
} else {
None
}
}
///
/// # Panics
/// Panics if not a modifier action
#[must_use]
pub fn custom_action_type(&self) -> CustomActionType {
if let SpecialAction::Custom(c) = self.action {
c
} else {
panic!("Not a custom action")
}
}
///
/// # Panics
/// Panics if not a modifier action
#[must_use]
pub fn modifier_action_type(&self) -> PlayingActionType {
if let SpecialAction::Modifier(m) = self.action {
m.playing_action_type()
} else {
panic!("Not a modifier action")
}
}
}
type CustomActionChecker = Arc<dyn Fn(&Game, &Player) -> bool + Sync + Send>;
@ -109,11 +133,53 @@ impl CustomActionActionExecution {
}
#[derive(Clone)]
pub enum CustomActionExecution {
pub enum SpecialActionExecution {
Modifier(PlayingActionType),
Action(CustomActionActionExecution),
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Copy, Hash, Debug)]
pub enum SpecialAction {
Modifier(PlayingActionModifier),
Custom(CustomActionType),
}
impl SpecialAction {
#[must_use]
pub fn playing_action_type(&self) -> PlayingActionType {
match self {
SpecialAction::Modifier(m) => m.playing_action_type(),
SpecialAction::Custom(c) => c.playing_action_type(),
}
}
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Copy, Hash, Debug)]
pub enum PlayingActionModifier {
// Advances
ArtsInfluenceCultureAttempt,
FreeEconomyCollect,
VotingIncreaseHappiness,
// Update patch Advances
CityPlanning,
Philosophy,
// Civilizations,
// Rome
StatesmanIncreaseHappiness,
// Greece
HellenisticInfluenceCultureAttempt,
}
impl PlayingActionModifier {
#[must_use]
pub fn playing_action_type(&self) -> PlayingActionType {
PlayingActionType::Special(SpecialAction::Modifier(*self))
}
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Copy, Hash, Debug)]
pub enum CustomActionType {
// Advances
@ -121,16 +187,11 @@ pub enum CustomActionType {
ForcedLabor,
CivilLiberties,
Bartering,
ArtsInfluenceCultureAttempt,
VotingIncreaseHappiness,
FreeEconomyCollect,
Sports,
Taxes,
Theaters,
// Update patch Advances
CityPlanning,
Philosophy,
WelfareState,
ForcedMarch,
MilitaryState,
@ -145,10 +206,8 @@ pub enum CustomActionType {
// Rome
Aqueduct,
Princeps,
StatesmanIncreaseHappiness,
// Greece
HellenisticInfluenceCultureAttempt,
Idol,
Master,
@ -166,21 +225,7 @@ pub enum CustomActionType {
impl CustomActionType {
#[must_use]
pub fn playing_action_type(&self) -> PlayingActionType {
PlayingActionType::Custom(*self)
}
}
pub(crate) fn log_start_custom_action(game: &mut Game, player_index: usize, action: &CustomAction) {
let p = game.player(player_index);
let player = EventPlayer::from_player(
player_index,
game,
action.action.playing_action_type().origin(p),
);
if let Some(city) = action.city {
player.log(game, &format!("Start action in city {city}"));
} else {
player.log(game, "Start action");
PlayingActionType::Special(SpecialAction::Custom(*self))
}
}
@ -207,8 +252,11 @@ pub(crate) fn custom_action_execution(
player: &Player,
action_type: CustomActionType,
) -> Option<CustomActionActionExecution> {
if let CustomActionExecution::Action(e) =
player.custom_actions.get(&action_type)?.execution.clone()
if let SpecialActionExecution::Action(e) = player
.special_actions
.get(&SpecialAction::Custom(action_type))?
.execution
.clone()
{
Some(e)
} else {
@ -216,23 +264,23 @@ pub(crate) fn custom_action_execution(
}
}
pub(crate) fn can_play_custom_action(
pub(crate) fn can_play_special_action(
game: &Game,
p: &Player,
c: CustomActionType,
c: SpecialAction,
) -> Result<(), String> {
if !p.custom_actions.contains_key(&c) {
if !p.special_actions.contains_key(&c) {
return Err("Custom action not available".to_string());
}
let info = p.custom_action_info(c);
let info = p.special_action_info(&c);
if let Some(key) = info.cost.once_per_turn
&& p.played_once_per_turn_actions.contains(&key)
{
return Err("Custom action already played this turn".to_string());
}
if let CustomActionExecution::Action(e) = &info.execution
if let SpecialActionExecution::Action(e) = &info.execution
&& !(e.checker)(game, p)
{
return Err("Custom action cannot be played".to_string());
@ -253,8 +301,11 @@ pub(crate) fn is_base_or_modifier(
base_type: &PlayingActionType,
) -> bool {
match base_type {
PlayingActionType::Custom(c) => {
if let CustomActionExecution::Modifier(t) = &p.custom_action_info(*c).execution {
PlayingActionType::Special(SpecialAction::Modifier(c)) => {
if let SpecialActionExecution::Modifier(t) = &p
.special_action_info(&SpecialAction::Modifier(*c))
.execution
{
t == action_type
} else {
false
@ -269,7 +320,7 @@ pub(crate) fn custom_action_modifier_event_origin(
action_type: &PlayingActionType,
player: &Player,
) -> EventOrigin {
if let PlayingActionType::Custom(c) = action_type {
if let PlayingActionType::Special(SpecialAction::Modifier(c)) = action_type {
c.playing_action_type().origin(player)
} else {
base_action_origin

View file

@ -275,7 +275,7 @@ fn envoy() -> Incident {
|_p, _, _| true,
0,
|game, s, _| {
s.other_player(s.choice, game)
s.other_player(s.choice)
.gain_resources(game, ResourcePile::culture_tokens(1));
},
)

View file

@ -204,7 +204,7 @@ fn destroy_building(game: &mut Game, b: Building, position: Position, origin: &E
let o = game.player_mut(owner);
o.gain_event_victory_points(2.0, origin);
o.destroyed_structures.add_building(b);
let player = EventPlayer::from_player(city_owner, game, origin.clone());
let player = EventPlayer::new(city_owner, origin.clone());
lose_building(game, &player, b, position);
game.log(
owner,
@ -219,11 +219,7 @@ fn destroy_wonder_for_points(
wonder: Wonder,
origin: &EventOrigin,
) {
let p = &EventPlayer::from_player(
game.get_any_city(position).player_index,
game,
origin.clone(),
);
let p = &EventPlayer::new(game.get_any_city(position).player_index, origin.clone());
destroy_wonder(game, p, wonder, position);
let a = wonder.info(game).owned_victory_points;

View file

@ -7,6 +7,7 @@ use crate::content::effects::PermanentEffect;
use crate::content::persistent_events::UnitsRequest;
use crate::game::Game;
use crate::incident::{DecreaseMood, Incident, IncidentBaseEffect, MoodModifier};
use crate::log::ActionLogBalance;
use crate::player::Player;
use crate::player_events::IncidentTarget;
use crate::playing_actions::PlayingActionType;
@ -219,7 +220,7 @@ pub(crate) fn famine(
// only avoid anger if full amount is paid
i.player.payment = ResourcePile::food(lost);
}
player.lose_resources(game, ResourcePile::food(lost));
player.lose_resources(game, ResourcePile::food(lost), ActionLogBalance::Loss);
player.log(game, &format!("Lost {lost} food",));
})

View file

@ -147,7 +147,7 @@ fn good_year(mut builder: IncidentBuilder, amount: u8, good_year_type: &GoodYear
|p, _, _| p.resources.food < p.resource_limit.food,
i as i32,
move |game, s, _| {
s.other_player(s.choice, game)
s.other_player(s.choice)
.gain_resources(game, ResourcePile::food(1));
},
);

View file

@ -1,3 +1,4 @@
use crate::log::ActionLogBalance;
use crate::objective_card::Objective;
use crate::resource::ResourceType;
use crate::resource_pile::ResourcePile;
@ -50,7 +51,7 @@ pub(crate) fn pay_resources(
)
.status_phase_check(move |_game, player| player.resources.has_at_least(&want))
.status_phase_update(move |game, player| {
player.lose_resources(game, pay.clone());
player.lose_resources(game, pay.clone(), ActionLogBalance::Pay);
player.log(game, &format!("Pay {pay} for {objective}",));
})
.build()

View file

@ -383,7 +383,8 @@ fn colosseum() -> WonderInfo {
p.log(
game,
&format!(
"Combat value is already at maximum, cannot increase combat value for {p}",
"Combat value is already at maximum, cannot increase combat value for {}",
p.name(game)
),
);
return None;

View file

@ -12,7 +12,7 @@ use crate::log::current_turn_log_without_redo;
use crate::payment::PaymentOptions;
use crate::player::Player;
use crate::player_events::ActionInfo;
use crate::playing_actions::{PlayingAction, PlayingActionType, base_or_custom_available};
use crate::playing_actions::{PlayingAction, PlayingActionType, base_or_modified_available};
use crate::position::Position;
use crate::resource_pile::ResourcePile;
use crate::special_advance::SpecialAdvance;
@ -83,8 +83,8 @@ impl InfluenceCultureInfo {
}
#[must_use]
pub(crate) fn player(&self, player: usize, game: &Game) -> EventPlayer {
EventPlayer::from_player(player, game, self.info.origin.clone())
pub(crate) fn player(&self, player: usize) -> EventPlayer {
EventPlayer::new(player, self.info.origin.clone())
}
}
@ -144,7 +144,7 @@ pub(crate) fn execute_influence_culture_attempt(
Structure::Wonder(_) => panic!("Wonder is not allowed here"),
};
info.player(player_index, game).log(
info.player(player_index).log(
game,
&format!(
"Tried to influence the {city_piece} in the city \
@ -222,7 +222,7 @@ fn roll_boost_paid(
)
.clone();
let player = info.player(player_index, game);
let player = info.player(player_index);
if payment.is_empty() {
player.log(game, "Declined to pay to increase the dice roll");
attempt_failed(game, player_index, a.selected_structure.position);
@ -274,7 +274,7 @@ fn range_boost_cost(
info: &mut InfluenceCultureInfo,
player_index: usize,
) -> PaymentOptions {
let p = info.player(player_index, game);
let p = info.player(player_index);
let roll = game.next_dice_roll().value + info.roll_boost;
info.roll = roll;
@ -457,10 +457,10 @@ fn structures(city: &City) -> Vec<SelectedStructure> {
fn influence_culture(game: &mut Game, influencer_index: usize, info: &InfluenceCultureInfo) {
let city_position = info.position;
let city_owner = game.get_any_city(city_position).player_index;
let new = &info.player(influencer_index, game);
let new = &info.player(influencer_index);
match info.structure {
Structure::CityCenter => {
let city = lose_city(game, &info.player(city_owner, game), city_position);
let city = lose_city(game, &info.player(city_owner), city_position);
gain_city(game, new, city);
}
Structure::Building(b) => gain_building(game, new, b, city_position),
@ -569,7 +569,7 @@ pub fn affordable_start_city(
#[must_use]
pub fn available_influence_actions(game: &Game, player: usize) -> Vec<PlayingActionType> {
base_or_custom_available(game, player, &PlayingActionType::InfluenceCultureAttempt)
base_or_modified_available(game, player, &PlayingActionType::InfluenceCultureAttempt)
}
pub(crate) fn influence_event_origin(

View file

@ -1,5 +1,6 @@
use crate::advance::Advance;
use crate::game::Game;
use crate::log::{ActionLogBalance, ActionLogEntry, add_action_log_item};
use crate::payment::{PaymentOptionsBuilder, RewardBuilder};
use crate::player::{CostTrigger, Player};
use crate::resource::{gain_resources, lose_resources};
@ -7,7 +8,6 @@ use crate::resource_pile::ResourcePile;
use crate::special_advance::SpecialAdvance;
use crate::wonder::Wonder;
use serde::{Deserialize, Serialize};
use std::fmt::Display;
use std::sync::Arc;
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug, Hash)]
@ -66,25 +66,14 @@ pub fn check_event_origin() -> EventOrigin {
#[derive(Clone, PartialEq, Eq, Debug)]
pub(crate) struct EventPlayer {
pub index: usize,
pub name: String,
pub origin: EventOrigin,
}
impl EventPlayer {
#[must_use]
pub fn new(player_index: usize, player_name: String, origin: EventOrigin) -> Self {
pub fn new(player_index: usize, origin: EventOrigin) -> Self {
Self {
index: player_index,
name: player_name,
origin,
}
}
#[must_use]
pub fn from_player(player: usize, game: &Game, origin: EventOrigin) -> Self {
Self {
index: player,
name: game.player_name(player),
origin,
}
}
@ -103,15 +92,26 @@ impl EventPlayer {
gain_resources(game, self.index, resources, self.origin.clone());
}
pub fn lose_resources(&self, game: &mut Game, resources: ResourcePile) {
lose_resources(game, self.index, resources, self.origin.clone(), vec![]);
pub fn lose_resources(
&self,
game: &mut Game,
resources: ResourcePile,
balance: ActionLogBalance,
) {
lose_resources(
game,
self.index,
resources,
self.origin.clone(),
vec![],
balance,
);
}
#[must_use]
pub fn with_origin(&self, origin: EventOrigin) -> Self {
Self {
index: self.index,
name: self.name.clone(),
origin,
}
}
@ -129,11 +129,14 @@ impl EventPlayer {
pub fn log(&self, game: &mut Game, message: &str) {
game.log(self.index, &self.origin, message);
}
}
impl Display for EventPlayer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.name)
#[must_use]
pub fn name(&self, game: &Game) -> String {
self.get(game).get_name()
}
pub fn add_action_log_item(&self, game: &mut Game, entry: ActionLogEntry) {
add_action_log_item(game, self.index, entry, self.origin.clone(), vec![]);
}
}
@ -298,13 +301,13 @@ mod tests {
event.add_listener_mut(
|item, constant, _, (), _| *item += constant,
0,
EventPlayer::new(0, String::new(), EventOrigin::Advance(add_constant)),
EventPlayer::new(0, EventOrigin::Advance(add_constant)),
);
let multiply_value = Advance::Sanitation;
event.add_listener_mut(
|item, _, multiplier, (), _| *item *= multiplier,
-1,
EventPlayer::new(0, String::new(), EventOrigin::Advance(multiply_value)),
EventPlayer::new(0, EventOrigin::Advance(multiply_value)),
);
let no_change = Advance::Bartering;
event.add_listener_mut(
@ -313,7 +316,7 @@ mod tests {
*item -= 1;
},
1,
EventPlayer::new(0, String::new(), EventOrigin::Advance(no_change)),
EventPlayer::new(0, EventOrigin::Advance(no_change)),
);
let mut item = 0;

View file

@ -6,10 +6,10 @@ use crate::content::persistent_events::{
};
use crate::events::EventPlayer;
use crate::game::Game;
use crate::log::ActionLogEntry;
use crate::map::{Block, BlockPosition, Map, Rotation, UnexploredBlock};
use crate::movement::{move_units, stop_current_move};
use crate::position::Position;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
@ -259,14 +259,7 @@ fn add_block_tiles_with_log(
.retain(|b| b.position.top_tile != pos.top_tile);
let tiles = block.tiles(pos, rotation);
let s = tiles
.into_iter()
.map(|(position, tile)| format!("{position}={tile}"))
.sorted()
.join(", ");
p.log(game, &format!("Explored tiles {s}"));
p.add_action_log_item(game, ActionLogEntry::explore_tiles(tiles));
game.map.add_block_tiles(pos, block, rotation);
}

View file

@ -2,7 +2,7 @@ use crate::action::lose_action;
use crate::cache::Cache;
use crate::combat_roll::{COMBAT_DIE_SIDES, CombatDieRoll};
use crate::consts::ACTIONS;
use crate::content::custom_actions::{CustomActionExecution, CustomActionInfo};
use crate::content::custom_actions::{SpecialActionExecution, SpecialActionInfo};
use crate::content::effects::PermanentEffect;
use crate::content::persistent_events::{
PersistentEventHandler, PersistentEventState, PersistentEventType,
@ -364,14 +364,10 @@ impl Game {
.position(|e| matches!(e, PermanentEffect::RevolutionLoseAction(p) if *p == player))
.map(|i| self.permanent_effects.remove(i));
if lost_action.is_some() {
add_start_turn_action_if_needed(self);
add_start_turn_action_if_needed(self, player);
lose_action(
self,
&EventPlayer::from_player(
player,
self,
EventOrigin::Ability("Revolution".to_string()),
),
&EventPlayer::new(player, EventOrigin::Ability("Revolution".to_string())),
);
}
self.successful_cultural_influence = false;
@ -499,7 +495,7 @@ impl Game {
let winner_name = self.player_name(winner_player_index);
let m = format!("The game has ended. {winner_name} has won");
self.add_message(&m);
add_start_turn_action_if_needed(self);
add_start_turn_action_if_needed(self, 0);
self.add_info_log_item(&m);
self.state = GameState::Finished;
}
@ -538,13 +534,13 @@ impl Game {
}
#[must_use]
pub fn available_custom_actions(&self, player_index: usize) -> Vec<CustomActionInfo> {
pub fn available_custom_actions(&self, player_index: usize) -> Vec<SpecialActionInfo> {
self.player(player_index)
.custom_actions
.special_actions
.values()
.filter(|&c| {
if matches!(c.execution, CustomActionExecution::Modifier(_)) {
// returned as part of "base_or_custom_available"
if matches!(c.execution, SpecialActionExecution::Modifier(_)) {
// returned as part of "base_or_modified_available"
return false;
}

View file

@ -5,7 +5,7 @@ use crate::city::{City, CityData};
use crate::city_pieces::{DestroyedStructures, DestroyedStructuresData};
use crate::content::ability;
use crate::content::ability::Ability;
use crate::content::custom_actions::CustomActionType;
use crate::content::custom_actions::SpecialAction;
use crate::content::effects::PermanentEffect;
use crate::content::persistent_events::PersistentEventState;
use crate::game::{Game, GameContext, GameOptions, GameState, UIElement};
@ -282,7 +282,7 @@ pub struct PlayerData {
next_unit_id: u32,
#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
played_once_per_turn_actions: Vec<CustomActionType>,
played_once_per_turn_actions: Vec<SpecialAction>,
#[serde(default)]
#[serde(skip_serializing_if = "HashMap::is_empty")]
#[serde(serialize_with = "sorted_map")]
@ -382,7 +382,7 @@ fn player_from_data(data: PlayerData, game: &Game) -> Player {
completed_objectives: data.completed_objectives,
captured_leaders: data.captured_leaders,
special_victory_points: data.special_victory_points,
custom_actions: HashMap::new(),
special_actions: HashMap::new(),
wonder_cards: data.wonder_cards,
action_cards: data.action_cards,
objective_cards: data.objective_cards,

View file

@ -11,7 +11,9 @@ use crate::content::civilizations::{BARBARIANS, CHOOSE_CIV, PIRATES};
use crate::events::{EventOrigin, EventPlayer};
use crate::game::{CivSetupOption, Game, GameContext, GameOptions, GameState};
use crate::leader::Leader;
use crate::log::{ActionLogAction, ActionLogAge, ActionLogRound, ActionLogTurn, TurnType};
use crate::log::{
ActionLogAge, ActionLogRound, TurnType, add_start_turn_action_if_needed, add_turn_log,
};
use crate::map::{Map, MapSetup, get_map_setup};
use crate::objective_card::gain_objective_card_from_pile;
use crate::player::{Player, gain_unit};
@ -191,21 +193,14 @@ pub fn setup_game_with_cache(setup: &GameSetup, cache: Cache) -> Game {
fn execute_setup_round(setup: &GameSetup, game: &mut Game, map_setup: Option<&MapSetup>) {
let mut age = ActionLogAge::new(0);
let mut round = ActionLogRound::new(0);
let mut turn = ActionLogTurn::new(TurnType::Setup);
turn.actions.push(ActionLogAction::new(Action::Setup));
round.turns.push(turn);
age.rounds.push(round);
age.rounds.push(ActionLogRound::new(0));
game.log.push(age);
for player_index in 0..setup.player_amount {
add_turn_log(game, TurnType::Setup(player_index));
add_start_turn_action_if_needed(game, player_index);
let origin = setup_event_origin();
let player = &EventPlayer::from_player(player_index, game, origin.clone());
player.log(
game,
&format!("Play as {}", player.get(game).civilization.name),
);
let player = &EventPlayer::new(player_index, origin.clone());
player.gain_resources(game, ResourcePile::food(2));
do_advance(game, Advance::Farming, player, false);
do_advance(game, Advance::Mining, player, false);
@ -237,7 +232,8 @@ pub(crate) fn place_home_tiles(game: &mut Game, player: &EventPlayer) {
.add_block_tiles(&h.position, &home, h.position.rotation);
}
fn setup_event_origin() -> EventOrigin {
#[must_use]
pub fn setup_event_origin() -> EventOrigin {
EventOrigin::Ability("Setup".to_string())
}
@ -299,7 +295,7 @@ pub(crate) fn execute_choose_civ(
player_index: usize,
action: &Action,
) -> Result<(), String> {
let player = EventPlayer::from_player(player_index, game, setup_event_origin());
let player = EventPlayer::new(player_index, setup_event_origin());
if let Action::ChooseCivilization(civ) = action {
game.player_mut(player_index).civilization = game.cache.get_civilization(civ);
let p = game.player_mut(player_index);
@ -315,7 +311,7 @@ pub(crate) fn execute_choose_civ(
}
player.log(
game,
&format!("Play as {}", game.player(player_index).civilization.name),
&format!("Choose {}", game.player(player_index).civilization.name),
);
Ok(())
}

View file

@ -1,12 +1,14 @@
use crate::city::{MoodState, increase_mood_state};
use crate::content::custom_actions::{CustomActionType, custom_action_modifier_event_origin};
use crate::content::custom_actions::{
PlayingActionModifier, SpecialAction, custom_action_modifier_event_origin,
};
use crate::events::EventOrigin;
use crate::game::Game;
use crate::leader::leader_position;
use crate::payment::PaymentOptions;
use crate::player::{CostTrigger, Player};
use crate::player_events::CostInfo;
use crate::playing_actions::{PlayingActionType, base_or_custom_available};
use crate::playing_actions::{PlayingActionType, base_or_modified_available};
use crate::position::Position;
use crate::resource::ResourceType;
use crate::resource_pile::ResourcePile;
@ -36,14 +38,14 @@ impl IncreaseHappiness {
#[must_use]
pub fn available_happiness_actions(game: &Game, player: usize) -> Vec<PlayingActionType> {
base_or_custom_available(game, player, &PlayingActionType::IncreaseHappiness)
base_or_modified_available(game, player, &PlayingActionType::IncreaseHappiness)
}
#[must_use]
pub fn happiness_city_restriction(player: &Player, action: &PlayingActionType) -> Option<Position> {
match action {
PlayingActionType::Custom(custom)
if custom == &CustomActionType::StatesmanIncreaseHappiness =>
PlayingActionType::Special(SpecialAction::Modifier(m))
if m == &PlayingActionModifier::StatesmanIncreaseHappiness =>
{
Some(leader_position(player))
}

View file

@ -3,12 +3,17 @@ use crate::card::{HandCard, HandCardLocation};
use crate::city::MoodState;
use crate::combat_stats::CombatStats;
use crate::events::EventOrigin;
use crate::map::Terrain;
use crate::movement::{MoveUnits, move_event_origin};
use crate::player::Player;
use crate::position::Position;
use crate::resource_pile::ResourcePile;
use crate::status_phase::StatusPhaseStateType;
use crate::structure::Structure;
use crate::unit::Units;
use crate::{action::Action, game::Game};
use json_patch::PatchOperation;
use num::Zero;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, PartialEq)]
@ -46,8 +51,8 @@ impl ActionLogRound {
#[derive(Serialize, Deserialize, Clone, PartialEq)]
pub enum TurnType {
Player(usize),
Setup,
StatusPhase,
Setup(usize),
StatusPhase(StatusPhaseStateType),
}
#[derive(Serialize, Deserialize, Clone, PartialEq)]
@ -78,9 +83,13 @@ impl ActionLogTurn {
}
}
#[derive(Serialize, Deserialize, Clone, PartialEq)]
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct ActionLogAction {
pub action: Action,
pub player: usize,
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub origin: Option<EventOrigin>,
#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
pub undo: Vec<PatchOperation>,
@ -93,31 +102,70 @@ pub struct ActionLogAction {
#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
pub log: Vec<String>,
#[serde(default)]
#[serde(skip_serializing_if = "usize::is_zero")]
pub active_events: usize,
}
impl ActionLogAction {
#[must_use]
pub fn new(action: Action) -> Self {
pub fn new(
action: Action,
player: usize,
origin: Option<EventOrigin>,
active_events: usize,
) -> Self {
Self {
action,
player,
origin,
undo: Vec::new(),
combat_stats: None,
items: Vec::new(),
log: Vec::new(),
active_events,
}
}
}
#[derive(Serialize, Deserialize, Clone, PartialEq)]
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum ActionLogIncidentToken {
Take(u8),
NoChange,
}
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum ActionLogBalance {
Gain,
Loss,
Pay, // Like loss, but for payment
}
#[derive(Serialize, Deserialize, Clone, PartialEq)]
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct ActionLogEntryStructure {
pub structure: Structure,
pub balance: ActionLogBalance,
pub position: Position,
pub port_position: Option<Position>,
}
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct ActionLogEntryMove {
pub units: Units,
pub start: Position,
pub destination: Position,
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub embark_carrier_id: Option<u32>,
}
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum ActionLogEntry {
Action {
balance: ActionLogBalance,
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
amount: Option<u32>,
},
Resources {
resources: ResourcePile,
@ -125,18 +173,15 @@ pub enum ActionLogEntry {
},
Advance {
advance: Advance,
take_incident_token: bool,
incident_token: ActionLogIncidentToken,
balance: ActionLogBalance,
},
Units {
units: Units,
balance: ActionLogBalance,
},
Structure {
structure: Structure,
balance: ActionLogBalance,
position: Position,
},
Structure(ActionLogEntryStructure),
HandCard {
card: HandCard,
from: HandCardLocation,
@ -146,37 +191,70 @@ pub enum ActionLogEntry {
city: Position,
mood: MoodState,
},
Move(ActionLogEntryMove),
Explore {
tiles: Vec<(Position, Terrain)>,
},
}
impl ActionLogEntry {
#[must_use]
pub fn balance(&self) -> Option<&ActionLogBalance> {
match self {
ActionLogEntry::Action { balance, .. }
| ActionLogEntry::Resources { balance, .. }
| ActionLogEntry::Advance { balance, .. }
| ActionLogEntry::Units { balance, .. } => Some(balance),
ActionLogEntry::Structure(s) => Some(&s.balance),
ActionLogEntry::HandCard { .. }
| ActionLogEntry::MoodChange { .. }
| ActionLogEntry::Move { .. }
| ActionLogEntry::Explore { .. } => None,
}
}
#[must_use]
pub fn resources(resources: ResourcePile, balance: ActionLogBalance) -> Self {
Self::Resources { resources, balance }
}
#[must_use]
pub fn units(units: Units, balance: ActionLogBalance) -> Self {
Self::Units { units, balance }
}
#[must_use]
pub fn advance(advance: Advance, balance: ActionLogBalance, take_incident_token: bool) -> Self {
Self::Advance {
advance,
take_incident_token,
balance,
}
}
#[must_use]
pub fn structure(structure: Structure, balance: ActionLogBalance, position: Position) -> Self {
Self::Structure {
structure,
pub fn units(units: Units, balance: ActionLogBalance, position: Position) -> Self {
Self::Units {
units,
balance,
position,
}
}
#[must_use]
pub fn advance(
advance: Advance,
balance: ActionLogBalance,
incident_token: ActionLogIncidentToken,
) -> Self {
Self::Advance {
advance,
incident_token,
balance,
}
}
#[must_use]
pub fn structure(
structure: Structure,
balance: ActionLogBalance,
position: Position,
port_position: Option<Position>,
) -> Self {
Self::Structure(ActionLogEntryStructure {
structure,
balance,
position,
port_position,
})
}
#[must_use]
pub fn hand_card(card: HandCard, from: HandCardLocation, to: HandCardLocation) -> Self {
Self::HandCard { card, from, to }
@ -188,20 +266,42 @@ impl ActionLogEntry {
}
#[must_use]
pub fn action(balance: ActionLogBalance) -> Self {
Self::Action { balance }
pub fn action(balance: ActionLogBalance, amount: u32) -> Self {
Self::Action {
balance,
amount: if amount == 1 { None } else { Some(amount) },
}
}
#[must_use]
pub fn move_units(player: &Player, m: &MoveUnits) -> Self {
Self::Move(ActionLogEntryMove {
units: m
.units
.iter()
.map(|unit| player.get_unit(*unit).unit_type)
.collect::<Units>(),
start: player.get_unit(m.units[0]).position,
destination: m.destination,
embark_carrier_id: m.embark_carrier_id,
})
}
#[must_use]
pub(crate) fn explore_tiles(tiles: Vec<(Position, Terrain)>) -> ActionLogEntry {
Self::Explore { tiles }
}
}
#[derive(Serialize, Deserialize, Clone, PartialEq)]
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct ActionLogItem {
pub player: usize,
#[serde(flatten)]
pub entry: ActionLogEntry,
origin: EventOrigin,
pub origin: EventOrigin,
#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
modifiers: Vec<EventOrigin>,
pub modifiers: Vec<EventOrigin>,
}
impl ActionLogItem {
@ -243,13 +343,26 @@ pub(crate) fn linear_action_log(game: &Game) -> Vec<Action> {
}
pub(crate) fn add_log_action(game: &mut Game, item: Action) {
let active_events = game.events.len();
let player = game.active_player();
let origin = action_origin(&item, game.player(player)).clone();
let i = game.log_index;
let l = &mut current_turn_log_mut(game).actions;
remove_redo_actions(l, i);
l.push(ActionLogAction::new(item));
l.push(ActionLogAction::new(item, player, origin, active_events));
game.log_index += 1;
}
fn action_origin(a: &Action, player: &Player) -> Option<EventOrigin> {
match a {
Action::Playing(p) => Some(p.playing_action_type(player).origin(player).clone()),
Action::Movement(_) => Some(move_event_origin()),
Action::Undo => panic!("Unexpected undo in log"),
Action::Redo => panic!("Unexpected redo in log"),
Action::StartTurn | Action::Response(_) | Action::ChooseCivilization(_) => None,
}
}
fn remove_redo_actions(l: &mut Vec<ActionLogAction>, action_log_index: usize) {
if action_log_index < l.len() {
// remove items from undo
@ -274,10 +387,11 @@ pub(crate) fn add_action_log_item(
.push(ActionLogItem::new(player, entry, origin, modifiers));
}
pub(crate) fn add_start_turn_action_if_needed(game: &mut Game) {
pub(crate) fn add_start_turn_action_if_needed(game: &mut Game, player: usize) {
let p = current_turn_log_mut(game);
if p.actions.is_empty() {
p.actions.push(ActionLogAction::new(Action::StartTurn));
p.actions
.push(ActionLogAction::new(Action::StartTurn, player, None, 0));
game.log_index += 1;
}
}

View file

@ -13,6 +13,7 @@ use crate::events::{EventOrigin, EventPlayer};
use crate::explore::move_to_unexplored_tile;
use crate::game::GameState::Movement;
use crate::game::{Game, GameContext, GameState};
use crate::log::ActionLogEntry;
use crate::move_routes::{MoveRoute, move_routes};
use crate::movement::MovementAction::{Move, Stop};
use crate::payment::PaymentOptions;
@ -285,16 +286,18 @@ pub(crate) fn execute_movement_action(
action: MovementAction,
player_index: usize,
) -> Result<(), String> {
let player = EventPlayer::from_player(player_index, game, move_event_origin());
let player = EventPlayer::new(player_index, move_event_origin());
match &action {
Move(m) if m.units.is_empty() => {
player.log(game, "Used a movement actions but moved no units");
}
Move(m) => player.log(game, &move_action_log(game, player.get(game), m)),
Move(m) => {
player.add_action_log_item(game, ActionLogEntry::move_units(player.get(game), m));
}
Stop => player.log(game, "End the movement action"),
}
let p = &EventPlayer::from_player(player_index, game, move_event_origin());
let p = &EventPlayer::new(player_index, move_event_origin());
if let GameState::Playing = game.state {
if game.actions_left == 0 && game.context != GameContext::Replay {
return Err("No actions left".to_string());
@ -651,42 +654,7 @@ fn can_embark(game: &Game, player: &Player, unit: &Unit) -> bool {
})
}
pub(crate) fn move_action_log(game: &Game, player: &Player, m: &MoveUnits) -> String {
let units_str = m
.units
.iter()
.map(|unit| player.get_unit(*unit).unit_type)
.collect::<Units>()
.to_string(Some(game));
let start = player.get_unit(m.units[0]).position;
let start_is_water = game.map.is_sea(start);
let dest = m.destination;
let t = game
.map
.get(dest)
.expect("the destination position should be on the map");
let (verb, suffix) = if start_is_water {
if t.is_unexplored() || t.is_water() {
("sailed", "")
} else {
("disembarked", "")
}
} else if m.embark_carrier_id.is_some() {
("embarked", "")
} else if start.is_neighbor(dest) {
("marched", "")
} else {
("marched", " on roads")
};
let payment = &m.payment;
let cost = if payment.is_empty() {
String::new()
} else {
format!(" for {payment}")
};
format!("{verb} {units_str} from {start} to {dest}{suffix}{cost}",)
}
pub(crate) fn move_event_origin() -> EventOrigin {
#[must_use]
pub fn move_event_origin() -> EventOrigin {
EventOrigin::Ability("Move".to_string())
}

View file

@ -330,7 +330,7 @@ pub(crate) fn complete_objective_card(game: &mut Game, player: usize, id: u8, ob
{
s(
game,
&EventPlayer::from_player(player, game, EventOrigin::Objective(objective.to_string())),
&EventPlayer::new(player, EventOrigin::Objective(objective.to_string())),
);
}

View file

@ -248,7 +248,7 @@ fn cities_with_adjacent_pirates(player: &Player, game: &Game) -> Vec<Position> {
#[must_use]
pub(crate) fn get_pirates_event_player(game: &Game, origin: &EventOrigin) -> EventPlayer {
let player = get_pirates_player(game);
EventPlayer::new(player.index, player.get_name(), origin.clone())
EventPlayer::new(player.index, origin.clone())
}
///

View file

@ -2,7 +2,9 @@ use crate::advance::{Advance, base_advance_cost, player_government};
use crate::city_pieces::DestroyedStructures;
use crate::consts::{STACK_LIMIT, UNIT_LIMIT_BARBARIANS, UNIT_LIMIT_PIRATES};
use crate::content::ability::construct_event_origin;
use crate::content::custom_actions::{CustomActionExecution, CustomActionInfo};
use crate::content::custom_actions::{
PlayingActionModifier, SpecialAction, SpecialActionExecution, SpecialActionInfo,
};
use crate::events::{Event, EventOrigin, EventPlayer};
use crate::game_setup::all_leaders;
use crate::leader::Leader;
@ -23,7 +25,6 @@ use crate::{
city_pieces::Building::{self},
civilization::Civilization,
consts::{BUILDING_COST, CITY_LIMIT, CITY_PIECE_LIMIT, UNIT_LIMIT},
content::custom_actions::CustomActionType,
game::Game,
leader::LeaderInfo,
player_events::PlayerEvents,
@ -35,7 +36,6 @@ use enumset::EnumSet;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt::Display;
#[derive(Serialize, Deserialize, PartialEq, Eq)]
pub enum PlayerType {
@ -66,12 +66,12 @@ pub struct Player {
pub completed_objectives: Vec<CompletedObjective>,
pub captured_leaders: Vec<Leader>,
pub special_victory_points: Vec<SpecialVictoryPoints>,
pub custom_actions: HashMap<CustomActionType, CustomActionInfo>, // transient
pub special_actions: HashMap<SpecialAction, SpecialActionInfo>, // transient
pub wonder_cards: Vec<Wonder>,
pub action_cards: Vec<u8>,
pub objective_cards: Vec<u8>,
pub next_unit_id: u32,
pub played_once_per_turn_actions: Vec<CustomActionType>,
pub played_once_per_turn_actions: Vec<SpecialAction>,
pub event_info: HashMap<String, String>,
pub secrets: Vec<String>,
pub custom_data: HashMap<String, Data>,
@ -80,12 +80,6 @@ pub struct Player {
pub(crate) great_mausoleum_action_cards: u8, // transient
}
impl Display for Player {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.get_name())
}
}
#[derive(PartialEq, Eq, Copy, Clone)]
pub enum CostTrigger {
WithModifiers,
@ -119,7 +113,7 @@ impl Player {
completed_objectives: Vec::new(),
captured_leaders: Vec::new(),
special_victory_points: Vec::new(),
custom_actions: HashMap::new(),
special_actions: HashMap::new(),
wonder_cards: Vec::new(),
action_cards: Vec::new(),
objective_cards: Vec::new(),
@ -506,28 +500,27 @@ impl Player {
/// # Panics
/// Panics if the custom action type does not exist for this player
#[must_use]
pub fn custom_action_info(&self, custom_action_type: CustomActionType) -> CustomActionInfo {
self.custom_actions
.get(&custom_action_type)
pub fn special_action_info(&self, a: &SpecialAction) -> SpecialActionInfo {
self.special_actions
.get(a)
.cloned()
.unwrap_or_else(|| {
panic!(
"Custom action {custom_action_type:?} not found for player {}",
self.index
)
})
.unwrap_or_else(|| panic!("Custom action {a:?} not found for player {}", self.index))
}
#[must_use]
pub(crate) fn custom_action_modifiers(
&self,
base: &PlayingActionType,
) -> Vec<CustomActionType> {
self.custom_actions
) -> Vec<PlayingActionModifier> {
self.special_actions
.iter()
.filter_map(move |(t, c)| {
if let CustomActionExecution::Modifier(b) = &c.execution {
(b == base).then_some(*t)
if let SpecialActionExecution::Modifier(b) = &c.execution {
(b == base).then_some(if let SpecialAction::Modifier(m) = t {
*m
} else {
unreachable!()
})
} else {
None
}
@ -583,15 +576,10 @@ pub fn gain_units(
}
}
game.log(
player,
origin,
&format!("Gain {} at {}", units.to_string(Some(game)), position),
);
add_action_log_item(
game,
player,
ActionLogEntry::units(units, ActionLogBalance::Gain),
ActionLogEntry::units(units, ActionLogBalance::Gain, position),
origin.clone(),
vec![],
);

View file

@ -14,8 +14,8 @@ use crate::content::ability::{
Ability, advance_event_origin, construct_event_origin, recruit_event_origin,
};
use crate::content::custom_actions::{
CustomAction, CustomActionActivation, CustomActionType, can_play_custom_action,
log_start_custom_action, on_custom_action,
CustomAction, CustomActionActivation, PlayingActionModifier, SpecialAction,
can_play_special_action, on_custom_action,
};
use crate::content::persistent_events::{
PaymentRequest, PersistentEventType, TriggerPersistentEventParams, trigger_persistent_event_ext,
@ -29,6 +29,7 @@ use crate::happiness::{
IncreaseHappiness, execute_increase_happiness, happiness_base_event_origin,
happiness_event_origin,
};
use crate::log::{ActionLogBalance, ActionLogEntry};
use crate::movement::move_event_origin;
use crate::payment::PaymentOptions;
use crate::player::Player;
@ -48,7 +49,7 @@ pub enum PlayingActionType {
InfluenceCultureAttempt,
ActionCard(u8),
WonderCard(Wonder),
Custom(CustomActionType),
Special(SpecialAction),
EndTurn,
}
@ -67,8 +68,8 @@ impl PlayingActionType {
let p = game.player(player_index);
match self {
PlayingActionType::Custom(c) => {
can_play_custom_action(game, p, *c)?;
PlayingActionType::Special(c) => {
can_play_special_action(game, p, *c)?;
}
PlayingActionType::ActionCard(id) => {
can_play_civil_card(game, p, *id)?;
@ -98,9 +99,9 @@ impl PlayingActionType {
#[must_use]
pub fn cost(&self, game: &Game, player: usize) -> ActionCost {
match self {
PlayingActionType::Custom(custom_action) => game
PlayingActionType::Special(custom_action) => game
.player(player)
.custom_action_info(*custom_action)
.special_action_info(custom_action)
.cost
.cost
.clone(),
@ -135,11 +136,9 @@ impl PlayingActionType {
PlayingActionType::InfluenceCultureAttempt => influence_base_origin(),
PlayingActionType::ActionCard(a) => EventOrigin::CivilCard(*a),
PlayingActionType::WonderCard(w) => EventOrigin::Wonder(*w),
PlayingActionType::Custom(c) => player.custom_action_info(*c).event_origin,
PlayingActionType::Special(c) => player.special_action_info(c).event_origin,
PlayingActionType::MoveUnits => move_event_origin(),
PlayingActionType::EndTurn => panic!(
"PlayingAction::origin called on an action that does not have an origin: EndTurn",
),
PlayingActionType::EndTurn => end_turn_origin(),
}
}
}
@ -175,7 +174,7 @@ impl PlayingAction {
if !action_cost.free {
pay_action(
game,
&EventPlayer::from_player(player_index, game, playing_action_type.origin(p)),
&EventPlayer::new(player_index, playing_action_type.origin(p)),
);
}
@ -188,51 +187,19 @@ impl PlayingAction {
player_index: usize,
) -> Result<(), String> {
// log these before the payment for clarity
match &self {
PlayingAction::Custom(a) => {
log_start_custom_action(game, player_index, a);
}
PlayingAction::ActionCard(id) => {
discard_action_card(
game,
player_index,
*id,
&EventOrigin::Ability("Action Card".to_string()),
HandCardLocation::PlayToDiscard,
);
}
_ => {}
}
let action_type = self.playing_action_type(game.player(player_index));
let origin_override = match action_type {
PlayingActionType::Custom(c) => {
if let Some(key) = &game
.player(player_index)
.custom_action_info(c)
.cost
.once_per_turn
{
game.players[player_index]
.played_once_per_turn_actions
.push(*key);
}
Some(game.player(player_index).custom_action_info(c).event_origin)
}
PlayingActionType::ActionCard(c) => Some(EventOrigin::CivilCard(c)),
_ => None,
};
let payment_options = action_type.payment_options(game, player_index);
if !payment_options.is_free() {
game.log(
if let PlayingAction::ActionCard(id) = &self {
discard_action_card(
game,
player_index,
&payment_options.origin,
&format!("Pay {}", payment_options.default,),
*id,
&EventOrigin::Ability("Action Card".to_string()),
HandCardLocation::PlayToDiscard,
);
}
ActionPayment::new(self).on_pay_action(game, player_index, origin_override)
let action_type = self.playing_action_type(game.player(player_index));
let override_origin = add_override_origin(game, player_index, &action_type);
ActionPayment::new(self).on_pay_action(game, player_index, override_origin)
}
pub(crate) fn execute_without_cost(
@ -309,7 +276,7 @@ impl PlayingAction {
),
PlayingAction::ActionCard(a) => PlayingActionType::ActionCard(*a),
PlayingAction::WonderCard(name) => PlayingActionType::WonderCard(*name),
PlayingAction::Custom(c) => PlayingActionType::Custom(c.action),
PlayingAction::Custom(c) => PlayingActionType::Special(SpecialAction::Custom(c.action)),
PlayingAction::EndTurn => PlayingActionType::EndTurn,
}
}
@ -321,7 +288,7 @@ fn assert_allowed_action_type(
player: &Player,
) -> PlayingActionType {
match playing_action_type {
PlayingActionType::Custom(c) => {
PlayingActionType::Special(SpecialAction::Modifier(c)) => {
assert!(player.custom_action_modifiers(base_type).contains(c));
}
_ => {
@ -332,7 +299,7 @@ fn assert_allowed_action_type(
}
#[must_use]
pub(crate) fn base_or_custom_available(
pub(crate) fn base_or_modified_available(
game: &Game,
player: usize,
base: &PlayingActionType,
@ -343,7 +310,7 @@ pub(crate) fn base_or_custom_available(
game.player(player)
.custom_action_modifiers(base)
.iter()
.map(CustomActionType::playing_action_type),
.map(PlayingActionModifier::playing_action_type),
)
.filter_map(|a| a.is_available(game, player).map(|()| a).ok())
.collect()
@ -423,10 +390,43 @@ pub(crate) fn pay_for_action() -> Ability {
}
fn end_turn(game: &mut Game, player: usize) {
game.log(
player,
&EventOrigin::Ability("End Turn".to_string()),
&format!("{} actions left", game.actions_left),
);
if game.actions_left > 0 {
EventPlayer::new(player, end_turn_origin()).add_action_log_item(
game,
ActionLogEntry::action(ActionLogBalance::Loss, game.actions_left),
);
}
game.next_turn();
}
pub(crate) fn end_turn_origin() -> EventOrigin {
EventOrigin::Ability("End Turn".to_string())
}
fn add_override_origin(
game: &mut Game,
player_index: usize,
action_type: &PlayingActionType,
) -> Option<EventOrigin> {
match action_type {
PlayingActionType::Special(c) => {
if let Some(key) = &game
.player(player_index)
.special_action_info(c)
.cost
.once_per_turn
{
game.players[player_index]
.played_once_per_turn_actions
.push(*key);
}
Some(
game.player(player_index)
.special_action_info(c)
.event_origin,
)
}
PlayingActionType::ActionCard(c) => Some(EventOrigin::CivilCard(*c)),
_ => None,
}
}

View file

@ -1,11 +1,10 @@
use crate::content::persistent_events::PaymentRequest;
use crate::events::EventOrigin;
use crate::events::{EventOrigin, EventPlayer};
use crate::game::Game;
use crate::log::{ActionLogBalance, ActionLogEntry, add_action_log_item};
use crate::payment::PaymentOptions;
use crate::player::Player;
use crate::resource_pile::ResourcePile;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use std::{fmt, mem};
@ -91,22 +90,7 @@ pub(crate) fn gain_resources_with_modifiers(
origin: EventOrigin,
modifiers: Vec<EventOrigin>,
) {
if modifiers.is_empty() {
game.log(player, &origin, &format!("Gain {resources}"));
} else {
let modifier_names = modifiers
.iter()
.map(|m| m.name(game))
.collect_vec()
.join(", ");
game.log(
player,
&origin,
&format!("Gain {resources} with {modifier_names}"),
);
}
let p = game.player_mut(player);
p.resources += resources.clone();
apply_resource_limit(p);
add_action_log_item(
@ -129,10 +113,9 @@ pub(crate) fn check_for_waste(game: &mut Game) {
let wasted_resources =
mem::replace(&mut game.players[p].wasted_resources, ResourcePile::empty());
if !wasted_resources.is_empty() {
game.log(
p,
&EventOrigin::Ability("Waste".to_string()),
&format!("Could not store {wasted_resources}",),
EventPlayer::new(p, EventOrigin::Ability("Waste".to_string())).add_action_log_item(
game,
ActionLogEntry::resources(wasted_resources, ActionLogBalance::Loss),
);
}
}
@ -144,6 +127,7 @@ pub(crate) fn lose_resources(
resources: ResourcePile,
origin: EventOrigin,
modifiers: Vec<EventOrigin>,
balance: ActionLogBalance,
) {
let p = game.player_mut(player);
assert!(
@ -155,7 +139,7 @@ pub(crate) fn lose_resources(
add_action_log_item(
game,
player,
ActionLogEntry::resources(resources, ActionLogBalance::Loss),
ActionLogEntry::resources(resources, balance),
origin,
modifiers,
);
@ -191,20 +175,6 @@ fn log_payment(game: &mut Game, player: usize, payment: &ResourcePile, cost: &Pa
payment.clone(),
cost.origin.clone(),
cost.modifiers.clone(),
ActionLogBalance::Pay,
);
if cost.modifiers.is_empty() {
game.log(player, &cost.origin, &format!("Pay {payment}"));
} else {
let modifiers = cost
.modifiers
.iter()
.map(|m| m.name(game))
.collect_vec()
.join(", ");
game.log(
player,
&cost.origin,
&format!("Pay {payment} with {modifiers}"),
);
}
}

View file

@ -10,7 +10,7 @@ use crate::content::persistent_events::{
trigger_persistent_event_with_listener,
};
use crate::events::{EventOrigin, EventPlayer};
use crate::log::{TurnType, add_turn_log};
use crate::log::{TurnType, add_start_turn_action_if_needed, add_turn_log};
use crate::objective_card::{
gain_objective_card_from_pile, present_objective_cards, status_phase_completable,
};
@ -22,6 +22,16 @@ use itertools::Itertools;
use serde::{Deserialize, Serialize};
use std::fmt::Display;
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug, Hash, Copy)]
pub enum StatusPhaseStateType {
CompleteObjectives,
FreeAdvance,
DrawCards,
RazeSize1City,
ChangeGovernmentType,
DetermineFirstPlayer,
}
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug, Hash)]
pub enum StatusPhaseState {
CompleteObjectives,
@ -32,15 +42,15 @@ pub enum StatusPhaseState {
DetermineFirstPlayer(usize),
}
impl Display for StatusPhaseState {
impl Display for StatusPhaseStateType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
StatusPhaseState::CompleteObjectives => write!(f, "Complete Objectives"),
StatusPhaseState::FreeAdvance => write!(f, "Free Advance"),
StatusPhaseState::DrawCards => write!(f, "Draw Cards"),
StatusPhaseState::RazeSize1City => write!(f, "Raze Size 1 City"),
StatusPhaseState::ChangeGovernmentType(_) => write!(f, "Change Government"),
StatusPhaseState::DetermineFirstPlayer(_) => write!(f, "Determine First Player"),
StatusPhaseStateType::CompleteObjectives => write!(f, "Complete Objectives"),
StatusPhaseStateType::FreeAdvance => write!(f, "Free Advance"),
StatusPhaseStateType::DrawCards => write!(f, "Draw Cards"),
StatusPhaseStateType::RazeSize1City => write!(f, "Raze Size 1 City"),
StatusPhaseStateType::ChangeGovernmentType => write!(f, "Change Government"),
StatusPhaseStateType::DetermineFirstPlayer => write!(f, "Determine First Player"),
}
}
}
@ -72,19 +82,31 @@ pub fn get_status_phase(game: &Game) -> Option<&StatusPhaseState> {
}
pub(crate) fn enter_status_phase(game: &mut Game) {
add_turn_log(game, TurnType::StatusPhase);
play_status_phase(game, StatusPhaseState::CompleteObjectives);
play_status_phase(game, StatusPhaseState::CompleteObjectives, false);
}
pub(crate) fn play_status_phase(game: &mut Game, mut phase: StatusPhaseState) {
pub(crate) fn status_phase_response(game: &mut Game, phase: StatusPhaseState) {
play_status_phase(game, phase, true);
}
fn play_status_phase(game: &mut Game, mut phase: StatusPhaseState, response: bool) {
use StatusPhaseState::*;
loop {
let t = status_phase_type(&phase);
if game.events.is_empty() {
add_turn_log(game, TurnType::StatusPhase(t));
// needed for draw cards
if response {
add_start_turn_action_if_needed(game, game.active_player());
}
game.player_changed();
}
phase = match trigger_persistent_event_with_listener(
game,
&game.human_players_sorted(game.starting_player_index),
|events| &mut events.status_phase,
&game.cache.status_phase_handler(&phase).listeners.clone(),
&game.cache.status_phase_handler(&t).listeners.clone(),
phase,
PersistentEventType::StatusPhase,
TriggerPersistentEventParams::default(),
@ -323,10 +345,11 @@ where
p.log(
game,
&format!(
"{p} changed their government from {} to {}",
"{} changed their government from {} to {}",
p.get(game)
.government(game)
.expect("player should have a government before changing it"),
p.name(game),
c.new_government
),
);
@ -497,6 +520,18 @@ fn player_that_chooses_next_first_player(players: &[&Player]) -> usize {
.index
}
#[must_use]
pub fn status_phase_type(p: &StatusPhaseState) -> StatusPhaseStateType {
match p {
StatusPhaseState::CompleteObjectives => StatusPhaseStateType::CompleteObjectives,
StatusPhaseState::FreeAdvance => StatusPhaseStateType::FreeAdvance,
StatusPhaseState::DrawCards => StatusPhaseStateType::DrawCards,
StatusPhaseState::RazeSize1City => StatusPhaseStateType::RazeSize1City,
StatusPhaseState::ChangeGovernmentType(_) => StatusPhaseStateType::ChangeGovernmentType,
StatusPhaseState::DetermineFirstPlayer(_) => StatusPhaseStateType::DetermineFirstPlayer,
}
}
#[cfg(test)]
mod tests {
use crate::civilization::Civilization;

View file

@ -31,8 +31,14 @@ pub(crate) fn log_gain_city(
structure: Structure,
position: Position,
) {
player.log(game, &format!("Gain city {position}"));
log_structure(game, player, structure, ActionLogBalance::Gain, position);
log_structure(
game,
player,
structure,
ActionLogBalance::Gain,
position,
None,
);
}
pub(crate) fn log_lose_city(
@ -41,8 +47,14 @@ pub(crate) fn log_lose_city(
structure: Structure,
position: Position,
) {
player.log(game, &format!("Lose city {position}"));
log_structure(game, player, structure, ActionLogBalance::Loss, position);
log_structure(
game,
player,
structure,
ActionLogBalance::Loss,
position,
None,
);
}
pub(crate) fn log_structure(
@ -51,11 +63,12 @@ pub(crate) fn log_structure(
structure: Structure,
balance: ActionLogBalance,
position: Position,
port_position: Option<Position>,
) {
add_action_log_item(
game,
player.index,
ActionLogEntry::structure(structure, balance, position),
ActionLogEntry::structure(structure, balance, position, port_position),
player.origin.clone(),
vec![],
);

View file

@ -602,19 +602,10 @@ pub(crate) fn kill_units_without_event(
.iter()
.map(|id| p.get_unit(*id).unit_type)
.collect::<Units>();
game.log(
player,
origin,
&format!(
"Lost {} at {}",
units.to_string(Some(game)),
killed_units.position
),
);
add_action_log_item(
game,
player,
ActionLogEntry::units(units, ActionLogBalance::Loss),
ActionLogEntry::units(units, ActionLogBalance::Loss, killed_units.position),
origin.clone(),
vec![],
);

View file

@ -534,13 +534,13 @@ pub(crate) fn gain_wonder(
wonder: Wonder,
city_position: Position,
) {
player.log(game, &format!("Gain {} at {city_position}", wonder.name()));
log_structure(
game,
player,
Structure::Wonder(wonder),
ActionLogBalance::Gain,
city_position,
None,
);
let p = player.get_mut(game);
p.get_city_mut(city_position).pieces.wonders.push(wonder);
@ -570,13 +570,13 @@ pub(crate) fn lose_wonder(
"Player does not own the wonder to lose it"
);
player.log(game, &format!("Lose {} at {city_position}", wonder.name()));
log_structure(
game,
player,
Structure::Wonder(wonder),
ActionLogBalance::Loss,
city_position,
None,
);
let p = game.player_mut(player.index);
@ -655,7 +655,7 @@ pub(crate) fn use_draw_replacement_wonder() -> Ability {
|game, p, ()| {
let player = p.get_mut(game);
if player.event_info.remove(DRAW_REPLACEMENT_WONDER).is_some() {
add_start_turn_action_if_needed(game);
add_start_turn_action_if_needed(game, game.active_player());
p.log(game, "Draw a replacement wonder card");
draw_wonder_card(game, p);
}

View file

@ -8,7 +8,9 @@ use server::city_pieces::Building::{Academy, Fortress, Temple};
use server::collect::{PositionCollection, possible_resource_collections};
use server::consts::BUILDING_COST;
use server::content::advances::trade_routes::find_trade_routes;
use server::content::custom_actions::{CustomAction, CustomActionType};
use server::content::custom_actions::{
CustomAction, CustomActionType, PlayingActionModifier, SpecialAction,
};
use server::content::persistent_events::{EventResponse, SelectedStructure};
use server::cultural_influence::InfluenceCultureAttempt;
use server::events::{EventOrigin, check_event_origin};
@ -227,7 +229,9 @@ fn test_increase_happiness_voting() {
(Position::from_offset("B3"), 2),
],
ResourcePile::mood_tokens(6),
PlayingActionType::Custom(CustomActionType::VotingIncreaseHappiness),
PlayingActionType::Special(SpecialAction::Modifier(
PlayingActionModifier::VotingIncreaseHappiness,
)),
),
)),
)],
@ -247,7 +251,9 @@ fn test_increase_happiness_voting_rituals() {
(Position::from_offset("B3"), 2),
],
ResourcePile::new(1, 0, 1, 3, 1, 0, 0),
PlayingActionType::Custom(CustomActionType::VotingIncreaseHappiness),
PlayingActionType::Special(SpecialAction::Modifier(
PlayingActionModifier::VotingIncreaseHappiness,
)),
),
)),
)],
@ -611,7 +617,9 @@ fn test_collect_free_economy() {
PositionCollection::new(Position::from_offset("B1"), ResourcePile::ore(1)),
PositionCollection::new(Position::from_offset("B2"), ResourcePile::ore(1)),
],
PlayingActionType::Custom(CustomActionType::FreeEconomyCollect),
PlayingActionType::Special(SpecialAction::Modifier(
PlayingActionModifier::FreeEconomyCollect,
)),
))),
)
.skip_json(),
@ -641,7 +649,9 @@ fn test_cultural_influence_instant_with_arts() {
Position::from_offset("C2"),
Structure::Building(Fortress),
),
PlayingActionType::Custom(CustomActionType::ArtsInfluenceCultureAttempt),
PlayingActionType::Special(SpecialAction::Modifier(
PlayingActionModifier::ArtsInfluenceCultureAttempt,
)),
),
)),
)

View file

@ -1,7 +1,7 @@
use crate::common::{JsonTest, TestAction, custom_action, move_action, payment_response};
use server::action::Action;
use server::city_pieces::Building;
use server::content::custom_actions::CustomActionType;
use server::content::custom_actions::{CustomActionType, PlayingActionModifier, SpecialAction};
use server::content::persistent_events::{EventResponse, SelectedStructure};
use server::cultural_influence::{InfluenceCultureAttempt, affordable_start_city};
use server::playing_actions::{PlayingAction, PlayingActionType};
@ -45,8 +45,9 @@ fn sparta_battle() {
fn hellenistic_culture_staring_point() {
let game = &JSON.load_game("hellenistic_culture");
let action_type =
&PlayingActionType::Custom(CustomActionType::HellenisticInfluenceCultureAttempt);
let action_type = &PlayingActionType::Special(SpecialAction::Modifier(
PlayingActionModifier::HellenisticInfluenceCultureAttempt,
));
assert_eq!(
affordable_start_city(
game,
@ -84,9 +85,9 @@ fn hellenistic_culture_cost() {
Position::from_offset("C2"),
Structure::Building(Building::Port),
),
PlayingActionType::Custom(
CustomActionType::HellenisticInfluenceCultureAttempt,
),
PlayingActionType::Special(SpecialAction::Modifier(
PlayingActionModifier::HellenisticInfluenceCultureAttempt,
)),
),
)),
)

View file

@ -5,7 +5,7 @@ use server::action::Action;
use server::advance::Advance;
use server::city_pieces::Building;
use server::construct::Construct;
use server::content::custom_actions::CustomActionType;
use server::content::custom_actions::{CustomActionType, PlayingActionModifier, SpecialAction};
use server::happiness::IncreaseHappiness;
use server::movement::{MoveUnits, MovementAction};
use server::playing_actions::{PlayingAction, PlayingActionType};
@ -113,7 +113,9 @@ fn statesman() {
Action::Playing(PlayingAction::IncreaseHappiness(IncreaseHappiness::new(
vec![(Position::from_offset("A1"), 1)],
ResourcePile::mood_tokens(2),
PlayingActionType::Custom(CustomActionType::StatesmanIncreaseHappiness),
PlayingActionType::Special(SpecialAction::Modifier(
PlayingActionModifier::StatesmanIncreaseHappiness,
)),
))),
)],
);

View file

@ -63,7 +63,7 @@ fn test_large_civ() {
])),
)
.skip_json(),
TestAction::undoable(
TestAction::not_undoable(
0,
Action::Response(EventResponse::SelectHandCards(vec![
HandCard::ObjectiveCard(7),
@ -103,7 +103,7 @@ fn test_standing_army() {
"standing_army",
vec![
TestAction::not_undoable(1, Action::Playing(PlayingAction::EndTurn)).skip_json(),
TestAction::undoable(
TestAction::not_undoable(
0,
Action::Response(EventResponse::SelectHandCards(vec![
HandCard::ObjectiveCard(14),

View file

@ -28,11 +28,12 @@ fn test_free_advance() {
JSON.test(
"free_advance",
vec![
TestAction::not_undoable(0, Action::Playing(PlayingAction::EndTurn)),
TestAction::not_undoable(0, Action::Playing(PlayingAction::EndTurn)).skip_json(),
TestAction::not_undoable(
1,
Action::Response(EventResponse::SelectAdvance(advance::Advance::Storage)),
),
)
.skip_json(),
TestAction::not_undoable(
0,
Action::Response(EventResponse::SelectAdvance(advance::Advance::Philosophy)),
@ -117,7 +118,7 @@ fn test_keep_government() {
vec![
TestAction::not_undoable(1, Action::Response(EventResponse::SelectPositions(vec![])))
.skip_json(),
TestAction::undoable(0, payment_response(ResourcePile::empty())),
TestAction::not_undoable(0, payment_response(ResourcePile::empty())),
],
);
}

View file

@ -198,6 +198,10 @@
"ActionCard": 2
}
},
"player": 0,
"origin": {
"CivilCard": 2
},
"items": [
{
"player": 0,
@ -214,10 +218,6 @@
"Ability": "Action Card"
}
}
],
"log": [
"Player1: Action Card: Play Quick Advance/Encircled",
"Player1: Quick Advance: Pay 1 culture token"
]
},
{
@ -230,6 +230,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -237,16 +238,14 @@
"resources": {
"culture_tokens": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 2
}
}
],
"log": [
"Player1: Quick Advance: Pay 1 culture token"
]
"active_events": 1
},
{
"action": {
@ -254,6 +253,7 @@
"SelectAdvance": "Storage"
}
},
"player": 0,
"items": [
{
"player": 0,
@ -271,7 +271,7 @@
"player": 0,
"Advance": {
"advance": "Storage",
"take_incident_token": false,
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
@ -279,10 +279,7 @@
}
}
],
"log": [
"Player1: Storage: Gain 1 mood token",
"Player1: Quick Advance: Gain Storage without taking an event token"
]
"active_events": 1
}
]
}
@ -316,4 +313,4 @@
"action_cards_discarded": [
2
]
}
}

View file

@ -226,6 +226,10 @@
"ActionCard": 27
}
},
"player": 0,
"origin": {
"CivilCard": 27
},
"items": [
{
"player": 0,
@ -242,10 +246,6 @@
"Ability": "Action Card"
}
}
],
"log": [
"Player1: Action Card: Play Assassination/High Ground",
"Player1: Assassination: Pay 1 culture token"
]
},
{
@ -258,6 +258,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -265,7 +266,7 @@
"resources": {
"culture_tokens": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 27
@ -273,15 +274,29 @@
}
],
"log": [
"Player1: Assassination: Pay 1 culture token, Assassinated Player2"
]
"Player1: Assassination: Assassinated Player2"
],
"active_events": 1
},
{
"action": {
"Playing": "EndTurn"
},
"log": [
"Player1: End Turn: 3 actions left"
"player": 0,
"origin": {
"Ability": "End Turn"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss",
"amount": 3
},
"origin": {
"Ability": "End Turn"
}
}
]
}
]
@ -293,6 +308,7 @@
"actions": [
{
"action": "StartTurn",
"player": 1,
"items": [
{
"player": 1,
@ -303,17 +319,27 @@
"Ability": "Assassination"
}
}
],
"log": [
"Player2: Assassination: Lose 1 action"
]
},
{
"action": {
"Playing": "EndTurn"
},
"log": [
"Player2: End Turn: 2 actions left"
"player": 1,
"origin": {
"Ability": "End Turn"
},
"items": [
{
"player": 1,
"Action": {
"balance": "Loss",
"amount": 2
},
"origin": {
"Ability": "End Turn"
}
}
]
}
]

View file

@ -217,11 +217,15 @@
"ActionCard": 17
}
},
"player": 0,
"origin": {
"CivilCard": 17
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 17
@ -242,10 +246,6 @@
"Ability": "Action Card"
}
}
],
"log": [
"Player1: City Development: Pay 1 action, Pay 1 culture token",
"Player1: Action Card: Play City Development/Tactical Retreat"
]
},
{
@ -258,6 +258,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -265,7 +266,7 @@
"resources": {
"culture_tokens": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 17
@ -282,8 +283,9 @@
}
],
"log": [
"Player1: City Development: Pay 1 culture token, Gain 1 action, You may build a building in a city without spending an action and without paying resources."
]
"Player1: City Development: You may build a building in a city without spending an action and without paying resources."
],
"active_events": 1
},
{
"action": {
@ -296,11 +298,15 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Construct Building"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Construct Building"
@ -310,7 +316,7 @@
"player": 0,
"Resources": {
"resources": {},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Construct Building"
@ -331,7 +337,8 @@
"Building": "Fortress"
},
"balance": "Gain",
"position": "C2"
"position": "C2",
"port_position": null
},
"origin": {
"Ability": "Construct Building"
@ -339,7 +346,6 @@
}
],
"log": [
"Player1: Construct Building: Pay 1 action, Pay nothing with Captivi, Construct Only, Gain Fortress at C2",
"Player1: Captivi: May replace resources with mood tokens"
]
}

View file

@ -235,6 +235,10 @@
"ActionCard": 15
}
},
"player": 0,
"origin": {
"CivilCard": 15
},
"items": [
{
"player": 0,
@ -253,7 +257,6 @@
}
],
"log": [
"Player1: Action Card: Play Cultural Takeover/Heavy Resistance",
"Player1: Cultural Takeover: You may influence Barbarian cities of size 1."
]
},
@ -269,11 +272,15 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Influence Culture"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Influence Culture"
@ -281,7 +288,7 @@
}
],
"log": [
"Player1: Influence Culture: Pay 1 action, Tried to influence the City Center in the city at B3 by Barbarians with the city A1 and may pay 2 culture tokens to boost the range"
"Player1: Influence Culture: Tried to influence the City Center in the city at B3 by Barbarians with the city A1 and may pay 2 culture tokens to boost the range"
]
},
{
@ -294,6 +301,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -301,7 +309,7 @@
"resources": {
"culture_tokens": 2
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Influence Culture"
@ -312,7 +320,8 @@
"Structure": {
"structure": "CityCenter",
"balance": "Loss",
"position": "B3"
"position": "B3",
"port_position": null
},
"origin": {
"Ability": "Influence Culture"
@ -323,7 +332,8 @@
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "B3"
"position": "B3",
"port_position": null
},
"origin": {
"Ability": "Influence Culture"
@ -335,7 +345,8 @@
"units": {
"infantry": 1
},
"balance": "Gain"
"balance": "Gain",
"position": "B3"
},
"origin": {
"CivilCard": 15
@ -343,10 +354,9 @@
}
],
"log": [
"Player1: Influence Culture: Pay 2 culture tokens, Cultural influence succeeded (rolled 6), Gain city B3",
"Barbarians: Influence Culture: Lose city B3",
"Player1: Cultural Takeover: Gain 1 infantry at B3"
]
"Player1: Influence Culture: Cultural influence succeeded (rolled 6)"
],
"active_events": 1
}
]
}

View file

@ -358,11 +358,15 @@
"ActionCard": 21
}
},
"player": 1,
"origin": {
"CivilCard": 21
},
"items": [
{
"player": 1,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 21
@ -383,10 +387,6 @@
"Ability": "Action Card"
}
}
],
"log": [
"Player2: Explorer: Pay 1 action, Pay 1 culture token",
"Player2: Action Card: Play Explorer/Encircled"
]
},
{
@ -399,6 +399,7 @@
]
}
},
"player": 1,
"items": [
{
"player": 1,
@ -406,16 +407,14 @@
"resources": {
"culture_tokens": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 21
}
}
],
"log": [
"Player2: Explorer: Pay 1 culture token"
]
"active_events": 1
},
{
"action": {
@ -425,9 +424,11 @@
]
}
},
"player": 1,
"log": [
"Player2: Explorer: Explored B6"
]
],
"active_events": 1
},
{
"action": {
@ -435,9 +436,39 @@
"ExploreResolution": 0
}
},
"player": 1,
"items": [
{
"player": 1,
"Explore": {
"tiles": [
[
"B6",
"Fertile"
],
[
"A7",
"Fertile"
],
[
"C7",
"Fertile"
],
[
"B7",
"Barren"
]
]
},
"origin": {
"Ability": "Explore Resolution"
}
}
],
"log": [
"Player2: Explore Resolution: Chose rotation 0, Explored tiles A7=Fertile, B6=Fertile, B7=Barren, C7=Fertile"
]
"Player2: Explore Resolution: Chose rotation 0"
],
"active_events": 2
},
{
"action": {
@ -447,6 +478,7 @@
]
}
},
"player": 1,
"items": [
{
"player": 1,
@ -454,16 +486,15 @@
"units": {
"settlers": 1
},
"balance": "Gain"
"balance": "Gain",
"position": "D8"
},
"origin": {
"CivilCard": 21
}
}
],
"log": [
"Player2: Explorer: Gain 1 settler at D8"
]
"active_events": 1
}
]
}

View file

@ -209,6 +209,10 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Move"
},
"combat_stats": {
"round": 1,
"battleground": "City",
@ -233,6 +237,22 @@
"city_mood": "Angry"
},
"items": [
{
"player": 0,
"Move": {
"units": {
"settlers": 2,
"infantry": 2,
"cavalry": 1,
"elephants": 1
},
"start": "C2",
"destination": "C1"
},
"origin": {
"Ability": "Move"
}
},
{
"player": 0,
"Resources": {
@ -250,7 +270,8 @@
"Structure": {
"structure": "CityCenter",
"balance": "Loss",
"position": "C1"
"position": "C1",
"port_position": null
},
"origin": {
"Ability": "Combat"
@ -261,18 +282,25 @@
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "C1"
"position": "C1",
"port_position": null
},
"origin": {
"Ability": "Combat"
}
},
{
"player": 0,
"Resources": {
"resources": {
"gold": 1
},
"balance": "Loss"
},
"origin": {
"Ability": "Waste"
}
}
],
"log": [
"Player1: Move: marched 2 settlers, 2 infantry, 1 cavalry and 1 elephant from C2 to C1",
"Player1: Combat: Gain 1 gold, Gain city C1",
"Player2: Combat: Lose city C1",
"Player1: Waste: Could not store 1 gold"
]
},
{
@ -281,6 +309,10 @@
"ActionCard": 11
}
},
"player": 0,
"origin": {
"CivilCard": 11
},
"items": [
{
"player": 0,
@ -309,10 +341,6 @@
"CivilCard": 11
}
}
],
"log": [
"Player1: Action Card: Play Great Ideas/Siege",
"Player1: Great Ideas: Gain 2 ideas"
]
}
]

View file

@ -209,8 +209,29 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Move"
},
"items": [
{
"player": 0,
"Move": {
"units": {
"settlers": 2,
"infantry": 2,
"cavalry": 1,
"elephants": 1
},
"start": "C2",
"destination": "C1"
},
"origin": {
"Ability": "Move"
}
}
],
"log": [
"Player1: Move: marched 2 settlers, 2 infantry, 1 cavalry and 1 elephant from C2 to C1",
"Combat round 1",
"Player1: Combat: Attacking with 2 settlers, 2 infantry, 1 cavalry and 1 elephant",
"Player2: Combat: Defending with 2 infantry"
@ -222,6 +243,7 @@
"SelectHandCards": []
}
},
"player": 0,
"combat_stats": {
"round": 1,
"battleground": "City",
@ -255,7 +277,8 @@
"units": {
"infantry": 2
},
"balance": "Loss"
"balance": "Loss",
"position": "C1"
},
"origin": {
"Ability": "Combat"
@ -278,7 +301,8 @@
"Structure": {
"structure": "CityCenter",
"balance": "Loss",
"position": "C1"
"position": "C1",
"port_position": null
},
"origin": {
"Ability": "Combat"
@ -289,21 +313,34 @@
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "C1"
"position": "C1",
"port_position": null
},
"origin": {
"Ability": "Combat"
}
},
{
"player": 0,
"Resources": {
"resources": {
"gold": 1
},
"balance": "Loss"
},
"origin": {
"Ability": "Waste"
}
}
],
"log": [
"Player1: Tactics: Did not play a Tactics Card",
"Player1: Combat: Roll 6 (infantry, +1 combat value), 6 (infantry, +1 combat value), 6 (infantry, no bonus), 6 (infantry, no bonus) for combined combat value of 26 and gets 2 hits against defending units, Gain 1 gold, Gain city C1",
"Player2: Combat: Roll 1 (leader, no bonus), 1 (leader, no bonus) for combined combat value of 2 and gets 0 hits against attacking units, Lost 2 infantry at C1, Lose city C1",
"Player1: Combat: Roll 6 (infantry, +1 combat value), 6 (infantry, +1 combat value), 6 (infantry, no bonus), 6 (infantry, no bonus) for combined combat value of 26 and gets 2 hits against defending units",
"Player2: Combat: Roll 1 (leader, no bonus), 1 (leader, no bonus) for combined combat value of 2 and gets 0 hits against attacking units",
"Player2: Choose Casualties: Remove all defending units",
"Attacker wins",
"Player1: Waste: Could not store 1 gold"
]
"Attacker wins"
],
"active_events": 1
}
]
}

View file

@ -206,8 +206,29 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Move"
},
"items": [
{
"player": 0,
"Move": {
"units": {
"settlers": 2,
"infantry": 2,
"cavalry": 1,
"elephants": 1
},
"start": "C2",
"destination": "C1"
},
"origin": {
"Ability": "Move"
}
}
],
"log": [
"Player1: Move: marched 2 settlers, 2 infantry, 1 cavalry and 1 elephant from C2 to C1",
"Combat round 1",
"Player1: Combat: Attacking with 2 settlers, 2 infantry, 1 cavalry and 1 elephant",
"Player2: Combat: Defending with 2 infantry"
@ -219,6 +240,7 @@
"SelectHandCards": []
}
},
"player": 0,
"combat_stats": {
"round": 1,
"battleground": "City",
@ -255,7 +277,8 @@
"units": {
"infantry": 2
},
"balance": "Loss"
"balance": "Loss",
"position": "C1"
},
"origin": {
"Ability": "Combat"
@ -278,7 +301,8 @@
"Structure": {
"structure": "CityCenter",
"balance": "Loss",
"position": "C1"
"position": "C1",
"port_position": null
},
"origin": {
"Ability": "Combat"
@ -289,21 +313,34 @@
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "C1"
"position": "C1",
"port_position": null
},
"origin": {
"Ability": "Combat"
}
},
{
"player": 0,
"Resources": {
"resources": {
"gold": 1
},
"balance": "Loss"
},
"origin": {
"Ability": "Waste"
}
}
],
"log": [
"Player1: Tactics: Did not play a Tactics Card",
"Player1: Combat: Roll 6 (infantry, +1 combat value), 6 (infantry, +1 combat value), 6 (infantry, no bonus), 6 (infantry, no bonus) for combined combat value of 26 and gets 2 hits against defending units, Gain 1 gold, Gain city C1",
"Player2: Combat: Roll 1 (leader, no bonus), 1 (leader, no bonus) for combined combat value of 2 and gets 0 hits against attacking units, Lost 2 infantry at C1, Lose city C1",
"Player1: Combat: Roll 6 (infantry, +1 combat value), 6 (infantry, +1 combat value), 6 (infantry, no bonus), 6 (infantry, no bonus) for combined combat value of 26 and gets 2 hits against defending units",
"Player2: Combat: Roll 1 (leader, no bonus), 1 (leader, no bonus) for combined combat value of 2 and gets 0 hits against attacking units",
"Player2: Choose Casualties: Remove all defending units",
"Attacker wins",
"Player1: Waste: Could not store 1 gold"
]
"Attacker wins"
],
"active_events": 1
},
{
"action": {
@ -311,6 +348,10 @@
"ActionCard": 5
}
},
"player": 0,
"origin": {
"CivilCard": 5
},
"items": [
{
"player": 0,
@ -327,9 +368,6 @@
"Ability": "Action Card"
}
}
],
"log": [
"Player1: Action Card: Play Hero General/Wedge Formation"
]
},
{
@ -340,6 +378,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -352,9 +391,7 @@
}
}
],
"log": [
"Player1: Hero General: City C1 became Neutral"
]
"active_events": 1
},
{
"action": {
@ -366,6 +403,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -373,16 +411,14 @@
"resources": {
"mood_tokens": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 5
}
}
],
"log": [
"Player1: Hero General: Pay 1 mood token"
]
"active_events": 1
},
{
"action": {
@ -392,6 +428,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -404,9 +441,7 @@
}
}
],
"log": [
"Player1: Hero General: City C2 became Happy"
]
"active_events": 1
}
]
}

View file

@ -201,6 +201,10 @@
"ActionCard": 9
}
},
"player": 0,
"origin": {
"CivilCard": 9
},
"items": [
{
"player": 0,
@ -229,10 +233,6 @@
"CivilCard": 9
}
}
],
"log": [
"Player1: Action Card: Play Ideas/High Ground",
"Player1: Ideas: Gain 1 idea"
]
}
]

View file

@ -199,6 +199,10 @@
"ActionCard": 3
}
},
"player": 0,
"origin": {
"CivilCard": 3
},
"items": [
{
"player": 0,
@ -231,18 +235,13 @@
"player": 0,
"Advance": {
"advance": "Storage",
"take_incident_token": false,
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"CivilCard": 3
}
}
],
"log": [
"Player1: Action Card: Play Inspiration/Encircled",
"Player1: Storage: Gain 1 mood token",
"Player1: Inspiration: Gain Storage without taking an event token"
]
}
]

View file

@ -220,6 +220,10 @@
"ActionCard": 29
}
},
"player": 0,
"origin": {
"CivilCard": 29
},
"items": [
{
"player": 0,
@ -238,7 +242,6 @@
}
],
"log": [
"Player1: Action Card: Play Mass Production/Defensive Formation",
"Player1: Mass Production: Can use Mass Production to collect from 2 additional tiles."
]
},
@ -274,11 +277,15 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Collect"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Collect"
@ -298,9 +305,6 @@
"Ability": "Collect"
}
}
],
"log": [
"Player1: Collect: Pay 1 action, Use city C2, Gain 1 wood, 1 ore and 1 mood token"
]
}
]

View file

@ -242,11 +242,15 @@
"ActionCard": 13
}
},
"player": 0,
"origin": {
"CivilCard": 13
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 13
@ -269,8 +273,7 @@
}
],
"log": [
"Player1: Mercenaries: Pay 1 action, Player1 cannot move Barbarian army at A3 because Sulla is in range",
"Player1: Action Card: Play Mercenaries/For the People"
"Player1: Mercenaries: Player1 cannot move Barbarian army at A3 because Sulla is in range"
]
},
{
@ -281,9 +284,11 @@
]
}
},
"player": 0,
"log": [
"Player1: Mercenaries: Selected Barbarian armies to move: B3"
]
],
"active_events": 1
},
{
"action": {
@ -295,6 +300,7 @@
]
}
},
"player": 0,
"combat_stats": {
"round": 1,
"battleground": "Land",
@ -327,7 +333,20 @@
"resources": {
"ore": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 13
}
},
{
"player": 0,
"Move": {
"units": {
"infantry": 2
},
"start": "B3",
"destination": "B2"
},
"origin": {
"CivilCard": 13
@ -339,7 +358,8 @@
"units": {
"infantry": 1
},
"balance": "Loss"
"balance": "Loss",
"position": "B3"
},
"origin": {
"Ability": "Combat"
@ -351,7 +371,8 @@
"units": {
"infantry": 1
},
"balance": "Loss"
"balance": "Loss",
"position": "B2"
},
"origin": {
"Ability": "Combat"
@ -363,7 +384,8 @@
"units": {
"infantry": 1
},
"balance": "Gain"
"balance": "Gain",
"position": "B3"
},
"origin": {
"CivilCard": 13
@ -371,15 +393,15 @@
}
],
"log": [
"Player1: Mercenaries: Pay 1 ore, Selected Barbarian army to move: B3, Selected destination for Barbarian army: B2, marched 2 infantry from B3 to B2",
"Player1: Mercenaries: Selected Barbarian army to move: B3, Selected destination for Barbarian army: B2",
"Combat round 1",
"Barbarians: Combat: Attacking with 2 infantry, Roll 6 (infantry, +1 combat value), 6 (infantry, +1 combat value) for combined combat value of 14 and gets 1 hits against defending units, Lost 1 infantry at B3",
"Player1: Combat: Defending with 1 infantry, Roll 6 (infantry, +1 combat value) for combined combat value of 7 and gets 1 hits against attacking units, Lost 1 infantry at B2",
"Barbarians: Combat: Attacking with 2 infantry, Roll 6 (infantry, +1 combat value), 6 (infantry, +1 combat value) for combined combat value of 14 and gets 1 hits against defending units",
"Player1: Combat: Defending with 1 infantry, Roll 6 (infantry, +1 combat value) for combined combat value of 7 and gets 1 hits against attacking units",
"Barbarians: Choose Casualties: Remove 1 of their attacking units",
"Player1: Choose Casualties: Remove all defending units",
"Attacker wins",
"Barbarians: Mercenaries: Gain 1 infantry at B3"
]
"Attacker wins"
],
"active_events": 1
}
]
}

View file

@ -199,6 +199,10 @@
"ActionCard": 37
}
},
"player": 0,
"origin": {
"CivilCard": 37
},
"items": [
{
"player": 0,
@ -215,10 +219,6 @@
"Ability": "Action Card"
}
}
],
"log": [
"Player1: Action Card: Play Militia/Wedge Formation",
"Player1: Militia: Pay 1 culture token"
]
},
{
@ -231,6 +231,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -238,7 +239,7 @@
"resources": {
"culture_tokens": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 37
@ -250,16 +251,15 @@
"units": {
"infantry": 1
},
"balance": "Gain"
"balance": "Gain",
"position": "A1"
},
"origin": {
"CivilCard": 37
}
}
],
"log": [
"Player1: Militia: Pay 1 culture token, Gain 1 infantry at A1"
]
"active_events": 1
}
]
}

View file

@ -221,6 +221,10 @@
"ActionCard": 23
}
},
"player": 0,
"origin": {
"CivilCard": 23
},
"items": [
{
"player": 0,
@ -237,10 +241,6 @@
"Ability": "Action Card"
}
}
],
"log": [
"Player1: Action Card: Play Negotiations/Scout",
"Player1: Negotiations: Pay 1 culture token"
]
},
{
@ -253,6 +253,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -260,7 +261,7 @@
"resources": {
"culture_tokens": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 23
@ -268,15 +269,29 @@
}
],
"log": [
"Player1: Negotiations: Pay 1 culture token, Started negotiations with Player2"
]
"Player1: Negotiations: Started negotiations with Player2"
],
"active_events": 1
},
{
"action": {
"Playing": "EndTurn"
},
"log": [
"Player1: End Turn: 3 actions left"
"player": 0,
"origin": {
"Ability": "End Turn"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss",
"amount": 3
},
"origin": {
"Ability": "End Turn"
}
}
]
}
]
@ -288,6 +303,7 @@
"actions": [
{
"action": "StartTurn",
"player": 1,
"log": [
"Player2: Negotiations: May not attack Player1 this turn."
]
@ -296,8 +312,21 @@
"action": {
"Playing": "EndTurn"
},
"log": [
"Player2: End Turn: 3 actions left"
"player": 1,
"origin": {
"Ability": "End Turn"
},
"items": [
{
"player": 1,
"Action": {
"balance": "Loss",
"amount": 3
},
"origin": {
"Ability": "End Turn"
}
}
]
}
]
@ -314,6 +343,7 @@
"actions": [
{
"action": "StartTurn",
"player": 0,
"log": [
"Player1: Negotiations: May attack Player2 again."
]
@ -329,6 +359,10 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Move"
},
"combat_stats": {
"round": 1,
"battleground": "Land",
@ -355,10 +389,23 @@
"result": "Draw"
},
"items": [
{
"player": 0,
"Move": {
"units": {
"infantry": 1
},
"start": "C2",
"destination": "B1"
},
"origin": {
"Ability": "Move"
}
},
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Move"
@ -370,7 +417,8 @@
"units": {
"infantry": 1
},
"balance": "Loss"
"balance": "Loss",
"position": "C2"
},
"origin": {
"Ability": "Combat"
@ -382,7 +430,8 @@
"units": {
"infantry": 1
},
"balance": "Loss"
"balance": "Loss",
"position": "B1"
},
"origin": {
"Ability": "Combat"
@ -390,10 +439,9 @@
}
],
"log": [
"Player1: Move: marched 1 infantry from C2 to B1, Pay 1 action",
"Combat round 1",
"Player1: Combat: Attacking with 1 infantry, Roll 6 (infantry, +1 combat value) for combined combat value of 7 and gets 1 hits against defending units, Lost 1 infantry at C2",
"Player2: Combat: Defending with 1 infantry, Roll 6 (infantry, +1 combat value) for combined combat value of 7 and gets 1 hits against attacking units, Lost 1 infantry at B1",
"Player1: Combat: Attacking with 1 infantry, Roll 6 (infantry, +1 combat value) for combined combat value of 7 and gets 1 hits against defending units",
"Player2: Combat: Defending with 1 infantry, Roll 6 (infantry, +1 combat value) for combined combat value of 7 and gets 1 hits against attacking units",
"Player1: Choose Casualties: Remove all attacking units",
"Player2: Choose Casualties: Remove all defending units",
"Battle ends in a draw"

View file

@ -200,11 +200,15 @@
"ActionCard": 41
}
},
"player": 0,
"origin": {
"CivilCard": 41
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 41
@ -225,10 +229,6 @@
"Ability": "Action Card"
}
}
],
"log": [
"Player1: New Ideas: Pay 1 action",
"Player1: Action Card: Play New Ideas/High Morale"
]
},
{
@ -237,9 +237,11 @@
"SelectAdvance": "Storage"
}
},
"player": 0,
"log": [
"Player1: New Ideas: Selected Storage as advance for New Ideas."
]
],
"active_events": 1
},
{
"action": {
@ -251,6 +253,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -258,7 +261,7 @@
"resources": {
"food": 2
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Advance"
@ -280,7 +283,7 @@
"player": 0,
"Advance": {
"advance": "Storage",
"take_incident_token": false,
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
@ -300,11 +303,7 @@
}
}
],
"log": [
"Player1: Advance: Pay 2 food",
"Player1: Storage: Gain 1 mood token",
"Player1: New Ideas: Gain Storage without taking an event token, Gain 2 ideas"
]
"active_events": 1
}
]
}

View file

@ -210,11 +210,15 @@
"ActionCard": 31
}
},
"player": 0,
"origin": {
"CivilCard": 31
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 31
@ -235,10 +239,6 @@
"Ability": "Action Card"
}
}
],
"log": [
"Player1: New Plans: Pay 1 action, Pay 1 culture token",
"Player1: Action Card: Play New Plans/Flanking"
]
},
{
@ -251,6 +251,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -258,7 +259,7 @@
"resources": {
"culture_tokens": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 31
@ -295,9 +296,7 @@
}
}
],
"log": [
"Player1: New Plans: Pay 1 culture token, Draw an objective card, Draw an objective card"
]
"active_events": 1
},
{
"action": {
@ -312,6 +311,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -344,9 +344,7 @@
}
}
],
"log": [
"Player1: New Plans: Shuffle an objective card back into the draw pile, Reshuffled a card from the draw pile back into the draw pile"
]
"active_events": 1
}
]
}

View file

@ -221,6 +221,10 @@
"ActionCard": 19
}
},
"player": 0,
"origin": {
"CivilCard": 19
},
"items": [
{
"player": 0,
@ -239,7 +243,6 @@
}
],
"log": [
"Player1: Action Card: Play Production Focus/Tactical Retreat",
"Player1: Production Focus: Production Focus: You may collect multiple times from the same tile."
]
},
@ -275,11 +278,15 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Collect"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Collect"
@ -298,11 +305,19 @@
"origin": {
"Ability": "Collect"
}
},
{
"player": 0,
"Resources": {
"resources": {
"gold": 1
},
"balance": "Loss"
},
"origin": {
"Ability": "Waste"
}
}
],
"log": [
"Player1: Collect: Pay 1 action, Use city C2, Gain 2 ore, 1 gold and 2 mood tokens",
"Player1: Waste: Could not store 1 gold"
]
}
]

View file

@ -214,11 +214,15 @@
"ActionCard": 7
}
},
"player": 0,
"origin": {
"CivilCard": 7
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 7
@ -239,10 +243,6 @@
"Ability": "Action Card"
}
}
],
"log": [
"Player1: Spy: Pay 1 action, Pay 1 culture token",
"Player1: Action Card: Play Spy/Heavy Resistance"
]
},
{
@ -255,6 +255,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -262,7 +263,7 @@
"resources": {
"culture_tokens": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 7
@ -270,8 +271,9 @@
}
],
"log": [
"Player1: Spy: Pay 1 culture token, Decided to looked at all Wonder, Action, and Objective cards of Player2"
]
"Player1: Spy: Decided to looked at all Wonder, Action, and Objective cards of Player2"
],
"active_events": 1
},
{
"action": {
@ -286,6 +288,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 1,
@ -323,9 +326,9 @@
}
],
"log": [
"Player2: Spy: Gain an action card from Player1",
"Player1: Spy: Gain an action card from Player2, Decided to swap an action card with Player2"
]
"Player1: Spy: Decided to swap an action card with Player2"
],
"active_events": 1
}
]
}

View file

@ -219,11 +219,15 @@
"ActionCard": 34
}
},
"player": 0,
"origin": {
"CivilCard": 34
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"CivilCard": 34
@ -244,10 +248,6 @@
"Ability": "Action Card"
}
}
],
"log": [
"Player1: Synergies: Pay 1 action",
"Player1: Action Card: Play Synergies/Archers"
]
},
{
@ -256,9 +256,11 @@
"SelectAdvance": "Fishing"
}
},
"player": 0,
"log": [
"Player1: Synergies: Selected Fishing as first advance"
]
],
"active_events": 1
},
{
"action": {
@ -270,6 +272,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -277,7 +280,7 @@
"resources": {
"ideas": 2
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Advance"
@ -299,7 +302,7 @@
"player": 0,
"Advance": {
"advance": "Fishing",
"take_incident_token": false,
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
@ -307,11 +310,7 @@
}
}
],
"log": [
"Player1: Advance: Pay 2 ideas",
"Player1: Fishing: Gain 1 mood token",
"Player1: Synergies: Gain Fishing without taking an event token"
]
"active_events": 1
},
{
"action": {
@ -319,9 +318,11 @@
"SelectAdvance": "WarShips"
}
},
"player": 0,
"log": [
"Player1: Synergies: Selected WarShips as second advance"
]
],
"active_events": 1
},
{
"action": {
@ -333,6 +334,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -340,7 +342,7 @@
"resources": {
"ideas": 2
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Advance"
@ -350,7 +352,7 @@
"player": 0,
"Advance": {
"advance": "WarShips",
"take_incident_token": false,
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
@ -358,10 +360,7 @@
}
}
],
"log": [
"Player1: Advance: Pay 2 ideas",
"Player1: Synergies: Gain WarShips without taking an event token"
]
"active_events": 1
}
]
}

View file

@ -213,6 +213,10 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Move"
},
"combat_stats": {
"round": 1,
"battleground": "City",
@ -240,13 +244,30 @@
"city_mood": "Angry"
},
"items": [
{
"player": 0,
"Move": {
"units": {
"settlers": 2,
"infantry": 2,
"cavalry": 1,
"elephants": 1
},
"start": "C2",
"destination": "C1"
},
"origin": {
"Ability": "Move"
}
},
{
"player": 1,
"Units": {
"units": {
"infantry": 2
},
"balance": "Loss"
"balance": "Loss",
"position": "C1"
},
"origin": {
"Ability": "Combat"
@ -269,7 +290,8 @@
"Structure": {
"structure": "CityCenter",
"balance": "Loss",
"position": "C1"
"position": "C1",
"port_position": null
},
"origin": {
"Ability": "Combat"
@ -280,21 +302,32 @@
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "C1"
"position": "C1",
"port_position": null
},
"origin": {
"Ability": "Combat"
}
},
{
"player": 0,
"Resources": {
"resources": {
"gold": 1
},
"balance": "Loss"
},
"origin": {
"Ability": "Waste"
}
}
],
"log": [
"Player1: Move: marched 2 settlers, 2 infantry, 1 cavalry and 1 elephant from C2 to C1",
"Combat round 1",
"Player1: Combat: Attacking with 2 settlers, 2 infantry, 1 cavalry and 1 elephant, Roll 6 (infantry, +1 combat value), 6 (infantry, +1 combat value), 6 (infantry, no bonus), 6 (infantry, no bonus) for combined combat value of 26 and gets 2 hits against defending units, Gain 1 gold, Gain city C1",
"Player2: Combat: Defending with 2 infantry, Roll 1 (leader, no bonus), 1 (leader, no bonus) for combined combat value of 2 and gets 0 hits against attacking units, Lost 2 infantry at C1, Lose city C1",
"Player1: Combat: Attacking with 2 settlers, 2 infantry, 1 cavalry and 1 elephant, Roll 6 (infantry, +1 combat value), 6 (infantry, +1 combat value), 6 (infantry, no bonus), 6 (infantry, no bonus) for combined combat value of 26 and gets 2 hits against defending units",
"Player2: Combat: Defending with 2 infantry, Roll 1 (leader, no bonus), 1 (leader, no bonus) for combined combat value of 2 and gets 0 hits against attacking units",
"Player2: Choose Casualties: Remove all defending units",
"Attacker wins",
"Player1: Waste: Could not store 1 gold"
"Attacker wins"
]
},
{
@ -307,6 +340,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -369,7 +403,7 @@
"player": 0,
"Advance": {
"advance": "Writing",
"take_incident_token": false,
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
@ -377,10 +411,7 @@
}
}
],
"log": [
"Player1: Teach us: Play Teach Us/Defensive Formation, Gain Writing without taking an event token",
"Player1: Writing: Draw an action card, Draw an objective card, Gain 1 culture token"
]
"active_events": 1
}
]
}

View file

@ -211,6 +211,10 @@
"ActionCard": 39
}
},
"player": 0,
"origin": {
"CivilCard": 39
},
"items": [
{
"player": 0,
@ -243,7 +247,7 @@
"player": 0,
"Advance": {
"advance": "Storage",
"take_incident_token": false,
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
@ -266,7 +270,7 @@
"player": 1,
"Advance": {
"advance": "Fishing",
"take_incident_token": false,
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
@ -275,11 +279,7 @@
}
],
"log": [
"Player1: Action Card: Play Technology Trade/Surprise",
"Player1: Technology Trade: Selected Player2 as trade partner, Gain Storage without taking an event token",
"Player1: Storage: Gain 1 mood token",
"Player2: Fishing: Gain 1 mood token",
"Player2: Technology Trade: Gain Fishing without taking an event token"
"Player1: Technology Trade: Selected Player2 as trade partner"
]
}
]

View file

@ -102,7 +102,9 @@
],
"next_unit_id": 7,
"played_once_per_turn_actions": [
"AbsolutePower"
{
"Custom": "AbsolutePower"
}
]
},
{
@ -240,9 +242,10 @@
}
}
},
"log": [
"Player1: Absolute Power: Start action, Pay 2 mood tokens"
]
"player": 0,
"origin": {
"Advance": "AbsolutePower"
}
},
{
"action": {
@ -254,6 +257,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -261,7 +265,7 @@
"resources": {
"mood_tokens": 2
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Advance": "AbsolutePower"
@ -277,9 +281,7 @@
}
}
],
"log": [
"Player1: Absolute Power: Pay 2 mood tokens, Gain 1 action"
]
"active_events": 1
}
]
}

View file

@ -88,7 +88,9 @@
"incident_tokens": 2,
"next_unit_id": 8,
"played_once_per_turn_actions": [
"Bartering"
{
"Custom": "Bartering"
}
]
},
{
@ -206,6 +208,10 @@
}
}
},
"player": 0,
"origin": {
"Advance": "Bartering"
},
"items": [
{
"player": 0,
@ -222,9 +228,6 @@
"Ability": "Bartering"
}
}
],
"log": [
"Player1: Bartering: Start action, Discard Quick Advance/Peltasts"
]
},
{
@ -235,6 +238,7 @@
}
}
},
"player": 0,
"items": [
{
"player": 0,
@ -247,12 +251,21 @@
"origin": {
"Ability": "Bartering"
}
},
{
"player": 0,
"Resources": {
"resources": {
"gold": 1
},
"balance": "Loss"
},
"origin": {
"Ability": "Waste"
}
}
],
"log": [
"Player1: Bartering: Gain 1 gold",
"Player1: Waste: Could not store 1 gold"
]
"active_events": 1
}
]
}

View file

@ -203,11 +203,15 @@
}
}
},
"player": 0,
"origin": {
"Advance": "CivilLiberties"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Advance": "CivilLiberties"
@ -225,9 +229,6 @@
"Ability": "Civil Liberties"
}
}
],
"log": [
"Player1: Civil Liberties: Pay 1 action, Start action, Gain 3 mood tokens"
]
}
]

View file

@ -209,11 +209,15 @@
}
}
},
"player": 0,
"origin": {
"Advance": "CivilLiberties"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Advance": "CivilLiberties"
@ -231,9 +235,6 @@
"Ability": "Civil Liberties"
}
}
],
"log": [
"Player1: Civil Liberties: Pay 1 action, Start action, Gain 3 mood tokens"
]
},
{
@ -250,11 +251,15 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Recruit"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Recruit"
@ -266,7 +271,7 @@
"resources": {
"mood_tokens": 2
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Recruit"
@ -283,7 +288,8 @@
"units": {
"infantry": 1
},
"balance": "Gain"
"balance": "Gain",
"position": "A1"
},
"origin": {
"Ability": "Recruit"
@ -291,7 +297,6 @@
}
],
"log": [
"Player1: Recruit: Pay 1 action, Pay 2 mood tokens with Draft, Gain 1 infantry at A1",
"Player1: Draft: Reduce the cost of 1 Infantry to 1 mood token"
]
}

View file

@ -296,11 +296,15 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Collect"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Collect"
@ -317,11 +321,19 @@
"origin": {
"Ability": "Collect"
}
},
{
"player": 0,
"Resources": {
"resources": {
"food": 1
},
"balance": "Loss"
},
"origin": {
"Ability": "Waste"
}
}
],
"log": [
"Player1: Collect: Pay 1 action, Use city C2, Gain 1 food",
"Player1: Waste: Could not store 1 food"
]
}
]

View file

@ -91,7 +91,9 @@
],
"next_unit_id": 8,
"played_once_per_turn_actions": [
"FreeEconomyCollect"
{
"Modifier": "FreeEconomyCollect"
}
]
},
{
@ -223,14 +225,17 @@
}
],
"action_type": {
"Custom": "FreeEconomyCollect"
"Special": {
"Modifier": "FreeEconomyCollect"
}
}
}
}
},
"log": [
"Player1: Free Economy: Pay 1 mood token"
]
"player": 0,
"origin": {
"Advance": "FreeEconomy"
}
},
{
"action": {
@ -242,6 +247,7 @@
]
}
},
"player": 0,
"items": [
{
"player": 0,
@ -249,7 +255,7 @@
"resources": {
"mood_tokens": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Advance": "FreeEconomy"
@ -268,9 +274,7 @@
}
}
],
"log": [
"Player1: Free Economy: Pay 1 mood token, Use city C2, Gain 2 ore"
]
"active_events": 1
},
{
"action": {
@ -278,6 +282,7 @@
"Bool": true
}
},
"player": 0,
"items": [
{
"player": 0,
@ -285,7 +290,7 @@
"resources": {
"ore": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Advance": "Metallurgy"
@ -304,9 +309,7 @@
}
}
],
"log": [
"Player1: Metallurgy: Gain 1 gold"
]
"active_events": 1
}
]
}
@ -338,4 +341,4 @@
"wonders_left": [
"Pyramids"
]
}
}

View file

@ -291,11 +291,15 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Collect"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Collect"
@ -322,12 +326,22 @@
"origin": {
"Ability": "Collect"
}
},
{
"player": 0,
"Resources": {
"resources": {
"food": 1
},
"balance": "Loss"
},
"origin": {
"Ability": "Waste"
}
}
],
"log": [
"Player1: Collect: Pay 1 action, Use city B3, City B3 became Neutral, Gain 1 food",
"Player1: Husbandry: Can collect 1 resources from 2 land spaces away",
"Player1: Waste: Could not store 1 food"
"Player1: Husbandry: Can collect 1 resources from 2 land spaces away"
]
}
]

View file

@ -295,11 +295,15 @@
}
}
},
"player": 0,
"origin": {
"Ability": "Collect"
},
"items": [
{
"player": 0,
"Action": {
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Ability": "Collect"
@ -317,9 +321,6 @@
"Ability": "Collect"
}
}
],
"log": [
"Player1: Collect: Pay 1 action, Use city C2, Gain 1 mood token"
]
}
]

View file

@ -133,7 +133,9 @@
"incident_tokens": 3,
"next_unit_id": 2,
"played_once_per_turn_actions": [
"ArtsInfluenceCultureAttempt"
{
"Modifier": "ArtsInfluenceCultureAttempt"
}
]
}
],
@ -206,14 +208,17 @@
}
},
"action_type": {
"Custom": "ArtsInfluenceCultureAttempt"
"Special": {
"Modifier": "ArtsInfluenceCultureAttempt"
}
}
}
}
},
"log": [
"Player2: Arts: Pay 1 culture token"
]
"player": 1,
"origin": {
"Advance": "Arts"
}
},
{
"action": {
@ -225,6 +230,7 @@
]
}
},
"player": 1,
"items": [
{
"player": 1,
@ -232,7 +238,7 @@
"resources": {
"culture_tokens": 1
},
"balance": "Loss"
"balance": "Pay"
},
"origin": {
"Advance": "Arts"
@ -245,7 +251,8 @@
"Building": "Fortress"
},
"balance": "Loss",
"position": "C2"
"position": "C2",
"port_position": null
},
"origin": {
"Advance": "Arts"
@ -258,7 +265,8 @@
"Building": "Fortress"
},
"balance": "Gain",
"position": "C2"
"position": "C2",
"port_position": null
},
"origin": {
"Advance": "Arts"
@ -266,9 +274,9 @@
}
],
"log": [
"Player2: Arts: Pay 1 culture token, Tried to influence the Fortress in the city at C2 by Player1 with the city C1, Cultural influence succeeded (rolled 6), Gain Fortress at C2",
"Player1: Arts: Lose Fortress at C2"
]
"Player2: Arts: Tried to influence the Fortress in the city at C2 by Player1 with the city C1, Cultural influence succeeded (rolled 6)"
],
"active_events": 1
}
]
}

Some files were not shown because too many files have changed in this diff Show more