action cards (#183)
This commit is contained in:
parent
1012669316
commit
1be6ff0802
167 changed files with 4633 additions and 952 deletions
|
|
@ -108,7 +108,7 @@ pub fn show_advance_menu(
|
|||
// tooltip should be shown on top of everything
|
||||
show_tooltip_for_rect(rc, &description(p, a), rect);
|
||||
|
||||
if rc.can_control()
|
||||
if rc.can_control_shown_player()
|
||||
&& matches!(
|
||||
advance_state,
|
||||
AdvanceState::Available | AdvanceState::Removable
|
||||
|
|
|
|||
|
|
@ -1,19 +1,200 @@
|
|||
// pub fn show_wonders(game: &Game, player: &ShownPlayer, ui: &mut Ui) {
|
||||
//todo move to cards ui
|
||||
// let player = game.get_player(player.index);
|
||||
// let y = 5.;
|
||||
//
|
||||
// for (i, card) in player.wonder_cards.iter().enumerate() {
|
||||
// let req = match card.required_advances[..] {
|
||||
// [] => String::from("no advances"),
|
||||
// _ => card.required_advances.join(", "),
|
||||
// };
|
||||
// ui.label(
|
||||
// vec2(900. + i as f32 * 30.0, y),
|
||||
// &format!(
|
||||
// "Wonder Card {} cost {} requires {}",
|
||||
// &card.name, card.cost, req
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
use crate::client_state::{ActiveDialog, StateUpdate};
|
||||
use crate::custom_phase_ui::MultiSelection;
|
||||
use crate::dialog_ui::ok_button;
|
||||
use crate::layout_ui::{bottom_centered_text, left_mouse_button_pressed_in_rect};
|
||||
use crate::render_context::RenderContext;
|
||||
use crate::select_ui::HighlightType;
|
||||
use crate::tooltip::show_tooltip_for_rect;
|
||||
use macroquad::color::BLACK;
|
||||
use macroquad::math::{vec2, Rect};
|
||||
use macroquad::prelude::{draw_rectangle, draw_rectangle_lines, Color, GREEN, RED, YELLOW};
|
||||
use server::action::Action;
|
||||
use server::card::{hand_cards, HandCard, HandCardType};
|
||||
use server::content::action_cards::get_action_card;
|
||||
use server::content::custom_phase_actions::CurrentEventResponse;
|
||||
use server::content::wonders::get_wonder;
|
||||
use server::player::Player;
|
||||
use server::playing_actions::PlayingAction;
|
||||
use server::tactics_card::CombatRole;
|
||||
use server::wonder::Wonder;
|
||||
|
||||
pub struct HandCardObject {
|
||||
id: HandCard,
|
||||
name: String,
|
||||
description: Vec<String>,
|
||||
color: Color,
|
||||
}
|
||||
|
||||
impl HandCardObject {
|
||||
pub fn new(id: HandCard, color: Color, name: String, description: Vec<String>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
color,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn wonder_cards(player: &Player) -> Vec<Wonder> {
|
||||
player.wonder_cards.iter().map(|n| get_wonder(n)).collect()
|
||||
}
|
||||
|
||||
const ACTION_CARD_COLOR: Color = RED;
|
||||
const WONDER_CARD_COLOR: Color = YELLOW;
|
||||
|
||||
pub(crate) fn show_cards(rc: &RenderContext) -> StateUpdate {
|
||||
let p = rc.shown_player;
|
||||
let cards = hand_cards(p, &HandCardType::get_all());
|
||||
let size = vec2(180., 30.);
|
||||
|
||||
let selection = if let ActiveDialog::HandCardsRequest(r) = &rc.state.active_dialog {
|
||||
Some(r)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
for pass in 0..2 {
|
||||
let mut y = (cards.len() as f32 * -size.y) / 2.;
|
||||
for card in &cards {
|
||||
let screen = rc.state.screen_size;
|
||||
let pos = vec2(screen.x, screen.y / 2.0) + vec2(-size.x, y);
|
||||
|
||||
let c = get_card_object(card);
|
||||
|
||||
if pass == 0 {
|
||||
draw_rectangle(pos.x, pos.y, size.x, size.y, c.color);
|
||||
let (thickness, border) = highlight(&c, selection);
|
||||
draw_rectangle_lines(pos.x, pos.y, size.x, size.y, thickness, border);
|
||||
|
||||
rc.state.draw_text(&c.name, pos.x + 10., pos.y + 22.);
|
||||
} else {
|
||||
let rect = Rect::new(pos.x, pos.y, size.x, size.y);
|
||||
|
||||
// tooltip should be shown on top of everything
|
||||
show_tooltip_for_rect(rc, &c.description, rect);
|
||||
|
||||
if left_mouse_button_pressed_in_rect(rect, rc) {
|
||||
if let Some(s) = selection {
|
||||
return StateUpdate::OpenDialog(ActiveDialog::HandCardsRequest(
|
||||
s.clone().toggle(c.id),
|
||||
));
|
||||
}
|
||||
if can_play_card(rc, card) {
|
||||
return play_card(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
y += size.y;
|
||||
}
|
||||
}
|
||||
StateUpdate::None
|
||||
}
|
||||
|
||||
fn can_play_card(rc: &RenderContext, card: &HandCard) -> bool {
|
||||
if rc.can_control_shown_player() && rc.is_playing() {
|
||||
if let HandCard::ActionCard(id) = card {
|
||||
return (get_action_card(*id).civil_card.can_play)(rc.game, rc.shown_player);
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn play_card(card: &HandCard) -> StateUpdate {
|
||||
match card {
|
||||
HandCard::ActionCard(a) => StateUpdate::execute_with_warning(
|
||||
Action::Playing(PlayingAction::ActionCard(*a)),
|
||||
vec![],
|
||||
),
|
||||
HandCard::Wonder(_) => panic!("wonders are played in the construct menu"),
|
||||
}
|
||||
}
|
||||
|
||||
fn highlight(c: &HandCardObject, selection: Option<&MultiSelection<HandCard>>) -> (f32, Color) {
|
||||
if let Some(s) = selection {
|
||||
if s.selected.contains(&c.id) {
|
||||
return (8.0, GREEN);
|
||||
}
|
||||
if s.request.choices.contains(&c.id) {
|
||||
return (8.0, HighlightType::Choices.color());
|
||||
}
|
||||
}
|
||||
(2.0, BLACK)
|
||||
}
|
||||
|
||||
fn get_card_object(card: &HandCard) -> HandCardObject {
|
||||
match card {
|
||||
HandCard::ActionCard(a) if *a == 0 => HandCardObject::new(
|
||||
card.clone(),
|
||||
ACTION_CARD_COLOR,
|
||||
"Action Card".to_string(),
|
||||
vec!["Hidden Action Card".to_string()],
|
||||
),
|
||||
HandCard::ActionCard(id) => {
|
||||
let a = get_action_card(*id);
|
||||
HandCardObject::new(
|
||||
card.clone(),
|
||||
ACTION_CARD_COLOR,
|
||||
a.civil_card.name.clone(),
|
||||
vec![
|
||||
a.civil_card.description.clone(),
|
||||
format!("Tactics: {}", a.tactics_card.name),
|
||||
format!("Unit Type: {:?}", a.tactics_card.fighter_requirement),
|
||||
format!(
|
||||
"Role: {:?}",
|
||||
match a.tactics_card.role_requirement {
|
||||
None => "None".to_string(),
|
||||
Some(r) => match r {
|
||||
CombatRole::Attacker => "Attacker".to_string(),
|
||||
CombatRole::Defender => "Defender".to_string(),
|
||||
},
|
||||
}
|
||||
),
|
||||
a.tactics_card.description.clone(),
|
||||
],
|
||||
)
|
||||
}
|
||||
HandCard::Wonder(n) if n.is_empty() => HandCardObject::new(
|
||||
card.clone(),
|
||||
WONDER_CARD_COLOR,
|
||||
"Wonder Card".to_string(),
|
||||
vec!["Hidden Wonder Card".to_string()],
|
||||
),
|
||||
HandCard::Wonder(name) => {
|
||||
let w = get_wonder(name);
|
||||
HandCardObject::new(
|
||||
card.clone(),
|
||||
WONDER_CARD_COLOR,
|
||||
w.name.clone(),
|
||||
vec![
|
||||
w.description.clone(),
|
||||
format!("Cost: {}", w.cost.to_string()),
|
||||
format!("Required advances: {}", w.required_advances.join(", ")),
|
||||
],
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn select_cards_dialog(rc: &RenderContext, s: &MultiSelection<HandCard>) -> StateUpdate {
|
||||
bottom_centered_text(
|
||||
rc,
|
||||
format!(
|
||||
"{}: {} cards selected",
|
||||
s.request.description,
|
||||
s.selected.len()
|
||||
)
|
||||
.as_str(),
|
||||
);
|
||||
|
||||
if ok_button(
|
||||
rc,
|
||||
crate::custom_phase_ui::multi_select_tooltip(s, s.request.is_valid(&s.selected), "cards"),
|
||||
) {
|
||||
StateUpdate::response(CurrentEventResponse::SelectHandCards(s.selected.clone()))
|
||||
} else {
|
||||
StateUpdate::None
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::action_buttons::{
|
||||
base_or_custom_action, base_or_custom_available, custom_action_buttons,
|
||||
};
|
||||
use crate::cards_ui::wonder_cards;
|
||||
use crate::client_state::{ActiveDialog, StateUpdate};
|
||||
use crate::collect_ui::CollectResources;
|
||||
use crate::construct_ui::{new_building_positions, ConstructionPayment, ConstructionProject};
|
||||
|
|
@ -84,8 +85,7 @@ fn wonder_icons<'a>(rc: &'a RenderContext, city: &'a City) -> IconActionVec<'a>
|
|||
let owner = rc.shown_player;
|
||||
let game = rc.game;
|
||||
|
||||
owner
|
||||
.wonder_cards()
|
||||
wonder_cards(owner)
|
||||
.into_iter()
|
||||
.filter(|w| city.can_build_wonder(w, owner, game))
|
||||
.map(|w| {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use server::game::Game;
|
|||
use server::position::Position;
|
||||
|
||||
use crate::advance_ui::{pay_advance_dialog, show_paid_advance_menu};
|
||||
use crate::cards_ui::show_cards;
|
||||
use crate::client_state::{
|
||||
ActiveDialog, CameraMode, DialogChooser, State, StateUpdate, StateUpdates,
|
||||
};
|
||||
|
|
@ -23,8 +24,8 @@ use crate::player_ui::{player_select, show_global_controls, show_top_center, sho
|
|||
use crate::render_context::RenderContext;
|
||||
use crate::unit_ui::unit_selection_click;
|
||||
use crate::{
|
||||
custom_actions_ui, custom_phase_ui, dialog_ui, influence_ui, map_ui, move_ui, recruit_unit_ui,
|
||||
status_phase_ui, tooltip,
|
||||
cards_ui, custom_actions_ui, custom_phase_ui, dialog_ui, influence_ui, map_ui, move_ui,
|
||||
recruit_unit_ui, status_phase_ui, tooltip,
|
||||
};
|
||||
|
||||
fn render_with_mutable_state(game: &Game, state: &mut State, features: &Features) -> StateUpdate {
|
||||
|
|
@ -62,6 +63,7 @@ fn render(rc: &RenderContext, features: &Features) -> StateUpdate {
|
|||
show_top_center(rc);
|
||||
}
|
||||
if !state.active_dialog.is_modal() {
|
||||
updates.add(show_cards(rc));
|
||||
updates.add(player_select(rc));
|
||||
updates.add(show_global_controls(rc, features));
|
||||
}
|
||||
|
|
@ -79,7 +81,7 @@ fn render(rc: &RenderContext, features: &Features) -> StateUpdate {
|
|||
return StateUpdate::OpenDialog(ActiveDialog::AdvanceMenu);
|
||||
};
|
||||
|
||||
let can_control = rc.can_control();
|
||||
let can_control = rc.can_control_shown_player();
|
||||
if can_control {
|
||||
if let Some(u) = &state.pending_update {
|
||||
updates.add(dialog_ui::show_pending_update(u, rc));
|
||||
|
|
@ -166,6 +168,7 @@ fn render_active_dialog(rc: &RenderContext) -> StateUpdate {
|
|||
ActiveDialog::StructuresRequest(r) => custom_phase_ui::select_structures_dialog(rc, r),
|
||||
ActiveDialog::BoolRequest(d) => custom_phase_ui::bool_request_dialog(rc, d),
|
||||
ActiveDialog::PositionRequest(r) => custom_phase_ui::position_request_dialog(rc, r),
|
||||
ActiveDialog::HandCardsRequest(r) => cards_ui::select_cards_dialog(rc, r),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -185,7 +188,7 @@ pub fn try_click(rc: &RenderContext) -> StateUpdate {
|
|||
let mouse_pos = rc.mouse_pos();
|
||||
let pos = Position::from_coordinate(pixel_to_coordinate(mouse_pos));
|
||||
|
||||
if rc.can_control() {
|
||||
if rc.can_control_shown_player() {
|
||||
if let ActiveDialog::CulturalInfluence(b) = &rc.state.active_dialog {
|
||||
return influence_ui::hover(rc, mouse_pos, b);
|
||||
}
|
||||
|
|
@ -199,7 +202,7 @@ pub fn try_click(rc: &RenderContext) -> StateUpdate {
|
|||
return StateUpdate::None;
|
||||
}
|
||||
|
||||
if rc.can_control() {
|
||||
if rc.can_control_shown_player() {
|
||||
let update = controlling_player_click(rc, mouse_pos, pos);
|
||||
if !matches!(update, StateUpdate::None) {
|
||||
return update;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use crate::render_context::RenderContext;
|
|||
use crate::status_phase_ui::ChooseAdditionalAdvances;
|
||||
use macroquad::prelude::*;
|
||||
use server::action::Action;
|
||||
use server::card::HandCard;
|
||||
use server::city::{City, MoodState};
|
||||
use server::content::custom_phase_actions::{
|
||||
AdvanceRequest, ChangeGovernmentRequest, CurrentEventRequest, CurrentEventResponse,
|
||||
|
|
@ -57,6 +58,7 @@ pub enum ActiveDialog {
|
|||
UnitTypeRequest(UnitTypeRequest),
|
||||
UnitsRequest(UnitsSelection),
|
||||
StructuresRequest(MultiSelection<SelectedStructure>),
|
||||
HandCardsRequest(MultiSelection<HandCard>),
|
||||
BoolRequest(String),
|
||||
ChangeGovernmentType(ChangeGovernmentRequest),
|
||||
ChooseAdditionalAdvances(ChooseAdditionalAdvances),
|
||||
|
|
@ -95,6 +97,7 @@ impl ActiveDialog {
|
|||
ActiveDialog::UnitsRequest(_) => "custom phase units request",
|
||||
ActiveDialog::StructuresRequest(_) => "custom phase structures request",
|
||||
ActiveDialog::BoolRequest(_) => "custom phase bool request",
|
||||
ActiveDialog::HandCardsRequest(_) => "custom phase hand cards request",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -163,6 +166,9 @@ impl ActiveDialog {
|
|||
custom_phase_event_help(rc, &r.request.description)
|
||||
}
|
||||
ActiveDialog::PositionRequest(r) => custom_phase_event_help(rc, &r.request.description),
|
||||
ActiveDialog::HandCardsRequest(r) => {
|
||||
custom_phase_event_help(rc, &r.request.description)
|
||||
}
|
||||
ActiveDialog::PlayerRequest(r) => custom_phase_event_help(rc, &r.description),
|
||||
}
|
||||
}
|
||||
|
|
@ -550,7 +556,9 @@ impl State {
|
|||
panic!("ExploreResolution expected");
|
||||
}
|
||||
}
|
||||
CurrentEventRequest::SelectHandCards(_) => todo!(),
|
||||
CurrentEventRequest::SelectHandCards(r) => {
|
||||
ActiveDialog::HandCardsRequest(MultiSelection::new(r.clone()))
|
||||
}
|
||||
};
|
||||
}
|
||||
match &game.state {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use crate::cards_ui::wonder_cards;
|
||||
use crate::client_state::{ActiveDialog, StateUpdate};
|
||||
use crate::payment_ui::{payment_dialog, Payment};
|
||||
use crate::recruit_unit_ui::RecruitSelection;
|
||||
|
|
@ -106,7 +107,7 @@ impl ConstructionPayment {
|
|||
let cost = match &project {
|
||||
ConstructionProject::Building(b, _) => p.construct_cost(*b, city, None),
|
||||
ConstructionProject::Wonder(name) => p.wonder_cost(
|
||||
p.wonder_cards().iter().find(|w| w.name == *name).unwrap(),
|
||||
wonder_cards(p).iter().find(|w| w.name == *name).unwrap(),
|
||||
city,
|
||||
None,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -204,7 +204,11 @@ pub fn select_structures_dialog(
|
|||
}
|
||||
}
|
||||
|
||||
fn multi_select_tooltip<T: Clone>(s: &MultiSelection<T>, valid: bool, name: &str) -> OkTooltip {
|
||||
pub(crate) fn multi_select_tooltip<T: Clone>(
|
||||
s: &MultiSelection<T>,
|
||||
valid: bool,
|
||||
name: &str,
|
||||
) -> OkTooltip {
|
||||
if valid {
|
||||
OkTooltip::Valid(format!("Select {name}"))
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
clippy::cast_possible_truncation,
|
||||
clippy::missing_panics_doc
|
||||
)]
|
||||
extern crate core;
|
||||
|
||||
mod action_buttons;
|
||||
mod advance_ui;
|
||||
|
|
|
|||
|
|
@ -250,20 +250,18 @@ pub fn show_top_left(rc: &RenderContext) {
|
|||
}
|
||||
|
||||
pub fn get_combat(game: &Game) -> Option<&Combat> {
|
||||
game.current_events
|
||||
.last()
|
||||
.and_then(|e| match &e.event_type {
|
||||
CurrentEventType::CombatStart(c) => Some(c),
|
||||
CurrentEventType::CombatRoundStart(s) => Some(&s.combat),
|
||||
CurrentEventType::CombatRoundEnd(e) => Some(&e.combat),
|
||||
CurrentEventType::CombatEnd(e) => Some(&e.combat),
|
||||
_ => None,
|
||||
})
|
||||
game.events.last().and_then(|e| match &e.event_type {
|
||||
CurrentEventType::CombatStart(c) => Some(c),
|
||||
CurrentEventType::CombatRoundStart(s) => Some(&s.combat),
|
||||
CurrentEventType::CombatRoundEnd(e) => Some(&e.combat),
|
||||
CurrentEventType::CombatEnd(e) => Some(&e.combat),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn show_global_controls(rc: &RenderContext, features: &Features) -> StateUpdate {
|
||||
let assets = rc.assets();
|
||||
let can_control = rc.can_control();
|
||||
let can_control = rc.can_control_shown_player();
|
||||
if can_control {
|
||||
let game = rc.game;
|
||||
if let Some(tooltip) = can_end_move(game) {
|
||||
|
|
|
|||
|
|
@ -64,13 +64,17 @@ impl RenderContext<'_> {
|
|||
}
|
||||
|
||||
pub fn can_play_action(&self, action: PlayingActionType) -> bool {
|
||||
self.can_control()
|
||||
&& self.game.state == GameState::Playing
|
||||
self.can_control_shown_player()
|
||||
&& self.is_playing()
|
||||
&& self.game.actions_left > 0
|
||||
&& action.is_available(self.game, self.shown_player.index)
|
||||
}
|
||||
|
||||
pub fn can_control(&self) -> bool {
|
||||
pub fn is_playing(&self) -> bool {
|
||||
self.game.state == GameState::Playing && self.game.events.is_empty()
|
||||
}
|
||||
|
||||
pub fn can_control_shown_player(&self) -> bool {
|
||||
self.can_control_active_player() && self.shown_player_is_active()
|
||||
}
|
||||
|
||||
|
|
|
|||
25
mise.toml
Normal file
25
mise.toml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
[tasks.update-tests]
|
||||
description = "Run server tests and update json files"
|
||||
run = "cargo test"
|
||||
env = { RUST_BACKTRACE = "1", UPDATE_EXPECTED = "true" }
|
||||
dir = "server"
|
||||
|
||||
[tasks.server-format-and-lint]
|
||||
description = "Format and lint all code"
|
||||
run = [
|
||||
"cargo fmt",
|
||||
"cargo clippy --fix --allow-dirty --allow-staged"
|
||||
]
|
||||
dir = "server"
|
||||
|
||||
[tasks.client-format-and-lint]
|
||||
description = "Format and lint all code"
|
||||
run = [
|
||||
"cargo fmt",
|
||||
"cargo clippy --fix --allow-dirty --allow-staged"
|
||||
]
|
||||
dir = "client"
|
||||
|
||||
[tasks.format-and-lint]
|
||||
depends = ["server-format-and-lint", "client-format-and-lint"]
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ use crate::content::custom_phase_actions::{
|
|||
ResourceRewardRequest, SelectedStructure, StructuresRequest, UnitTypeRequest, UnitsRequest,
|
||||
};
|
||||
use crate::events::{Event, EventOrigin};
|
||||
use crate::player_events::CurrentEvent;
|
||||
use crate::player_events::{CurrentEvent, PersistentEvents, TransientEvents};
|
||||
use crate::position::Position;
|
||||
use crate::resource_pile::ResourcePile;
|
||||
use crate::tactics_card::CombatRole;
|
||||
|
|
@ -135,7 +135,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
self
|
||||
}
|
||||
|
||||
fn add_player_event_listener<T, U, V, W, E, F>(
|
||||
fn add_transient_event_listener<T, U, V, E, F>(
|
||||
self,
|
||||
event: E,
|
||||
priority: i32,
|
||||
|
|
@ -143,29 +143,15 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
) -> Self
|
||||
where
|
||||
T: Clone + PartialEq,
|
||||
W: Clone + PartialEq,
|
||||
E: Fn(&mut PlayerEvents) -> &mut Event<T, U, V, W> + 'static + Clone,
|
||||
F: Fn(&mut T, &U, &V, &mut W) + 'static + Clone,
|
||||
E: Fn(&mut TransientEvents) -> &mut Event<T, U, V> + 'static + Clone,
|
||||
F: Fn(&mut T, &U, &V) + 'static + Clone,
|
||||
{
|
||||
let key = self.get_key().clone();
|
||||
let deinitialize_event = event.clone();
|
||||
let initializer = move |game: &mut Game, player_index: usize| {
|
||||
event(&mut game.players[player_index].events)
|
||||
.inner
|
||||
.as_mut()
|
||||
.expect("events should be set")
|
||||
.add_listener_mut(listener.clone(), priority, key.clone());
|
||||
};
|
||||
let key = self.get_key().clone();
|
||||
let deinitializer = move |game: &mut Game, player_index: usize| {
|
||||
deinitialize_event(&mut game.players[player_index].events)
|
||||
.inner
|
||||
.as_mut()
|
||||
.expect("events should be set")
|
||||
.remove_listener_mut_by_key(&key);
|
||||
};
|
||||
self.add_ability_initializer(initializer)
|
||||
.add_ability_deinitializer(deinitializer)
|
||||
add_player_event_listener(
|
||||
self,
|
||||
move |events| event(&mut events.transient),
|
||||
priority,
|
||||
move |value, u, v, ()| listener(value, u, v),
|
||||
)
|
||||
}
|
||||
|
||||
fn add_combat_round_start_listener(
|
||||
|
|
@ -194,11 +180,11 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
) -> Self
|
||||
where
|
||||
T: Clone + PartialEq,
|
||||
E: Fn(&mut PlayerEvents) -> &mut Event<T, U, V, ()> + 'static + Clone,
|
||||
E: Fn(&mut TransientEvents) -> &mut Event<T, U, V, ()> + 'static + Clone,
|
||||
F: Fn(&mut T, &U, &V) + 'static + Clone,
|
||||
{
|
||||
let id = self.get_key().id();
|
||||
self.add_player_event_listener(event, priority, move |value, u, v, ()| {
|
||||
self.add_transient_event_listener(event, priority, move |value, u, v| {
|
||||
if !get_info(value).contains_key(&id) {
|
||||
listener(value, u, v);
|
||||
get_info(value).insert(id.clone(), "used".to_string());
|
||||
|
|
@ -218,68 +204,74 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
+ Clone,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
let origin = self.get_key();
|
||||
self.add_player_event_listener(event, priority, move |game, i, (), details| {
|
||||
let player_index = i.player;
|
||||
let player_name = game.player_name(player_index);
|
||||
add_player_event_listener(
|
||||
self,
|
||||
move |e| event(&mut e.persistent),
|
||||
priority,
|
||||
move |game, i, (), details| {
|
||||
let player_index = i.player;
|
||||
let player_name = game.player_name(player_index);
|
||||
|
||||
if let Some(mut phase) = game.current_events.pop() {
|
||||
if let Some(ref c) = phase.player.handler {
|
||||
if let Some(ref action) = c.response {
|
||||
if c.priority == priority {
|
||||
let mut current = phase.clone();
|
||||
current
|
||||
.player
|
||||
.handler
|
||||
.as_mut()
|
||||
.expect("current missing")
|
||||
.response = None;
|
||||
let r = c.request.clone();
|
||||
let a = action.clone();
|
||||
phase.player.handler = None;
|
||||
game.current_events.push(phase);
|
||||
end_custom_phase.clone()(
|
||||
game,
|
||||
player_index,
|
||||
&player_name,
|
||||
a,
|
||||
r,
|
||||
details,
|
||||
);
|
||||
return;
|
||||
if let Some(mut phase) = game.events.pop() {
|
||||
if let Some(ref c) = phase.player.handler {
|
||||
if let Some(ref action) = c.response {
|
||||
if c.priority == priority {
|
||||
let mut current = phase.clone();
|
||||
current
|
||||
.player
|
||||
.handler
|
||||
.as_mut()
|
||||
.expect("current missing")
|
||||
.response = None;
|
||||
let r = c.request.clone();
|
||||
let a = action.clone();
|
||||
phase.player.handler = None;
|
||||
game.events.push(phase);
|
||||
end_custom_phase.clone()(
|
||||
game,
|
||||
player_index,
|
||||
&player_name,
|
||||
a,
|
||||
r,
|
||||
details,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
let is_current = phase.player.handler.is_some();
|
||||
game.events.push(phase);
|
||||
if is_current {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let is_current = phase.player.handler.is_some();
|
||||
game.current_events.push(phase);
|
||||
if is_current {
|
||||
|
||||
if game
|
||||
.current_event_player()
|
||||
.last_priority_used
|
||||
.is_some_and(|last| last < priority)
|
||||
{
|
||||
// already handled before
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if game
|
||||
.current_event_player()
|
||||
.last_priority_used
|
||||
.is_some_and(|last| last < priority)
|
||||
{
|
||||
// already handled before
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(request) = start_custom_phase(game, player_index, &player_name, details) {
|
||||
let s = game.current_event_mut();
|
||||
s.player.last_priority_used = Some(priority);
|
||||
s.player.handler = Some(CurrentEventHandler {
|
||||
priority,
|
||||
request: request.clone(),
|
||||
response: None,
|
||||
origin: origin.clone(),
|
||||
});
|
||||
};
|
||||
})
|
||||
if let Some(request) = start_custom_phase(game, player_index, &player_name, details)
|
||||
{
|
||||
let s = game.current_event_mut();
|
||||
s.player.last_priority_used = Some(priority);
|
||||
s.player.handler = Some(CurrentEventHandler {
|
||||
priority,
|
||||
request: request.clone(),
|
||||
response: None,
|
||||
origin: origin.clone(),
|
||||
});
|
||||
};
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn add_simple_current_event_listener<V, E, F>(
|
||||
|
|
@ -289,7 +281,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
listener: F,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
F: Fn(&mut Game, usize, &str, &mut V) + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
|
|
@ -313,7 +305,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
gain_reward: impl Fn(&mut Game, &SelectedChoice<Vec<ResourcePile>>, &mut V) + 'static + Clone,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
self.add_current_event_listener(
|
||||
|
|
@ -360,7 +352,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
+ Clone,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
let g = gain_reward_log.clone();
|
||||
|
|
@ -414,7 +406,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
gain_reward: impl Fn(&mut Game, &SelectedChoice<bool>, &mut V) + 'static + Clone,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
self.add_current_event_listener(
|
||||
|
|
@ -439,7 +431,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
)
|
||||
}
|
||||
|
||||
fn add_advance_reward_request_listener<E, V>(
|
||||
fn add_advance_request<E, V>(
|
||||
self,
|
||||
event: E,
|
||||
priority: i32,
|
||||
|
|
@ -447,7 +439,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
gain_reward: impl Fn(&mut Game, &SelectedChoice<String>, &mut V) + 'static + Clone,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
self.add_choice_reward_request_listener::<E, String, AdvanceRequest, V>(
|
||||
|
|
@ -476,7 +468,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
gain_reward: impl Fn(&mut Game, &SelectedChoice<Vec<Position>>, &mut V) + 'static + Clone,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
self.add_multi_choice_reward_request_listener::<E, Position, PositionRequest, V>(
|
||||
|
|
@ -505,7 +497,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
gain_reward: impl Fn(&mut Game, &SelectedChoice<usize>, &mut V) + 'static + Clone,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
self.add_choice_reward_request_listener::<E, usize, PlayerRequest, V>(
|
||||
|
|
@ -534,7 +526,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
gain_reward: impl Fn(&mut Game, &SelectedChoice<UnitType>, &mut V) + 'static + Clone,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
self.add_choice_reward_request_listener::<E, UnitType, UnitTypeRequest, V>(
|
||||
|
|
@ -563,7 +555,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
cards_selected: impl Fn(&mut Game, &SelectedChoice<Vec<HandCard>>, &mut V) + 'static + Clone,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
self.add_multi_choice_reward_request_listener::<E, HandCard, HandCardsRequest, V>(
|
||||
|
|
@ -592,7 +584,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
units_selected: impl Fn(&mut Game, &SelectedChoice<Vec<u32>>, &mut V) + 'static + Clone,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
self.add_multi_choice_reward_request_listener::<E, u32, UnitsRequest, V>(
|
||||
|
|
@ -629,7 +621,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
+ Clone,
|
||||
) -> Self
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
self.add_multi_choice_reward_request_listener::<E, SelectedStructure, StructuresRequest, V>(
|
||||
|
|
@ -664,7 +656,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
) -> Self
|
||||
where
|
||||
C: Clone + PartialEq,
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
let g = gain_reward.clone();
|
||||
|
|
@ -720,7 +712,7 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
) -> Self
|
||||
where
|
||||
C: Clone + PartialEq,
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
let g = gain_reward.clone();
|
||||
|
|
@ -785,10 +777,45 @@ pub(crate) trait AbilityInitializerSetup: Sized {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn join_ability_initializers(setup: Vec<AbilityInitializer>) -> AbilityInitializer {
|
||||
fn join_ability_initializers(setup: Vec<AbilityInitializer>) -> AbilityInitializer {
|
||||
Box::new(move |game: &mut Game, player_index: usize| {
|
||||
for initializer in &setup {
|
||||
initializer(game, player_index);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn add_player_event_listener<S, T, U, V, W, E, F>(
|
||||
setup: S,
|
||||
event: E,
|
||||
priority: i32,
|
||||
listener: F,
|
||||
) -> S
|
||||
where
|
||||
S: AbilityInitializerSetup,
|
||||
T: Clone + PartialEq,
|
||||
W: Clone + PartialEq,
|
||||
E: Fn(&mut PlayerEvents) -> &mut Event<T, U, V, W> + 'static + Clone,
|
||||
F: Fn(&mut T, &U, &V, &mut W) + 'static + Clone,
|
||||
{
|
||||
let key = setup.get_key().clone();
|
||||
let deinitialize_event = event.clone();
|
||||
let initializer = move |game: &mut Game, player_index: usize| {
|
||||
event(&mut game.players[player_index].events)
|
||||
.inner
|
||||
.as_mut()
|
||||
.expect("events should be set")
|
||||
.add_listener_mut(listener.clone(), priority, key.clone());
|
||||
};
|
||||
let key = setup.get_key().clone();
|
||||
let deinitializer = move |game: &mut Game, player_index: usize| {
|
||||
deinitialize_event(&mut game.players[player_index].events)
|
||||
.inner
|
||||
.as_mut()
|
||||
.expect("events should be set")
|
||||
.remove_listener_mut_by_key(&key);
|
||||
};
|
||||
setup
|
||||
.add_ability_initializer(initializer)
|
||||
.add_ability_deinitializer(deinitializer)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::advance::gain_advance;
|
||||
use crate::advance::on_advance;
|
||||
use crate::combat::{combat_loop, move_with_possible_combat, start_combat};
|
||||
use crate::combat_listeners::{combat_round_end, combat_round_start, end_combat};
|
||||
use crate::content::custom_phase_actions::{CurrentEventResponse, CurrentEventType};
|
||||
|
|
@ -12,7 +12,7 @@ use crate::map::Terrain::Unexplored;
|
|||
use crate::movement::{
|
||||
get_move_state, has_movable_units, move_units_destinations, CurrentMove, MoveState,
|
||||
};
|
||||
use crate::playing_actions::PlayingAction;
|
||||
use crate::playing_actions::{on_construct, play_action_card, PlayingAction};
|
||||
use crate::recruit::on_recruit;
|
||||
use crate::resource::check_for_waste;
|
||||
use crate::resource_pile::ResourcePile;
|
||||
|
|
@ -115,7 +115,7 @@ fn execute_without_undo(mut game: Game, action: Action, player_index: usize) ->
|
|||
if let Some(s) = game.current_event_handler_mut() {
|
||||
s.response = action.custom_phase_event();
|
||||
let details = game.current_event().event_type.clone();
|
||||
execute_custom_phase_action(&mut game, player_index, &details);
|
||||
execute_custom_phase_action(&mut game, player_index, details);
|
||||
} else {
|
||||
execute_regular_action(&mut game, action, player_index);
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ fn add_action_log_item(game: &mut Game, item: Action) {
|
|||
pub(crate) fn execute_custom_phase_action(
|
||||
game: &mut Game,
|
||||
player_index: usize,
|
||||
details: &CurrentEventType,
|
||||
details: CurrentEventType,
|
||||
) {
|
||||
use CurrentEventType::*;
|
||||
match details {
|
||||
|
|
@ -148,7 +148,7 @@ pub(crate) fn execute_custom_phase_action(
|
|||
ask_for_cultural_influence_payment(game, player_index, r);
|
||||
}
|
||||
CombatStart(c) => {
|
||||
start_combat(game, c.clone());
|
||||
start_combat(game, c);
|
||||
}
|
||||
CombatRoundStart(r) => {
|
||||
if let Some(c) = combat_round_start(game, r) {
|
||||
|
|
@ -163,20 +163,19 @@ pub(crate) fn execute_custom_phase_action(
|
|||
CombatEnd(r) => {
|
||||
end_combat(game, r);
|
||||
}
|
||||
StatusPhase(s) => play_status_phase(game, s.clone()),
|
||||
StatusPhase(s) => play_status_phase(game, s),
|
||||
TurnStart => game.start_turn(),
|
||||
Advance(a) => {
|
||||
gain_advance(game, player_index, a);
|
||||
on_advance(game, player_index, a);
|
||||
}
|
||||
Construct(b) => {
|
||||
PlayingAction::on_construct(game, player_index, *b);
|
||||
on_construct(game, player_index, b);
|
||||
}
|
||||
Recruit(r) => {
|
||||
on_recruit(game, player_index, r);
|
||||
}
|
||||
Incident(i) => {
|
||||
trigger_incident(game, i.clone());
|
||||
}
|
||||
Incident(i) => trigger_incident(game, i),
|
||||
ActionCard(a) => play_action_card(game, player_index, a),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,16 @@ use crate::card::draw_card_from_pile;
|
|||
use crate::content::action_cards;
|
||||
use crate::events::EventOrigin;
|
||||
use crate::game::Game;
|
||||
use crate::player::Player;
|
||||
use crate::tactics_card::TacticsCard;
|
||||
use action_cards::get_action_card;
|
||||
|
||||
pub type CanPlayCard = Box<dyn Fn(&Game, &Player) -> bool>;
|
||||
|
||||
pub struct CivilCard {
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub can_play: CanPlayCard,
|
||||
pub listeners: AbilityListeners,
|
||||
}
|
||||
|
||||
|
|
@ -30,13 +35,24 @@ impl ActionCard {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn civil_card_builder(
|
||||
pub fn civil_card_builder<F>(
|
||||
id: u8,
|
||||
name: &str,
|
||||
description: &str,
|
||||
can_play: F,
|
||||
tactics_card: TacticsCard,
|
||||
) -> CivilCardBuilder {
|
||||
CivilCardBuilder::new(id, name, description, tactics_card)
|
||||
) -> CivilCardBuilder
|
||||
where
|
||||
F: Fn(&Game, &Player) -> bool + 'static,
|
||||
{
|
||||
CivilCardBuilder {
|
||||
id,
|
||||
name: name.to_string(),
|
||||
description: description.to_string(),
|
||||
can_play: Box::new(can_play),
|
||||
tactics_card,
|
||||
builder: AbilityInitializerBuilder::new(),
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
|
@ -53,21 +69,12 @@ pub struct CivilCardBuilder {
|
|||
id: u8,
|
||||
name: String,
|
||||
description: String,
|
||||
can_play: CanPlayCard,
|
||||
tactics_card: TacticsCard,
|
||||
builder: AbilityInitializerBuilder,
|
||||
}
|
||||
|
||||
impl CivilCardBuilder {
|
||||
fn new(id: u8, name: &str, description: &str, tactics_card: TacticsCard) -> Self {
|
||||
Self {
|
||||
id,
|
||||
name: name.to_string(),
|
||||
description: description.to_string(),
|
||||
tactics_card,
|
||||
builder: AbilityInitializerBuilder::new(),
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn build(self) -> ActionCard {
|
||||
ActionCard::new(
|
||||
|
|
@ -75,6 +82,7 @@ impl CivilCardBuilder {
|
|||
CivilCard {
|
||||
name: self.name,
|
||||
description: self.description,
|
||||
can_play: self.can_play,
|
||||
listeners: self.builder.build(),
|
||||
},
|
||||
self.tactics_card,
|
||||
|
|
@ -98,7 +106,7 @@ pub(crate) fn gain_action_card_from_pile(game: &mut Game, player: usize) {
|
|||
"{} gained an action card from the pile",
|
||||
game.player_name(player)
|
||||
));
|
||||
gain_action_card(game, player, c);
|
||||
gain_action_card(game, player, &c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -109,11 +117,11 @@ fn draw_action_card_from_pile(game: &mut Game) -> Option<ActionCard> {
|
|||
false,
|
||||
|g| &mut g.action_cards_left,
|
||||
|| action_cards::get_all().iter().map(|c| c.id).collect(),
|
||||
|p| p.action_cards.iter().map(|c| c.id).collect(),
|
||||
|p| p.action_cards.clone(),
|
||||
)
|
||||
.map(action_cards::get_action_card)
|
||||
.map(get_action_card)
|
||||
}
|
||||
|
||||
fn gain_action_card(game: &mut Game, player_index: usize, action_card: ActionCard) {
|
||||
game.players[player_index].action_cards.push(action_card);
|
||||
fn gain_action_card(game: &mut Game, player_index: usize, action_card: &ActionCard) {
|
||||
game.players[player_index].action_cards.push(action_card.id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,41 +169,44 @@ pub fn do_advance(game: &mut Game, advance: &Advance, player_index: usize) {
|
|||
player.advances.push(get_advance(&advance.name));
|
||||
}
|
||||
|
||||
pub(crate) fn advance_with_incident_token(
|
||||
pub(crate) fn gain_advance(
|
||||
game: &mut Game,
|
||||
name: &str,
|
||||
player_index: usize,
|
||||
payment: ResourcePile,
|
||||
take_incident_token: bool,
|
||||
) {
|
||||
do_advance(game, &get_advance(name), player_index);
|
||||
gain_advance(
|
||||
on_advance(
|
||||
game,
|
||||
player_index,
|
||||
&AdvanceInfo {
|
||||
AdvanceInfo {
|
||||
name: name.to_string(),
|
||||
payment,
|
||||
take_incident_token,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn gain_advance(game: &mut Game, player_index: usize, info: &AdvanceInfo) {
|
||||
if game
|
||||
.trigger_current_event(
|
||||
&[player_index],
|
||||
|e| &mut e.on_advance,
|
||||
info,
|
||||
CurrentEventType::Advance,
|
||||
None,
|
||||
)
|
||||
.is_none()
|
||||
{
|
||||
return;
|
||||
}
|
||||
let player = &mut game.players[player_index];
|
||||
player.incident_tokens -= 1;
|
||||
if player.incident_tokens == 0 {
|
||||
player.incident_tokens = 3;
|
||||
trigger_incident(game, IncidentInfo::new(player_index));
|
||||
pub(crate) fn on_advance(game: &mut Game, player_index: usize, info: AdvanceInfo) {
|
||||
let info = match game.trigger_current_event(
|
||||
&[player_index],
|
||||
|e| &mut e.on_advance,
|
||||
info,
|
||||
CurrentEventType::Advance,
|
||||
None,
|
||||
) {
|
||||
None => return,
|
||||
Some(i) => i,
|
||||
};
|
||||
|
||||
if info.take_incident_token {
|
||||
let player = game.get_player_mut(player_index);
|
||||
player.incident_tokens -= 1;
|
||||
if player.incident_tokens == 0 {
|
||||
player.incident_tokens = 3;
|
||||
trigger_incident(game, IncidentInfo::new(player_index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -313,8 +313,8 @@ pub(crate) fn set_info(
|
|||
builder.add_simple_incident_listener(
|
||||
IncidentTarget::ActivePlayer,
|
||||
BASE_EFFECT_PRIORITY + 200,
|
||||
move |game, player, _, _| {
|
||||
if play_base_effect(game) && game.current_event().barbarians.is_none() {
|
||||
move |game, player, _, i| {
|
||||
if play_base_effect(i) && game.current_event().barbarians.is_none() {
|
||||
game.add_info_log_item(&format!("Base effect: {name}"));
|
||||
let mut state = BarbariansEventState::new();
|
||||
init(&mut state, game, player);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,21 @@
|
|||
use crate::game::Game;
|
||||
use crate::player::Player;
|
||||
use crate::utils::Shuffle;
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub enum HandCardType {
|
||||
Action,
|
||||
Wonder,
|
||||
}
|
||||
|
||||
impl HandCardType {
|
||||
#[must_use]
|
||||
pub fn get_all() -> Vec<HandCardType> {
|
||||
vec![HandCardType::Action, HandCardType::Wonder]
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum HandCard {
|
||||
ActionCard(u8),
|
||||
|
|
@ -46,3 +59,22 @@ where
|
|||
Some(get_pile(game).remove(0))
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn hand_cards(player: &Player, types: &[HandCardType]) -> Vec<HandCard> {
|
||||
types
|
||||
.iter()
|
||||
.flat_map(|t| match t {
|
||||
HandCardType::Action => player
|
||||
.action_cards
|
||||
.iter()
|
||||
.map(|&id| HandCard::ActionCard(id))
|
||||
.collect_vec(),
|
||||
HandCardType::Wonder => player
|
||||
.wonder_cards
|
||||
.iter()
|
||||
.map(|n| HandCard::Wonder(n.clone()))
|
||||
.collect(),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,10 +63,7 @@ pub(crate) fn collect(game: &mut Game, player_index: usize, c: &Collect) {
|
|||
city.activate();
|
||||
let _ = game
|
||||
.get_player(player_index)
|
||||
.events
|
||||
.on_collect
|
||||
.get()
|
||||
.trigger(&mut i, game, &(), &mut ());
|
||||
.trigger_event(|e| &e.on_collect, &mut i, game, &());
|
||||
i.info.execute(game);
|
||||
game.players[player_index].gain_resources(i.total.clone());
|
||||
}
|
||||
|
|
@ -120,11 +117,12 @@ pub fn possible_resource_collections(
|
|||
(Forest, HashSet::from([ResourcePile::wood(1)])),
|
||||
];
|
||||
let mut terrain_options = HashMap::from(set);
|
||||
let modifiers = game.players[player_index]
|
||||
.events
|
||||
.terrain_collect_options
|
||||
.get()
|
||||
.trigger(&mut terrain_options, &(), &(), &mut ());
|
||||
let modifiers = game.get_player(player_index).trigger_event(
|
||||
|e| &e.terrain_collect_options,
|
||||
&mut terrain_options,
|
||||
&(),
|
||||
&(),
|
||||
);
|
||||
|
||||
let collect_options = city_pos
|
||||
.neighbors()
|
||||
|
|
@ -142,6 +140,7 @@ pub fn possible_resource_collections(
|
|||
|
||||
let mut i = game.players[player_index]
|
||||
.events
|
||||
.transient
|
||||
.collect_options
|
||||
.get()
|
||||
.trigger_with_minimal_modifiers(
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use crate::city::City;
|
|||
use crate::city::MoodState::Angry;
|
||||
use crate::city_pieces::Building;
|
||||
use crate::combat_listeners::{
|
||||
combat_round_end, combat_round_start, Casualties, CombatRoundEnd, CombatRoundStart,
|
||||
CombatRoundType, CombatStrength,
|
||||
combat_round_end, combat_round_start, Casualties, CombatEventPhase, CombatRoundEnd,
|
||||
CombatRoundStart, CombatStrength,
|
||||
};
|
||||
use crate::consts::SHIP_CAPACITY;
|
||||
use crate::content::custom_phase_actions::CurrentEventType;
|
||||
|
|
@ -177,6 +177,14 @@ impl Combat {
|
|||
CombatRole::Defender
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn player(&self, role: CombatRole) -> usize {
|
||||
match role {
|
||||
CombatRole::Attacker => self.attacker,
|
||||
CombatRole::Defender => self.defender,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn initiate_combat(
|
||||
|
|
@ -201,22 +209,22 @@ pub fn initiate_combat(
|
|||
start_combat(game, combat);
|
||||
}
|
||||
|
||||
pub(crate) fn start_combat(game: &mut Game, mut combat: Combat) {
|
||||
pub(crate) fn start_combat(game: &mut Game, combat: Combat) {
|
||||
game.lock_undo(); // combat should not be undoable
|
||||
stop_current_move(game);
|
||||
|
||||
match game.trigger_current_event(
|
||||
let c = match game.trigger_current_event(
|
||||
&combat.players(),
|
||||
|events| &mut events.on_combat_start,
|
||||
&combat,
|
||||
combat,
|
||||
CurrentEventType::CombatStart,
|
||||
None,
|
||||
) {
|
||||
None => return,
|
||||
Some(c) => combat = c,
|
||||
}
|
||||
Some(c) => c,
|
||||
};
|
||||
|
||||
combat_loop(game, CombatRoundStart::new(combat));
|
||||
combat_loop(game, CombatRoundStart::new(c));
|
||||
}
|
||||
|
||||
pub(crate) fn update_combat_strength(
|
||||
|
|
@ -246,8 +254,8 @@ pub(crate) fn update_combat_strength(
|
|||
|
||||
pub(crate) fn combat_loop(game: &mut Game, mut s: CombatRoundStart) {
|
||||
loop {
|
||||
if s.round_type != CombatRoundType::Done {
|
||||
match combat_round_start(game, &s) {
|
||||
if s.phase != CombatEventPhase::Done {
|
||||
match combat_round_start(game, s) {
|
||||
Some(value) => s = value,
|
||||
None => return,
|
||||
};
|
||||
|
|
@ -315,26 +323,14 @@ pub(crate) fn combat_loop(game: &mut Game, mut s: CombatRoundStart) {
|
|||
&& defender_hits < active_attackers.len() as u8;
|
||||
|
||||
let result = CombatRoundEnd::new(
|
||||
Casualties::new(
|
||||
defender_hits,
|
||||
game,
|
||||
&c,
|
||||
c.attacker,
|
||||
s.attacker_strength.tactics_card.clone(),
|
||||
),
|
||||
Casualties::new(
|
||||
attacker_hits,
|
||||
game,
|
||||
&c,
|
||||
c.defender,
|
||||
s.defender_strength.tactics_card.clone(),
|
||||
),
|
||||
Casualties::new(defender_hits, s.attacker_strength.tactics_card.clone()),
|
||||
Casualties::new(attacker_hits, s.defender_strength.tactics_card.clone()),
|
||||
can_retreat,
|
||||
c,
|
||||
game,
|
||||
);
|
||||
|
||||
if let Some(r) = combat_round_end(game, &result) {
|
||||
if let Some(r) = combat_round_end(game, result) {
|
||||
s = CombatRoundStart::new(r);
|
||||
} else {
|
||||
return;
|
||||
|
|
@ -661,7 +657,7 @@ pub mod tests {
|
|||
pub fn test_game() -> Game {
|
||||
Game {
|
||||
state: GameState::Playing,
|
||||
current_events: Vec::new(),
|
||||
events: Vec::new(),
|
||||
players: Vec::new(),
|
||||
map: Map::new(HashMap::new()),
|
||||
starting_player_index: 0,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::content::custom_phase_actions::{new_position_request, CurrentEventTyp
|
|||
use crate::content::tactics_cards;
|
||||
use crate::game::Game;
|
||||
use crate::movement::move_units;
|
||||
use crate::player_events::{CurrentEvent, PlayerEvents};
|
||||
use crate::player_events::{CurrentEvent, PersistentEvents};
|
||||
use crate::position::Position;
|
||||
use crate::tactics_card::CombatRole;
|
||||
use crate::unit::{UnitType, Units};
|
||||
|
|
@ -44,18 +44,28 @@ impl CombatStrength {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum CombatRoundType {
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug, Default)]
|
||||
pub enum CombatEventPhase {
|
||||
#[default]
|
||||
Default,
|
||||
TacticsCardAttacker,
|
||||
TacticsCardDefender,
|
||||
Done,
|
||||
}
|
||||
|
||||
impl CombatEventPhase {
|
||||
#[must_use]
|
||||
pub fn is_default(&self) -> bool {
|
||||
matches!(self, CombatEventPhase::Default)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct CombatRoundStart {
|
||||
pub combat: Combat,
|
||||
pub round_type: CombatRoundType,
|
||||
#[serde(default)]
|
||||
#[serde(skip_serializing_if = "CombatEventPhase::is_default")]
|
||||
pub phase: CombatEventPhase,
|
||||
pub attacker_strength: CombatStrength,
|
||||
pub defender_strength: CombatStrength,
|
||||
}
|
||||
|
|
@ -67,7 +77,7 @@ impl CombatRoundStart {
|
|||
combat,
|
||||
attacker_strength: CombatStrength::new(),
|
||||
defender_strength: CombatStrength::new(),
|
||||
round_type: CombatRoundType::Default,
|
||||
phase: CombatEventPhase::Default,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -144,32 +154,25 @@ pub struct Casualties {
|
|||
#[serde(skip_serializing_if = "u8::is_zero")]
|
||||
pub fighters: u8,
|
||||
#[serde(default)]
|
||||
#[serde(skip_serializing_if = "u8::is_zero")]
|
||||
pub carried_units: u8,
|
||||
#[serde(default)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub tactics_card: Option<String>,
|
||||
}
|
||||
|
||||
impl Casualties {
|
||||
#[must_use]
|
||||
pub fn new(
|
||||
fighters: u8,
|
||||
game: &Game,
|
||||
c: &Combat,
|
||||
player: usize,
|
||||
tactics_card: Option<String>,
|
||||
) -> Self {
|
||||
pub fn new(fighters: u8, tactics_card: Option<String>) -> Self {
|
||||
Self {
|
||||
fighters,
|
||||
carried_units: c.carried_units_casualties(game, player, fighters),
|
||||
tactics_card,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct CombatRoundEnd {
|
||||
pub round_type: CombatRoundType,
|
||||
#[serde(default)]
|
||||
#[serde(skip_serializing_if = "CombatEventPhase::is_default")]
|
||||
pub phase: CombatEventPhase,
|
||||
pub attacker_casualties: Casualties,
|
||||
pub defender_casualties: Casualties,
|
||||
#[serde(default)]
|
||||
|
|
@ -210,7 +213,7 @@ impl CombatRoundEnd {
|
|||
can_retreat,
|
||||
final_result,
|
||||
combat,
|
||||
round_type: CombatRoundType::Default,
|
||||
phase: CombatEventPhase::TacticsCardAttacker,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -224,17 +227,26 @@ impl CombatRoundEnd {
|
|||
&self.defender_casualties
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn casualties_mut(&mut self, role: CombatRole) -> &mut Casualties {
|
||||
if role.is_attacker() {
|
||||
&mut self.attacker_casualties
|
||||
} else {
|
||||
&mut self.defender_casualties
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ROUND_START_TYPES: &[CombatRoundType; 3] = &[
|
||||
CombatRoundType::Default,
|
||||
CombatRoundType::TacticsCardAttacker,
|
||||
CombatRoundType::TacticsCardDefender,
|
||||
const ROUND_START_TYPES: &[CombatEventPhase; 3] = &[
|
||||
CombatEventPhase::Default,
|
||||
CombatEventPhase::TacticsCardAttacker,
|
||||
CombatEventPhase::TacticsCardDefender,
|
||||
];
|
||||
|
||||
pub(crate) fn combat_round_start(
|
||||
game: &mut Game,
|
||||
start: &CombatRoundStart,
|
||||
start: CombatRoundStart,
|
||||
) -> Option<CombatRoundStart> {
|
||||
event_with_tactics(
|
||||
game,
|
||||
|
|
@ -243,20 +255,21 @@ pub(crate) fn combat_round_start(
|
|||
ROUND_START_TYPES,
|
||||
|events| &mut events.on_combat_round_start,
|
||||
|events| &mut events.on_combat_round_start_tactics,
|
||||
|s| &mut s.round_type,
|
||||
|s| &mut s.phase,
|
||||
|s| &s.combat,
|
||||
|s| s.attacker_strength.tactics_card.as_ref(),
|
||||
|s| s.defender_strength.tactics_card.as_ref(),
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
const ROUND_END_TYPES: &[CombatRoundType; 3] = &[
|
||||
CombatRoundType::TacticsCardAttacker,
|
||||
CombatRoundType::TacticsCardDefender,
|
||||
CombatRoundType::Default,
|
||||
const ROUND_END_TYPES: &[CombatEventPhase; 3] = &[
|
||||
CombatEventPhase::TacticsCardAttacker,
|
||||
CombatEventPhase::TacticsCardDefender,
|
||||
CombatEventPhase::Default,
|
||||
];
|
||||
|
||||
pub(crate) fn combat_round_end(game: &mut Game, r: &CombatRoundEnd) -> Option<Combat> {
|
||||
pub(crate) fn combat_round_end(game: &mut Game, r: CombatRoundEnd) -> Option<Combat> {
|
||||
let e = event_with_tactics(
|
||||
game,
|
||||
r,
|
||||
|
|
@ -264,26 +277,26 @@ pub(crate) fn combat_round_end(game: &mut Game, r: &CombatRoundEnd) -> Option<Co
|
|||
ROUND_END_TYPES,
|
||||
|events| &mut events.on_combat_round_end,
|
||||
|events| &mut events.on_combat_round_end_tactics,
|
||||
|s| &mut s.round_type,
|
||||
|s| &mut s.phase,
|
||||
|s| &s.combat,
|
||||
|s| s.attacker_casualties.tactics_card.as_ref(),
|
||||
|s| s.defender_casualties.tactics_card.as_ref(),
|
||||
false,
|
||||
);
|
||||
let mut c = match e {
|
||||
None => return None,
|
||||
Some(e) => e.combat,
|
||||
};
|
||||
let e = e?;
|
||||
|
||||
if let Some(f) = &r.final_result {
|
||||
if let Some(f) = &e.final_result {
|
||||
let c = e.combat;
|
||||
match f {
|
||||
CombatResult::AttackerWins => attacker_wins(game, c),
|
||||
CombatResult::DefenderWins => defender_wins(game, c),
|
||||
CombatResult::Draw => draw(game, c),
|
||||
}
|
||||
None
|
||||
} else if matches!(c.retreat, CombatRetreatState::EndAfterCurrentRound) {
|
||||
} else if matches!(e.combat.retreat, CombatRetreatState::EndAfterCurrentRound) {
|
||||
None
|
||||
} else {
|
||||
let mut c = e.combat;
|
||||
c.round += 1;
|
||||
crate::combat::log_round(game, &c);
|
||||
Some(c)
|
||||
|
|
@ -294,12 +307,12 @@ fn attacker_wins(game: &mut Game, c: Combat) {
|
|||
game.add_info_log_item("Attacker wins");
|
||||
move_units(game, c.attacker, &c.attackers, c.defender_position, None);
|
||||
capture_position(game, c.defender, c.defender_position, c.attacker);
|
||||
end_combat(game, &CombatEnd::new(CombatResult::AttackerWins, c));
|
||||
end_combat(game, CombatEnd::new(CombatResult::AttackerWins, c));
|
||||
}
|
||||
|
||||
fn defender_wins(game: &mut Game, c: Combat) {
|
||||
game.add_info_log_item("Defender wins");
|
||||
end_combat(game, &CombatEnd::new(CombatResult::DefenderWins, c));
|
||||
end_combat(game, CombatEnd::new(CombatResult::DefenderWins, c));
|
||||
}
|
||||
|
||||
pub(crate) fn draw(game: &mut Game, c: Combat) {
|
||||
|
|
@ -308,16 +321,16 @@ pub(crate) fn draw(game: &mut Game, c: Combat) {
|
|||
"{} wins the battle because he has a defending fortress",
|
||||
game.player_name(c.defender)
|
||||
));
|
||||
return end_combat(game, &CombatEnd::new(CombatResult::DefenderWins, c));
|
||||
return end_combat(game, CombatEnd::new(CombatResult::DefenderWins, c));
|
||||
}
|
||||
game.add_info_log_item("Battle ends in a draw");
|
||||
end_combat(game, &CombatEnd::new(CombatResult::Draw, c));
|
||||
end_combat(game, CombatEnd::new(CombatResult::Draw, c));
|
||||
}
|
||||
|
||||
pub(crate) fn end_combat(game: &mut Game, info: &CombatEnd) {
|
||||
pub(crate) fn end_combat(game: &mut Game, info: CombatEnd) {
|
||||
let c = &info.combat;
|
||||
|
||||
game.trigger_current_event(
|
||||
let _ = game.trigger_current_event(
|
||||
&c.players(),
|
||||
|events| &mut events.on_combat_end,
|
||||
info,
|
||||
|
|
@ -328,84 +341,104 @@ pub(crate) fn end_combat(game: &mut Game, info: &CombatEnd) {
|
|||
|
||||
pub(crate) fn event_with_tactics<T: Clone + PartialEq>(
|
||||
game: &mut Game,
|
||||
event_type: &T,
|
||||
mut event_type: T,
|
||||
store_type: impl Fn(T) -> CurrentEventType + Clone + 'static,
|
||||
round_types: &[CombatRoundType; 3],
|
||||
event: fn(&mut PlayerEvents) -> &mut CurrentEvent<T>,
|
||||
tactics_event: fn(&mut PlayerEvents) -> &mut CurrentEvent<T>,
|
||||
get_round_type: impl Fn(&mut T) -> &mut CombatRoundType,
|
||||
round_types: &[CombatEventPhase; 3],
|
||||
event: fn(&mut PersistentEvents) -> &mut CurrentEvent<T>,
|
||||
tactics_event: fn(&mut PersistentEvents) -> &mut CurrentEvent<T>,
|
||||
get_round_type: impl Fn(&mut T) -> &mut CombatEventPhase,
|
||||
get_combat: impl Fn(&T) -> &Combat + Clone + 'static,
|
||||
attacker_tactics_card: impl Fn(&T) -> Option<&String>,
|
||||
defender_tactics_card: impl Fn(&T) -> Option<&String>,
|
||||
reveal_card: bool,
|
||||
) -> Option<T> {
|
||||
let mut s = event_type.clone();
|
||||
let from = round_types
|
||||
.iter()
|
||||
.position(|t| t == get_round_type(&mut s))
|
||||
.position(|t| t == get_round_type(&mut event_type))
|
||||
.expect("invalid round type");
|
||||
for t in round_types.iter().skip(from) {
|
||||
*get_round_type(&mut s) = t.clone();
|
||||
*get_round_type(&mut event_type) = t.clone();
|
||||
|
||||
let store_type = store_type.clone();
|
||||
let get_combat = get_combat.clone();
|
||||
|
||||
let option = match t {
|
||||
CombatRoundType::Default => {
|
||||
game.trigger_current_event(&get_combat(&s).players(), event, &s, store_type, None)
|
||||
}
|
||||
CombatRoundType::TacticsCardAttacker => trigger_tactics_event(
|
||||
event_type = (match t {
|
||||
CombatEventPhase::Default => game.trigger_current_event(
|
||||
&get_combat(&event_type).players(),
|
||||
event,
|
||||
event_type,
|
||||
store_type,
|
||||
None,
|
||||
),
|
||||
CombatEventPhase::TacticsCardAttacker => trigger_tactics_event(
|
||||
game,
|
||||
&s,
|
||||
event_type,
|
||||
tactics_event,
|
||||
get_combat,
|
||||
|s| attacker_tactics_card(s),
|
||||
store_type,
|
||||
CombatRole::Attacker,
|
||||
reveal_card,
|
||||
),
|
||||
CombatRoundType::TacticsCardDefender => trigger_tactics_event(
|
||||
CombatEventPhase::TacticsCardDefender => trigger_tactics_event(
|
||||
game,
|
||||
&s,
|
||||
event_type,
|
||||
tactics_event,
|
||||
get_combat,
|
||||
|s| defender_tactics_card(s),
|
||||
store_type,
|
||||
CombatRole::Defender,
|
||||
reveal_card,
|
||||
),
|
||||
CombatRoundType::Done => panic!("Invalid round type"),
|
||||
};
|
||||
s = option?;
|
||||
CombatEventPhase::Done => panic!("Invalid round type"),
|
||||
})?;
|
||||
}
|
||||
*get_round_type(&mut s) = CombatRoundType::Done;
|
||||
Some(s)
|
||||
*get_round_type(&mut event_type) = CombatEventPhase::Done;
|
||||
Some(event_type)
|
||||
}
|
||||
|
||||
pub(crate) fn trigger_tactics_event<T>(
|
||||
game: &mut Game,
|
||||
event_type: &T,
|
||||
event: fn(&mut PlayerEvents) -> &mut CurrentEvent<T>,
|
||||
event_type: T,
|
||||
event: fn(&mut PersistentEvents) -> &mut CurrentEvent<T>,
|
||||
get_combat: impl Fn(&T) -> &Combat,
|
||||
get_tactics_card: impl Fn(&T) -> Option<&String>,
|
||||
store_type: impl Fn(T) -> CurrentEventType,
|
||||
role: CombatRole,
|
||||
reveal_card: bool,
|
||||
) -> Option<T>
|
||||
where
|
||||
T: Clone + PartialEq,
|
||||
{
|
||||
game.trigger_current_event_with_listener(
|
||||
&get_combat(event_type).players(),
|
||||
event,
|
||||
get_tactics_card(event_type)
|
||||
.as_ref()
|
||||
.map(|c| tactics_cards::get_tactics_card(c).listeners)
|
||||
.as_ref(),
|
||||
event_type,
|
||||
store_type,
|
||||
None,
|
||||
)
|
||||
if let Some(card) = get_tactics_card(&event_type) {
|
||||
let combat = get_combat(&event_type);
|
||||
|
||||
if reveal_card {
|
||||
game.add_info_log_item(&format!(
|
||||
"{} reveals Tactics Card {}",
|
||||
game.player_name(combat.player(role)),
|
||||
tactics_cards::get_tactics_card(card).name
|
||||
));
|
||||
}
|
||||
|
||||
game.trigger_current_event_with_listener(
|
||||
&combat.players(),
|
||||
event,
|
||||
&tactics_cards::get_tactics_card(card).listeners,
|
||||
event_type,
|
||||
store_type,
|
||||
None,
|
||||
)
|
||||
} else {
|
||||
Some(event_type)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn choose_fighter_casualties() -> Builtin {
|
||||
choose_casualties(
|
||||
Builtin::builder("Choose Casualties", "Choose which carried units to remove."),
|
||||
1,
|
||||
|c| c.fighters,
|
||||
|c, _, _, _| c.fighters,
|
||||
|game, player, c| c.fighting_units(game, player),
|
||||
kill_units,
|
||||
)
|
||||
|
|
@ -418,7 +451,7 @@ pub(crate) fn choose_carried_units_casualties() -> Builtin {
|
|||
"Choose which carried units to remove.",
|
||||
),
|
||||
2,
|
||||
|c| c.carried_units,
|
||||
|c, p, game, combat| combat.carried_units_casualties(game, p, c.fighters),
|
||||
|game, player, c| {
|
||||
let pos = c.position(player);
|
||||
let carried: Vec<u32> = game
|
||||
|
|
@ -470,7 +503,7 @@ pub(crate) fn offer_retreat() -> Builtin {
|
|||
pub(crate) fn choose_casualties(
|
||||
builder: BuiltinBuilder,
|
||||
priority: i32,
|
||||
get_casualties: impl Fn(&Casualties) -> u8 + 'static + Clone,
|
||||
get_casualties: impl Fn(&Casualties, usize, &Game, &Combat) -> u8 + 'static + Clone,
|
||||
get_choices: impl Fn(&Game, usize, &Combat) -> Vec<u32> + 'static + Clone,
|
||||
kill_units: impl Fn(&mut Game, usize, &[u32], &mut Combat) + 'static + Copy,
|
||||
) -> Builtin {
|
||||
|
|
@ -487,7 +520,7 @@ pub(crate) fn choose_casualties(
|
|||
} else {
|
||||
"defending"
|
||||
};
|
||||
let casualties = get_casualties(r.casualties(role));
|
||||
let casualties = get_casualties(r.casualties(role), player, game, &r.combat);
|
||||
if casualties == 0 {
|
||||
return None;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
mod inspiration;
|
||||
|
||||
use crate::action_card::ActionCard;
|
||||
use crate::content::tactics_cards::peltasts;
|
||||
use crate::content::action_cards::inspiration::inspiration_action_cards;
|
||||
use itertools::Itertools;
|
||||
|
||||
#[must_use]
|
||||
pub(crate) fn get_all() -> Vec<ActionCard> {
|
||||
let all = vec![test_action_cards()]
|
||||
let all = vec![inspiration_action_cards()]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect_vec();
|
||||
|
|
@ -26,14 +28,3 @@ pub fn get_action_card(id: u8) -> ActionCard {
|
|||
.find(|c| c.id == id)
|
||||
.expect("action card not found")
|
||||
}
|
||||
|
||||
fn test_action_cards() -> Vec<ActionCard> {
|
||||
vec![advance(1), advance(2)]
|
||||
}
|
||||
|
||||
// todo move to dedicated module
|
||||
fn advance(id: u8) -> ActionCard {
|
||||
ActionCard::civil_card_builder(id, "Advance", "todo", peltasts())
|
||||
// .add_units_request()
|
||||
.build()
|
||||
}
|
||||
|
|
|
|||
58
server/src/content/action_cards/inspiration.rs
Normal file
58
server/src/content/action_cards/inspiration.rs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
use crate::ability_initializer::AbilityInitializerSetup;
|
||||
use crate::action_card::ActionCard;
|
||||
use crate::advance::gain_advance;
|
||||
use crate::content::advances;
|
||||
use crate::content::custom_phase_actions::AdvanceRequest;
|
||||
use crate::content::tactics_cards::{encircled, peltasts};
|
||||
use crate::player::Player;
|
||||
use crate::resource_pile::ResourcePile;
|
||||
use crate::tactics_card::TacticsCard;
|
||||
|
||||
pub(crate) fn inspiration_action_cards() -> Vec<ActionCard> {
|
||||
vec![advance(1, peltasts()), advance(2, encircled())]
|
||||
}
|
||||
|
||||
fn advance(id: u8, tactics_card: TacticsCard) -> ActionCard {
|
||||
ActionCard::civil_card_builder(
|
||||
id,
|
||||
"Advance",
|
||||
"Pay 1 idea: Gain 1 advance without changing the Game Event counter.",
|
||||
|_game, player| player.resources.ideas >= 1 && !possible_advances(player).is_empty(),
|
||||
tactics_card,
|
||||
)
|
||||
.add_advance_request(
|
||||
|e| &mut e.on_play_action_card,
|
||||
0,
|
||||
|game, player, _| {
|
||||
let p = game.get_player(player);
|
||||
|
||||
let advances = possible_advances(p);
|
||||
if advances.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(AdvanceRequest::new(advances))
|
||||
},
|
||||
|game, sel, _| {
|
||||
let advance = sel.choice.clone();
|
||||
gain_advance(
|
||||
game,
|
||||
&advance,
|
||||
sel.player_index,
|
||||
ResourcePile::ideas(1),
|
||||
false,
|
||||
);
|
||||
let name = &sel.player_name;
|
||||
game.add_info_log_item(&format!("{name} gained {advance} for 1 idea.",));
|
||||
},
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
||||
fn possible_advances(player: &Player) -> Vec<String> {
|
||||
advances::get_all()
|
||||
.iter()
|
||||
.filter(|a| player.can_advance_free(a))
|
||||
.map(|a| a.name.clone())
|
||||
.collect()
|
||||
}
|
||||
|
|
@ -38,10 +38,10 @@ fn irrigation() -> AdvanceBuilder {
|
|||
IRRIGATION,
|
||||
"Your cities may Collect food from Barren spaces, Ignore Famine events",
|
||||
)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.terrain_collect_options,
|
||||
0,
|
||||
|m, (), (), ()| {
|
||||
|m, (), ()| {
|
||||
m.insert(Barren, HashSet::from([ResourcePile::food(1)]));
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@ fn totalitarianism() -> AdvanceBuilder {
|
|||
"Totalitarianism",
|
||||
"Attempts to influence your cities with Army Units may not be boosted by culture tokens",
|
||||
)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.on_influence_culture_attempt,
|
||||
0,
|
||||
|info, city, game, ()| {
|
||||
|info, city, game| {
|
||||
if info.is_defender
|
||||
&& game
|
||||
.get_player(city.player_index)
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ fn sanitation() -> AdvanceBuilder {
|
|||
"When Recruiting, you may spend 1 mood token to pay for 1 Settler. Ignore Pestilence and Epidemics events.",
|
||||
)
|
||||
.with_advance_bonus(MoodToken)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.recruit_cost,
|
||||
1,
|
||||
|cost, units, _, ()| {
|
||||
|cost, units, _| {
|
||||
if units.settlers > 0 {
|
||||
// insert at beginning so that it's preferred over gold
|
||||
cost.info
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ fn monuments() -> AdvanceBuilder {
|
|||
Advance::builder("Monuments", "Immediately draw 1 wonder card. Your cities with wonders may not be the target of influence culture attempts")
|
||||
.add_one_time_ability_initializer(draw_wonder_card)
|
||||
.with_advance_bonus(CultureToken)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.on_influence_culture_attempt,
|
||||
1,
|
||||
|info, city, _, ()| {
|
||||
|info, city, _| {
|
||||
if info.is_defender && !city.pieces.wonders.is_empty() {
|
||||
info.set_impossible();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ fn separation_of_power() -> AdvanceBuilder {
|
|||
"Separation of Power",
|
||||
"Attempts to influence your happy cities may not be boosted by culture tokens",
|
||||
)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.on_influence_culture_attempt,
|
||||
2,
|
||||
|info, city, _, ()| {
|
||||
|info, city, _| {
|
||||
if matches!(city.mood_state, MoodState::Happy) {
|
||||
info.set_no_boost();
|
||||
}
|
||||
|
|
@ -54,10 +54,10 @@ fn civil_liberties() -> AdvanceBuilder {
|
|||
fn free_economy() -> AdvanceBuilder {
|
||||
Advance::builder("Free Economy", "As a free action, you may spend 1 mood token to collect resources in one city. This must be your only collect action this turn")
|
||||
.add_custom_action(FreeEconomyCollect)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.is_playing_action_available,
|
||||
0,
|
||||
|available, game, i, ()| {
|
||||
|available, game, i| {
|
||||
let p = game.get_player(i.player);
|
||||
if matches!(i.action_type, PlayingActionType::Collect) && p.played_once_per_turn_actions.contains(&FreeEconomyCollect) {
|
||||
*available = false;
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ fn math() -> AdvanceBuilder {
|
|||
"Math",
|
||||
"Engineering and Roads can be bought at no food cost",
|
||||
)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.advance_cost,
|
||||
1,
|
||||
|i, a, (), ()| {
|
||||
|i, a, ()| {
|
||||
if a.name == "Engineering" || a.name == "Roads" {
|
||||
i.info.log.push("Math reduced the cost to 0".to_string());
|
||||
i.set_zero();
|
||||
|
|
@ -38,10 +38,10 @@ fn astronomy() -> AdvanceBuilder {
|
|||
"Astronomy",
|
||||
"Navigation and Cartography can be bought at no food cost",
|
||||
)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.advance_cost,
|
||||
0,
|
||||
|i, a, (), ()| {
|
||||
|i, a, ()| {
|
||||
if a.name == "Navigation" || a.name == "Cartography" {
|
||||
i.set_zero();
|
||||
i.info
|
||||
|
|
@ -96,10 +96,10 @@ fn metallurgy() -> AdvanceBuilder {
|
|||
METALLURGY,
|
||||
"If you have the Steel Weapons Advance, you no longer have to pay 1 ore to activate it against enemies without Steel Weapons. If you collect at least 2 ore, replace 1 ore with 1 gold",)
|
||||
.with_advance_bonus(CultureToken)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.collect_total,
|
||||
0,
|
||||
|i, (),(), ()| {
|
||||
|i, (), ()| {
|
||||
if i.total.ore >= 2 {
|
||||
i.total.ore -= 1;
|
||||
i.total.gold += 1;
|
||||
|
|
|
|||
|
|
@ -18,11 +18,7 @@ pub(crate) fn seafaring() -> AdvanceGroup {
|
|||
|
||||
fn fishing() -> AdvanceBuilder {
|
||||
Advance::builder("Fishing", "Your cities may Collect food from one Sea space")
|
||||
.add_player_event_listener(
|
||||
|event| &mut event.collect_options,
|
||||
1,
|
||||
|i, c, game, ()| fishing_collect(i, c, game),
|
||||
)
|
||||
.add_transient_event_listener(|event| &mut event.collect_options, 1, fishing_collect)
|
||||
.with_advance_bonus(MoodToken)
|
||||
.with_unlocked_building(Port)
|
||||
}
|
||||
|
|
@ -58,10 +54,10 @@ fn cartography() -> AdvanceBuilder {
|
|||
"Cartography",
|
||||
"Gain 1 idea after a move action where you moved a Ship. If you used navigation, gain an additional 1 culture token.", )
|
||||
.with_advance_bonus(CultureToken)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.before_move,
|
||||
0,
|
||||
|game, i, (), ()| {
|
||||
|game, i, ()| {
|
||||
// info is the action that we last used this ability for
|
||||
let key = game.actions_left.to_string();
|
||||
if game.get_player(i.player).event_info.get("Cartography").is_some_and(|info| info == &key) {
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ fn myths() -> AdvanceBuilder {
|
|||
fn rituals() -> AdvanceBuilder {
|
||||
Advance::builder("Rituals", "When you perform the Increase Happiness Action you may spend any Resources as a substitute for mood tokens. This is done at a 1:1 ratio")
|
||||
.with_advance_bonus(CultureToken)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.happiness_cost,
|
||||
0,
|
||||
|cost, (), (), ()| {
|
||||
|cost, (), ()| {
|
||||
for r in &[
|
||||
ResourceType::Food,
|
||||
ResourceType::Wood,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::ability_initializer::AbilityInitializerSetup;
|
||||
use crate::advance::{advance_with_incident_token, Advance, AdvanceBuilder};
|
||||
use crate::advance::{gain_advance, Advance, AdvanceBuilder};
|
||||
use crate::city_pieces::Building::Temple;
|
||||
use crate::consts::STACK_LIMIT;
|
||||
use crate::content::advances::{advance_group_builder, get_group, AdvanceGroup};
|
||||
|
|
@ -32,7 +32,7 @@ fn dogma() -> AdvanceBuilder {
|
|||
.add_ability_undo_deinitializer(|game, player_index| {
|
||||
game.players[player_index].resource_limit.ideas = 7;
|
||||
})
|
||||
.add_advance_reward_request_listener(
|
||||
.add_advance_request(
|
||||
|event| &mut event.on_construct,
|
||||
0,
|
||||
|game, player_index, building| {
|
||||
|
|
@ -59,7 +59,7 @@ fn dogma() -> AdvanceBuilder {
|
|||
game.add_info_log_item(&format!(
|
||||
"{} {verb} {} as a reward for constructing a Temple", c.player_name, c.choice
|
||||
));
|
||||
advance_with_incident_token(game, &c.choice, c.player_index, ResourcePile::empty());
|
||||
gain_advance(game, &c.choice, c.player_index, ResourcePile::empty(), true);
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
@ -69,10 +69,10 @@ fn devotion() -> AdvanceBuilder {
|
|||
"Devotion",
|
||||
"Attempts to influence your cities with a Temple may not be boosted by culture tokens",
|
||||
)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.on_influence_culture_attempt,
|
||||
4,
|
||||
|info, city, _, ()| {
|
||||
|info, city, _| {
|
||||
if info.is_defender && city.pieces.temple.is_some() {
|
||||
info.set_no_boost();
|
||||
}
|
||||
|
|
@ -82,20 +82,20 @@ fn devotion() -> AdvanceBuilder {
|
|||
|
||||
fn conversion() -> AdvanceBuilder {
|
||||
Advance::builder("Conversion", "You add +1 to your Influence Culture roll and gain 1 culture token when you make a successful Influence Culture attempt.")
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.on_influence_culture_attempt,
|
||||
3,
|
||||
|info, _, _, ()| {
|
||||
|info, _, _| {
|
||||
if !info.is_defender {
|
||||
info.roll_boost += 1;
|
||||
info.info.log.push("Player gets +1 to Influence Culture roll for Conversion Advance".to_string());
|
||||
}
|
||||
},
|
||||
)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.on_influence_culture_success,
|
||||
0,
|
||||
|game, player, (), ()| {
|
||||
|game, player, ()| {
|
||||
game.get_player_mut(*player).gain_resources(ResourcePile::culture_tokens(1));
|
||||
game.add_info_log_item("Player gained 1 culture token for a successful Influence Culture attempt for Conversion Advance");
|
||||
},
|
||||
|
|
|
|||
|
|
@ -146,10 +146,10 @@ fn draft() -> AdvanceBuilder {
|
|||
"When Recruiting, you may spend 1 mood token to pay for 1 Infantry Army Unit.",
|
||||
)
|
||||
.with_advance_bonus(CultureToken)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.recruit_cost,
|
||||
0,
|
||||
|cost, units, player, ()| {
|
||||
|cost, units, player| {
|
||||
if units.infantry > 0 {
|
||||
// insert at beginning so that it's preferred over gold
|
||||
|
||||
|
|
|
|||
|
|
@ -115,8 +115,8 @@ pub(crate) fn status_phase_handler(phase: &StatusPhaseState) -> Builtin {
|
|||
match phase {
|
||||
CompleteObjectives => complete_objectives(),
|
||||
FreeAdvance => free_advance(),
|
||||
RazeSize1City => raze_city(),
|
||||
DrawCards => draw_cards(),
|
||||
RazeSize1City => raze_city(),
|
||||
ChangeGovernmentType => may_change_government(),
|
||||
DetermineFirstPlayer(_) => determine_first_player(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ pub fn get_all() -> Vec<Civilization> {
|
|||
vec![
|
||||
// todo add other effects
|
||||
SpecialAdvance::builder("Terrace", IRRIGATION)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|events| &mut events.terrain_collect_options,
|
||||
2,
|
||||
|m, (), (), ()| {
|
||||
|m, (), ()| {
|
||||
m.insert(
|
||||
Terrain::Mountain,
|
||||
std::collections::HashSet::from([
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ pub enum CurrentEventType {
|
|||
Construct(Building),
|
||||
Recruit(Recruit),
|
||||
Incident(IncidentInfo),
|
||||
ActionCard(u8),
|
||||
DrawWonderCard,
|
||||
}
|
||||
|
||||
|
|
@ -341,6 +342,6 @@ impl CurrentEventResponse {
|
|||
};
|
||||
s.response = Some(self.clone());
|
||||
let details = game.current_event().event_type.clone();
|
||||
execute_custom_phase_action(game, player_index, &details);
|
||||
execute_custom_phase_action(game, player_index, details);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ fn envoy() -> Incident {
|
|||
"Select a player to gain 1 culture token",
|
||||
|_p, _| true,
|
||||
0,
|
||||
|game, s| {
|
||||
|game, s, _| {
|
||||
let p = s.choice;
|
||||
game.add_info_log_item(&format!(
|
||||
"{} was selected to gain 1 culture token.",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use crate::ability_initializer::{AbilityInitializerSetup, SelectedChoice};
|
|||
use crate::city::{City, MoodState};
|
||||
use crate::content::builtin::Builtin;
|
||||
use crate::content::custom_phase_actions::UnitsRequest;
|
||||
use crate::content::incidents::civil_war::non_angry_cites;
|
||||
use crate::game::Game;
|
||||
use crate::incident::{Incident, IncidentBaseEffect, MoodModifier, PermanentIncidentEffect};
|
||||
use crate::player::Player;
|
||||
|
|
@ -44,14 +45,7 @@ fn pestilence() -> Incident {
|
|||
1
|
||||
} - game.current_event_player().payment.amount() as u8;
|
||||
|
||||
(
|
||||
p.cities
|
||||
.iter()
|
||||
.filter(|c| !matches!(c.mood_state, MoodState::Angry))
|
||||
.map(|c| c.position)
|
||||
.collect_vec(),
|
||||
needed,
|
||||
)
|
||||
(non_angry_cites(p), needed)
|
||||
},
|
||||
)
|
||||
.add_simple_incident_listener(IncidentTarget::ActivePlayer, 0, |game, _, _, _| {
|
||||
|
|
@ -74,10 +68,10 @@ pub(crate) fn pestilence_permanent_effect() -> Builtin {
|
|||
"Pestilence",
|
||||
"You cannot construct buildings or wonders until you research Sanitation.",
|
||||
)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|event| &mut event.is_playing_action_available,
|
||||
1,
|
||||
|available, game, i, ()| {
|
||||
|available, game, i| {
|
||||
let player = game.get_player(i.player);
|
||||
if game
|
||||
.permanent_incident_effects
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ fn good_year(mut builder: IncidentBuilder, amount: u32, good_year_type: &GoodYea
|
|||
"Select a player to gain 1 food",
|
||||
|p, _| p.resources.food < p.resource_limit.food,
|
||||
i as i32,
|
||||
move |game, c| {
|
||||
move |game, c, _| {
|
||||
game.add_info_log_item(&format!(
|
||||
"{} gained 1 food from {}",
|
||||
game.player_name(c.choice),
|
||||
|
|
@ -192,7 +192,7 @@ pub(crate) fn select_player_to_gain_settler(mut b: IncidentBuilder) -> IncidentB
|
|||
"Select another player to gain 1 settler on one of their cities",
|
||||
|p, _| p.available_units().settlers > 0 && !p.cities.is_empty(),
|
||||
12,
|
||||
|game, c| {
|
||||
|game, c, _| {
|
||||
game.add_info_log_item(&format!(
|
||||
"{} was selected to gain 1 settler.",
|
||||
game.player_name(c.choice)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::card::{hand_cards, HandCard, HandCardType};
|
||||
use crate::city::City;
|
||||
use crate::content::custom_phase_actions::{
|
||||
PaymentRequest, PositionRequest, ResourceRewardRequest, UnitsRequest,
|
||||
HandCardsRequest, PaymentRequest, PositionRequest, ResourceRewardRequest, UnitsRequest,
|
||||
};
|
||||
use crate::content::incidents::famine::{
|
||||
additional_sanitation_damage, famine, kill_incident_units,
|
||||
|
|
@ -14,6 +15,7 @@ use crate::player_events::IncidentTarget;
|
|||
use crate::position::Position;
|
||||
use crate::resource::ResourceType;
|
||||
use itertools::Itertools;
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
pub(crate) fn pandemics_incidents() -> Vec<Incident> {
|
||||
vec![
|
||||
|
|
@ -31,24 +33,26 @@ fn pandemics() -> Incident {
|
|||
Incident::builder(
|
||||
49,
|
||||
"Pandemics",
|
||||
"Every player loses an amount resources, tokens, cards, \
|
||||
"Every player loses an amount resources, tokens, action or objective cards, \
|
||||
or units equal to the half of the number of their cities (rounded down).",
|
||||
IncidentBaseEffect::BarbariansMove,
|
||||
)
|
||||
.set_protection_advance("Sanitation")
|
||||
.add_incident_units_request(
|
||||
IncidentTarget::AllPlayers,
|
||||
1,
|
||||
2,
|
||||
|game, p, _i| {
|
||||
game.add_info_log_item(&format!(
|
||||
"{} has to lose a total of {} units, cards, and resources",
|
||||
game.player_name(p),
|
||||
pandemics_cost(game.get_player(p))
|
||||
));
|
||||
|
||||
let player = game.get_player(p);
|
||||
let needed = pandemics_cost(player);
|
||||
let choices = player.units.iter().map(|u| u.id).collect_vec();
|
||||
let min = needed.saturating_sub(player.resources.amount() as u8);
|
||||
let max = needed.min(choices.len() as u8);
|
||||
Some(UnitsRequest::new(
|
||||
p,
|
||||
choices,
|
||||
min..=max,
|
||||
player.units.iter().map(|u| u.id).collect_vec(),
|
||||
PandemicsContributions::range(player, game, 0),
|
||||
"Select units to lose",
|
||||
))
|
||||
},
|
||||
|
|
@ -57,14 +61,49 @@ fn pandemics() -> Incident {
|
|||
game.current_event_mut().player.sacrifice = s.choice.len() as u8;
|
||||
},
|
||||
)
|
||||
.add_incident_hand_card_request(
|
||||
IncidentTarget::AllPlayers,
|
||||
1,
|
||||
|game, p, _i| {
|
||||
let player = game.get_player(p);
|
||||
Some(HandCardsRequest::new(
|
||||
// todo also objective cards
|
||||
hand_cards(player, &[HandCardType::Action]),
|
||||
PandemicsContributions::range(player, game, 1),
|
||||
"Select cards to lose",
|
||||
))
|
||||
},
|
||||
|game, s| {
|
||||
for id in &s.choice {
|
||||
match id {
|
||||
HandCard::ActionCard(a) => {
|
||||
game.get_player_mut(s.player_index)
|
||||
.action_cards
|
||||
.retain(|c| c != a);
|
||||
game.add_info_log_item(&format!(
|
||||
"{} discarded an action card",
|
||||
s.player_name
|
||||
));
|
||||
}
|
||||
HandCard::Wonder(_) => panic!("Unexpected card type"),
|
||||
}
|
||||
}
|
||||
game.current_event_mut().player.sacrifice += s.choice.len() as u8;
|
||||
},
|
||||
)
|
||||
.add_incident_payment_request(
|
||||
IncidentTarget::AllPlayers,
|
||||
0,
|
||||
|game, p, _i| {
|
||||
let player = game.get_player(p);
|
||||
let resources = player.resources.amount() as u8;
|
||||
let needed =
|
||||
(pandemics_cost(player) - game.current_event_mut().player.sacrifice).min(resources);
|
||||
let needed = PandemicsContributions::range(player, game, 2)
|
||||
.min()
|
||||
.expect("min not found");
|
||||
|
||||
if needed == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(vec![PaymentRequest::new(
|
||||
PaymentOptions::sum(needed as u32, &ResourceType::all()),
|
||||
"Select resources to lose",
|
||||
|
|
@ -78,6 +117,40 @@ fn pandemics() -> Incident {
|
|||
.build()
|
||||
}
|
||||
|
||||
struct PandemicsContributions {
|
||||
pub max: Vec<u8>,
|
||||
}
|
||||
|
||||
impl PandemicsContributions {
|
||||
pub fn new(player: &Player) -> Self {
|
||||
Self {
|
||||
max: vec![
|
||||
player.units.len() as u8,
|
||||
player.action_cards.len() as u8,
|
||||
player.resources.amount() as u8,
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn range(player: &Player, game: &Game, level: usize) -> RangeInclusive<u8> {
|
||||
PandemicsContributions::new(player).range_impl(
|
||||
level,
|
||||
pandemics_cost(player) - game.current_event_player().sacrifice,
|
||||
)
|
||||
}
|
||||
|
||||
fn range_impl(&self, level: usize, needed: u8) -> RangeInclusive<u8> {
|
||||
let current_max = self.max[level];
|
||||
let remaining: u8 = self.max.iter().skip(level + 1).sum();
|
||||
|
||||
let i = needed.saturating_sub(remaining);
|
||||
let min = i.min(current_max);
|
||||
let max = needed.min(current_max);
|
||||
|
||||
min..=max
|
||||
}
|
||||
}
|
||||
|
||||
fn pandemics_cost(player: &Player) -> u8 {
|
||||
(player.cities.len() / 2) as u8
|
||||
}
|
||||
|
|
@ -282,3 +355,19 @@ pub(crate) fn successful_year() -> Incident {
|
|||
)
|
||||
.build()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use crate::content::incidents::pandemics;
|
||||
|
||||
#[test]
|
||||
pub fn get_test_range_impl() {
|
||||
let c = pandemics::PandemicsContributions { max: vec![7, 2, 3] };
|
||||
assert_eq!(c.range_impl(0, 4), 0..=4);
|
||||
assert_eq!(c.range_impl(1, 4), 1..=2);
|
||||
assert_eq!(c.range_impl(2, 4), 3..=3);
|
||||
|
||||
assert_eq!(c.range_impl(2, 3), 3..=3);
|
||||
assert_eq!(c.range_impl(2, 2), 2..=2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::city::City;
|
|||
use crate::city_pieces::Building;
|
||||
use crate::content::custom_phase_actions::{new_position_request, ResourceRewardRequest};
|
||||
use crate::game::Game;
|
||||
use crate::incident::{Incident, IncidentBaseEffect, PassedIncident, PermanentIncidentEffect};
|
||||
use crate::incident::{Incident, IncidentBaseEffect, PassedIncident};
|
||||
use crate::payment::PaymentOptions;
|
||||
use crate::player::Player;
|
||||
use crate::player_events::IncidentTarget;
|
||||
|
|
@ -129,12 +129,6 @@ fn reformation() -> Incident {
|
|||
IncidentTarget::ActivePlayer,
|
||||
4,
|
||||
|game, p, player_name, _i| {
|
||||
// if game.permanent_incident_effects.iter().any(
|
||||
// |e| matches!(e, PermanentIncidentEffect::PassedIncident(PassedIncident::AlreadyPassed))) {
|
||||
// // can't pass the event again
|
||||
// return;
|
||||
// }
|
||||
|
||||
if has_temple(game, p) {
|
||||
game.current_event_mut().selected_player = Some(p);
|
||||
} else if game
|
||||
|
|
@ -155,12 +149,9 @@ fn reformation() -> Incident {
|
|||
"Select a player to execute the event",
|
||||
|p, game| has_temple(game, p.index) && game.current_event().selected_player.is_none(),
|
||||
3,
|
||||
|game, s| {
|
||||
|game, s, i| {
|
||||
// pass the event to the player itself
|
||||
game.permanent_incident_effects
|
||||
.push(PermanentIncidentEffect::PassedIncident(
|
||||
PassedIncident::NewPlayer(s.choice),
|
||||
));
|
||||
i.passed = Some(PassedIncident::NewPlayer(s.choice));
|
||||
game.add_info_log_item(&format!(
|
||||
"{} selected {} to execute the event",
|
||||
s.player_name,
|
||||
|
|
@ -173,7 +164,7 @@ fn reformation() -> Incident {
|
|||
"Select a player to gain a Temple",
|
||||
|p, game| can_gain_temple(game, p),
|
||||
2,
|
||||
|game, s| {
|
||||
|game, s, _| {
|
||||
game.current_event_mut().selected_player = Some(s.choice);
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use itertools::Itertools;
|
|||
|
||||
#[must_use]
|
||||
pub(crate) fn get_all() -> Vec<TacticsCard> {
|
||||
let all: Vec<TacticsCard> = vec![vec![peltasts()]].into_iter().flatten().collect_vec();
|
||||
let all: Vec<TacticsCard> = vec![peltasts(), encircled()];
|
||||
assert_eq!(
|
||||
all.iter().unique_by(|i| &i.name).count(),
|
||||
all.len(),
|
||||
|
|
@ -45,3 +45,41 @@ pub(crate) fn peltasts() -> TacticsCard {
|
|||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
pub(crate) fn encircled() -> TacticsCard {
|
||||
TacticsCard::builder(
|
||||
"Encircled",
|
||||
"Before removing casualties: If your opponent loses the same number of units \
|
||||
as you or more: Roll a die. On a 5 or 6, add 1 hit, which cannot be ignored",
|
||||
TacticsCardTarget::ActivePlayer,
|
||||
FighterRequirement::Army,
|
||||
)
|
||||
.add_resolve_listener(0, |player, game, e| {
|
||||
let combat = &e.combat;
|
||||
let opponent = combat.opponent(player);
|
||||
let role = combat.role(player);
|
||||
let opponent_role = combat.role(opponent);
|
||||
|
||||
let player_losses = e.casualties(role).fighters;
|
||||
let opponent_losses = e.casualties(opponent_role).fighters;
|
||||
if opponent_losses >= player_losses {
|
||||
if opponent_losses == combat.fighting_units(game, opponent).len() as u8 {
|
||||
game.add_info_log_item("Encircled cannot do damage - all units already die");
|
||||
return;
|
||||
}
|
||||
|
||||
let roll = game.get_next_dice_roll().value;
|
||||
if roll >= 5 {
|
||||
game.add_info_log_item(
|
||||
"Encircled rolled a 5 or 6 and added a hit that cannot be ignored",
|
||||
);
|
||||
e.casualties_mut(opponent_role).fighters += 1;
|
||||
} else {
|
||||
game.add_info_log_item("Encircled rolled no 5 or 6");
|
||||
}
|
||||
} else {
|
||||
game.add_info_log_item("Encircled cannot do damage - opponent has fewer losses");
|
||||
}
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ pub fn get_all() -> Vec<Wonder> {
|
|||
PaymentOptions::resources(ResourcePile::new(5, 5, 2, 0, 0, 0, 5)),
|
||||
vec![IRRIGATION],
|
||||
)
|
||||
.add_player_event_listener(
|
||||
.add_transient_event_listener(
|
||||
|events| &mut events.terrain_collect_options,
|
||||
1,
|
||||
|m,(),(), ()| {
|
||||
|m,(),()| {
|
||||
m.insert(Fertile, HashSet::from([
|
||||
ResourcePile::food(1),
|
||||
ResourcePile::wood(1),
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ pub(crate) fn influence_culture_attempt(
|
|||
game.add_to_last_log_item(&format!(" and rolled a {roll}"));
|
||||
info.info.execute(game);
|
||||
game.add_info_log_item(&format!("{} now has the option to pay {roll_boost_cost} to increase the dice roll and proceed with the cultural influence", game.player_name(player_index)));
|
||||
ask_for_cultural_influence_payment(game, player_index, &roll_boost_cost);
|
||||
ask_for_cultural_influence_payment(game, player_index, roll_boost_cost);
|
||||
} else {
|
||||
game.add_to_last_log_item(&format!(
|
||||
" but rolled a {roll} and has not enough culture tokens to increase the roll "
|
||||
|
|
@ -73,9 +73,9 @@ pub(crate) fn influence_culture_attempt(
|
|||
pub(crate) fn ask_for_cultural_influence_payment(
|
||||
game: &mut Game,
|
||||
player_index: usize,
|
||||
roll_boost_cost: &ResourcePile,
|
||||
roll_boost_cost: ResourcePile,
|
||||
) {
|
||||
game.trigger_current_event(
|
||||
let _ = game.trigger_current_event(
|
||||
&[player_index],
|
||||
|e| &mut e.on_influence_culture_resolution,
|
||||
roll_boost_cost,
|
||||
|
|
@ -185,18 +185,18 @@ pub fn influence_culture_boost_cost(
|
|||
PaymentOptions::resources(ResourcePile::culture_tokens(range_boost)),
|
||||
ActionInfo::new(attacker),
|
||||
);
|
||||
let _ = attacker.events.on_influence_culture_attempt.get().trigger(
|
||||
let _ = attacker.trigger_event(
|
||||
|e| &e.on_influence_culture_attempt,
|
||||
&mut info,
|
||||
target_city,
|
||||
game,
|
||||
&mut (),
|
||||
);
|
||||
info.is_defender = true;
|
||||
let _ = defender.events.on_influence_culture_attempt.get().trigger(
|
||||
let _ = defender.trigger_event(
|
||||
|e| &e.on_influence_culture_attempt,
|
||||
&mut info,
|
||||
target_city,
|
||||
game,
|
||||
&mut (),
|
||||
);
|
||||
|
||||
if !matches!(city_piece, Building::Obelisk)
|
||||
|
|
@ -234,11 +234,10 @@ pub fn influence_culture(
|
|||
.set_building(building, influencer_index);
|
||||
game.successful_cultural_influence = true;
|
||||
|
||||
game.trigger_event_with_game_value(
|
||||
game.trigger_transient_event_with_game_value(
|
||||
influencer_index,
|
||||
|e| &mut e.on_influence_culture_success,
|
||||
&influencer_index,
|
||||
&(),
|
||||
&mut (),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,13 +35,15 @@ impl EventOrigin {
|
|||
| EventOrigin::Leader(name)
|
||||
| EventOrigin::TacticsCard(name)
|
||||
| EventOrigin::Builtin(name) => name.to_string(),
|
||||
EventOrigin::ActionCard(id) => action_cards::get_action_card(*id).civil_card.name,
|
||||
EventOrigin::Incident(id) => incidents::get_incident(*id).name,
|
||||
EventOrigin::ActionCard(id) => get_action_card(*id).civil_card.name,
|
||||
EventOrigin::Incident(id) => get_incident(*id).name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use crate::content::{action_cards, incidents};
|
||||
use action_cards::get_action_card;
|
||||
use incidents::get_incident;
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ pub(crate) fn move_to_unexplored_block(
|
|||
destination,
|
||||
ship_can_teleport,
|
||||
};
|
||||
ask_explore_resolution(game, player_index, &resolution_state);
|
||||
ask_explore_resolution(game, player_index, resolution_state);
|
||||
|
||||
true // current event is active
|
||||
}
|
||||
|
|
@ -141,9 +141,9 @@ pub(crate) fn move_to_unexplored_block(
|
|||
pub(crate) fn ask_explore_resolution(
|
||||
game: &mut Game,
|
||||
player_index: usize,
|
||||
resolution_state: &ExploreResolutionState,
|
||||
resolution_state: ExploreResolutionState,
|
||||
) {
|
||||
game.trigger_current_event(
|
||||
let _ = game.trigger_current_event(
|
||||
&[player_index],
|
||||
|events| &mut events.on_explore_resolution,
|
||||
resolution_state,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ use crate::events::{Event, EventOrigin};
|
|||
use crate::incident::PermanentIncidentEffect;
|
||||
use crate::movement::{CurrentMove, MoveState};
|
||||
use crate::pirates::get_pirates_player;
|
||||
use crate::player_events::{CurrentEvent, CurrentEventInfo, PlayerEvents};
|
||||
use crate::player_events::{
|
||||
CurrentEvent, CurrentEventInfo, PersistentEvents, PlayerEvents, TransientEvents,
|
||||
};
|
||||
use crate::resource::check_for_waste;
|
||||
use crate::resource_pile::ResourcePile;
|
||||
use crate::status_phase::enter_status_phase;
|
||||
|
|
@ -35,7 +37,7 @@ use std::vec;
|
|||
|
||||
pub struct Game {
|
||||
pub state: GameState,
|
||||
pub current_events: Vec<CurrentEventState>,
|
||||
pub events: Vec<CurrentEventState>,
|
||||
// in turn order starting from starting_player_index and wrapping around
|
||||
pub players: Vec<Player>,
|
||||
pub map: Map,
|
||||
|
|
@ -143,7 +145,7 @@ impl Game {
|
|||
.collect();
|
||||
let mut game = Self {
|
||||
state: GameState::Playing,
|
||||
current_events: Vec::new(),
|
||||
events: Vec::new(),
|
||||
players,
|
||||
map,
|
||||
starting_player_index: starting_player,
|
||||
|
|
@ -219,7 +221,7 @@ impl Game {
|
|||
action_cards_left: data.action_cards_left,
|
||||
incidents_left: data.incidents_left,
|
||||
permanent_incident_effects: data.permanent_incident_effects,
|
||||
current_events: data.current_events,
|
||||
events: data.events,
|
||||
};
|
||||
for player in data.players {
|
||||
Player::initialize_player(player, &mut game);
|
||||
|
|
@ -231,7 +233,7 @@ impl Game {
|
|||
pub fn data(self) -> GameData {
|
||||
GameData {
|
||||
state: self.state,
|
||||
current_events: self.current_events,
|
||||
events: self.events,
|
||||
players: self.players.into_iter().map(Player::data).collect(),
|
||||
map: self.map.data(),
|
||||
starting_player_index: self.starting_player_index,
|
||||
|
|
@ -260,7 +262,7 @@ impl Game {
|
|||
pub fn cloned_data(&self) -> GameData {
|
||||
GameData {
|
||||
state: self.state.clone(),
|
||||
current_events: self.current_events.clone(),
|
||||
events: self.events.clone(),
|
||||
players: self.players.iter().map(Player::cloned_data).collect(),
|
||||
map: self.map.cloned_data(),
|
||||
starting_player_index: self.starting_player_index,
|
||||
|
|
@ -339,12 +341,12 @@ impl Game {
|
|||
/// Panics if the player does not have events
|
||||
#[must_use]
|
||||
pub fn current_event(&self) -> &CurrentEventState {
|
||||
self.current_events.last().expect("state should exist")
|
||||
self.events.last().expect("state should exist")
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub(crate) fn current_event_mut(&mut self) -> &mut CurrentEventState {
|
||||
self.current_events.last_mut().expect("state should exist")
|
||||
self.events.last_mut().expect("state should exist")
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
|
@ -354,13 +356,11 @@ impl Game {
|
|||
|
||||
#[must_use]
|
||||
pub fn current_event_handler(&self) -> Option<&CurrentEventHandler> {
|
||||
self.current_events
|
||||
.last()
|
||||
.and_then(|s| s.player.handler.as_ref())
|
||||
self.events.last().and_then(|s| s.player.handler.as_ref())
|
||||
}
|
||||
|
||||
pub fn current_event_handler_mut(&mut self) -> Option<&mut CurrentEventHandler> {
|
||||
self.current_events
|
||||
self.events
|
||||
.last_mut()
|
||||
.and_then(|s| s.player.handler.as_mut())
|
||||
}
|
||||
|
|
@ -368,66 +368,68 @@ impl Game {
|
|||
pub(crate) fn trigger_current_event_with_listener<V>(
|
||||
&mut self,
|
||||
players: &[usize],
|
||||
event: fn(&mut PlayerEvents) -> &mut CurrentEvent<V>,
|
||||
listeners: Option<&AbilityListeners>,
|
||||
event_type: &V,
|
||||
event: fn(&mut PersistentEvents) -> &mut CurrentEvent<V>,
|
||||
listeners: &AbilityListeners,
|
||||
event_type: V,
|
||||
store_type: impl Fn(V) -> CurrentEventType,
|
||||
log: Option<&str>,
|
||||
) -> Option<V>
|
||||
where
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
if let Some(listeners) = listeners {
|
||||
for p in players {
|
||||
(listeners.initializer)(self, *p);
|
||||
}
|
||||
|
||||
let result = self.trigger_current_event(players, event, event_type, store_type, log);
|
||||
|
||||
for p in players {
|
||||
(listeners.deinitializer)(self, *p);
|
||||
}
|
||||
result
|
||||
} else {
|
||||
self.trigger_current_event(players, event, event_type, store_type, log)
|
||||
for p in players {
|
||||
(listeners.initializer)(self, *p);
|
||||
}
|
||||
|
||||
let result = self.trigger_current_event(players, event, event_type, store_type, log);
|
||||
|
||||
for p in players {
|
||||
(listeners.deinitializer)(self, *p);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub(crate) fn trigger_current_event<V>(
|
||||
&mut self,
|
||||
players: &[usize],
|
||||
event: fn(&mut PlayerEvents) -> &mut CurrentEvent<V>,
|
||||
details: &V,
|
||||
event: fn(&mut PersistentEvents) -> &mut CurrentEvent<V>,
|
||||
mut value: V,
|
||||
to_event_type: impl Fn(V) -> CurrentEventType,
|
||||
log: Option<&str>,
|
||||
) -> Option<V>
|
||||
where
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
let current_event_type = to_event_type(details.clone());
|
||||
let current_event_type = to_event_type(value.clone());
|
||||
if self
|
||||
.current_events
|
||||
.events
|
||||
.last()
|
||||
.is_none_or(|s| s.event_type != current_event_type)
|
||||
{
|
||||
if let Some(log) = log {
|
||||
self.add_info_log_group(log.to_string());
|
||||
}
|
||||
self.current_events
|
||||
self.events
|
||||
.push(CurrentEventState::new(players[0], current_event_type));
|
||||
}
|
||||
|
||||
let event_index = self.current_events.len() - 1;
|
||||
let event_index = self.events.len() - 1;
|
||||
|
||||
let mut value = details.clone();
|
||||
for player_index in Self::remaining_current_event_players(players, self.current_event()) {
|
||||
let info = CurrentEventInfo {
|
||||
player: player_index,
|
||||
};
|
||||
self.trigger_event_with_game_value(player_index, event, &info, &(), &mut value);
|
||||
self.trigger_persistent_event_with_game_value(
|
||||
player_index,
|
||||
event,
|
||||
&info,
|
||||
&(),
|
||||
&mut value,
|
||||
);
|
||||
|
||||
if self.current_event().player.handler.is_some() {
|
||||
self.current_events[event_index].event_type = to_event_type(value.clone());
|
||||
self.events[event_index].event_type = to_event_type(value);
|
||||
return None;
|
||||
}
|
||||
let state = self.current_event_mut();
|
||||
|
|
@ -436,7 +438,7 @@ impl Game {
|
|||
state.player = CurrentEventPlayer::new(p);
|
||||
}
|
||||
}
|
||||
self.current_events.pop();
|
||||
self.events.pop();
|
||||
Some(value)
|
||||
}
|
||||
|
||||
|
|
@ -448,10 +450,45 @@ impl Game {
|
|||
.collect_vec()
|
||||
}
|
||||
|
||||
pub(crate) fn trigger_event_with_game_value<U, V, W>(
|
||||
fn trigger_persistent_event_with_game_value<U, V, W>(
|
||||
&mut self,
|
||||
player_index: usize,
|
||||
event: fn(&mut PlayerEvents) -> &mut Event<Game, U, V, W>,
|
||||
event: fn(&mut PersistentEvents) -> &mut Event<Game, U, V, W>,
|
||||
info: &U,
|
||||
details: &V,
|
||||
extra_value: &mut W,
|
||||
) where
|
||||
W: Clone + PartialEq,
|
||||
{
|
||||
self.trigger_event_with_game_value(
|
||||
player_index,
|
||||
move |e| event(&mut e.persistent),
|
||||
info,
|
||||
details,
|
||||
extra_value,
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn trigger_transient_event_with_game_value<U, V>(
|
||||
&mut self,
|
||||
player_index: usize,
|
||||
event: fn(&mut TransientEvents) -> &mut Event<Game, U, V>,
|
||||
info: &U,
|
||||
details: &V,
|
||||
) {
|
||||
self.trigger_event_with_game_value(
|
||||
player_index,
|
||||
move |e| event(&mut e.transient),
|
||||
info,
|
||||
details,
|
||||
&mut (),
|
||||
);
|
||||
}
|
||||
|
||||
fn trigger_event_with_game_value<U, V, W>(
|
||||
&mut self,
|
||||
player_index: usize,
|
||||
event: impl Fn(&mut PlayerEvents) -> &mut Event<Game, U, V, W>,
|
||||
info: &U,
|
||||
details: &V,
|
||||
extra_value: &mut W,
|
||||
|
|
@ -535,10 +572,10 @@ impl Game {
|
|||
}
|
||||
|
||||
pub(crate) fn start_turn(&mut self) {
|
||||
self.trigger_current_event(
|
||||
let _ = self.trigger_current_event(
|
||||
&[self.current_player_index],
|
||||
|e| &mut e.on_turn_start,
|
||||
&(),
|
||||
(),
|
||||
|()| CurrentEventType::TurnStart,
|
||||
None,
|
||||
);
|
||||
|
|
@ -563,7 +600,7 @@ impl Game {
|
|||
|
||||
#[must_use]
|
||||
pub fn active_player(&self) -> usize {
|
||||
if let Some(e) = &self.current_events.last() {
|
||||
if let Some(e) = &self.events.last() {
|
||||
return e.player.index;
|
||||
}
|
||||
self.current_player_index
|
||||
|
|
@ -778,7 +815,7 @@ pub struct GameData {
|
|||
state: GameState,
|
||||
#[serde(default)]
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
current_events: Vec<CurrentEventState>,
|
||||
events: Vec<CurrentEventState>,
|
||||
players: Vec<PlayerData>,
|
||||
map: MapData,
|
||||
starting_player_index: usize,
|
||||
|
|
@ -821,13 +858,6 @@ pub enum GameState {
|
|||
Finished,
|
||||
}
|
||||
|
||||
impl GameState {
|
||||
#[must_use]
|
||||
pub fn is_playing(&self) -> bool {
|
||||
matches!(self, GameState::Playing)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq)]
|
||||
pub struct ActionLogItem {
|
||||
pub action: Action,
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ pub fn strip_secret(mut game: Game, player_index: Option<usize>) -> Game {
|
|||
}
|
||||
}
|
||||
game.map.strip_secret();
|
||||
for s in &mut game.current_events {
|
||||
for s in &mut game.events {
|
||||
if let CurrentEventType::CombatRoundStart(r) = &mut s.event_type {
|
||||
if r.attacker_strength.tactics_card.is_some() {
|
||||
// defender shouldn't see attacker's tactics card
|
||||
|
|
@ -120,6 +120,10 @@ pub fn strip_secret(mut game: Game, player_index: Option<usize>) -> Game {
|
|||
}
|
||||
}
|
||||
}
|
||||
for l in &mut game.action_log {
|
||||
// undo has secret information, like gained and discarded action cards
|
||||
l.undo.clear();
|
||||
}
|
||||
game
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
use crate::ability_initializer::{AbilityInitializerBuilder, AbilityListeners};
|
||||
use crate::ability_initializer::{AbilityInitializerSetup, SelectedChoice};
|
||||
use crate::barbarians::{barbarians_move, barbarians_spawn, no_units_present};
|
||||
use crate::card::draw_card_from_pile;
|
||||
use crate::card::{draw_card_from_pile, HandCard};
|
||||
use crate::city::MoodState;
|
||||
use crate::content::custom_phase_actions::{
|
||||
new_position_request, CurrentEventType, PaymentRequest, PlayerRequest, PositionRequest,
|
||||
ResourceRewardRequest, SelectedStructure, StructuresRequest, UnitTypeRequest, UnitsRequest,
|
||||
new_position_request, CurrentEventType, HandCardsRequest, PaymentRequest, PlayerRequest,
|
||||
PositionRequest, ResourceRewardRequest, SelectedStructure, StructuresRequest, UnitTypeRequest,
|
||||
UnitsRequest,
|
||||
};
|
||||
use crate::content::incidents;
|
||||
use crate::events::EventOrigin;
|
||||
|
|
@ -19,7 +20,6 @@ use crate::position::Position;
|
|||
use crate::resource::ResourceType;
|
||||
use crate::resource_pile::ResourcePile;
|
||||
use crate::unit::UnitType;
|
||||
use crate::utils::{remove_and_map_element_by, remove_element_by};
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ pub struct Anarchy {
|
|||
pub advances_lost: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum PassedIncident {
|
||||
NewPlayer(usize),
|
||||
AlreadyPassed,
|
||||
|
|
@ -105,7 +105,6 @@ pub enum PermanentIncidentEffect {
|
|||
TrojanHorse,
|
||||
SolarEclipse,
|
||||
Anarchy(Anarchy),
|
||||
PassedIncident(PassedIncident),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
@ -372,13 +371,38 @@ impl IncidentBuilder {
|
|||
)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub(crate) fn add_incident_hand_card_request(
|
||||
self,
|
||||
role: IncidentTarget,
|
||||
priority: i32,
|
||||
request: impl Fn(&mut Game, usize, &IncidentInfo) -> Option<HandCardsRequest> + 'static + Clone,
|
||||
cards_selected: impl Fn(&mut Game, &SelectedChoice<Vec<HandCard>>) + 'static + Clone,
|
||||
) -> Self {
|
||||
let f = self.new_filter(role, priority);
|
||||
self.add_hand_card_request(
|
||||
|event| &mut event.on_incident,
|
||||
priority,
|
||||
move |game, player_index, i| {
|
||||
if f.is_active(game, i, player_index) {
|
||||
request(game, player_index, i)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
},
|
||||
move |game, s, _| {
|
||||
cards_selected(game, s);
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub(crate) fn add_incident_player_request(
|
||||
self,
|
||||
description: &str,
|
||||
player_pred: impl Fn(&Player, &Game) -> bool + 'static + Clone,
|
||||
priority: i32,
|
||||
gain_reward: impl Fn(&mut Game, &SelectedChoice<usize>) + 'static + Clone,
|
||||
gain_reward: impl Fn(&mut Game, &SelectedChoice<usize>, &mut IncidentInfo) + 'static + Clone,
|
||||
) -> Self {
|
||||
let f = self.new_filter(IncidentTarget::ActivePlayer, priority);
|
||||
let d = description.to_string();
|
||||
|
|
@ -403,8 +427,8 @@ impl IncidentBuilder {
|
|||
None
|
||||
}
|
||||
},
|
||||
move |game, s, _| {
|
||||
gain_reward(game, s);
|
||||
move |game, s, i| {
|
||||
gain_reward(game, s, i);
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
@ -523,34 +547,28 @@ pub(crate) fn trigger_incident(game: &mut Game, mut info: IncidentInfo) {
|
|||
);
|
||||
|
||||
loop {
|
||||
if game
|
||||
.trigger_current_event_with_listener(
|
||||
&game.human_players(info.active_player),
|
||||
|events| &mut events.on_incident,
|
||||
Some(&incident.listeners),
|
||||
&info,
|
||||
CurrentEventType::Incident,
|
||||
play_base_effect(game).then_some(&format!(
|
||||
"A new game event has been triggered: {}",
|
||||
incident.name
|
||||
)),
|
||||
)
|
||||
.is_none()
|
||||
{
|
||||
return;
|
||||
}
|
||||
let log: Option<String> = play_base_effect(&info).then_some(format!(
|
||||
"A new game event has been triggered: {}",
|
||||
incident.name
|
||||
));
|
||||
info = match game.trigger_current_event_with_listener(
|
||||
&game.human_players(info.active_player),
|
||||
|events| &mut events.on_incident,
|
||||
&incident.listeners,
|
||||
info,
|
||||
CurrentEventType::Incident,
|
||||
log.as_deref(),
|
||||
) {
|
||||
Some(p) => p,
|
||||
None => return,
|
||||
};
|
||||
|
||||
if !game
|
||||
.current_events
|
||||
.events
|
||||
.iter()
|
||||
.any(|e| matches!(e.event_type, CurrentEventType::Incident(_)))
|
||||
{
|
||||
if let Some(p) = passed_to_player(game, info.active_player) {
|
||||
info.active_player = p;
|
||||
game.permanent_incident_effects
|
||||
.push(PermanentIncidentEffect::PassedIncident(
|
||||
PassedIncident::AlreadyPassed,
|
||||
));
|
||||
if passed_to_player(game, &mut info) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
|
@ -558,39 +576,24 @@ pub(crate) fn trigger_incident(game: &mut Game, mut info: IncidentInfo) {
|
|||
}
|
||||
|
||||
game.incidents_left.remove(0);
|
||||
|
||||
remove_element_by(&mut game.permanent_incident_effects, |e| {
|
||||
matches!(
|
||||
e,
|
||||
PermanentIncidentEffect::PassedIncident(PassedIncident::AlreadyPassed)
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn play_base_effect(game: &Game) -> bool {
|
||||
!game
|
||||
.permanent_incident_effects
|
||||
.iter()
|
||||
.any(|e| matches!(e, PermanentIncidentEffect::PassedIncident(_)))
|
||||
pub(crate) fn play_base_effect(i: &IncidentInfo) -> bool {
|
||||
i.passed.is_none()
|
||||
}
|
||||
|
||||
fn passed_to_player(game: &mut Game, player_index: usize) -> Option<usize> {
|
||||
let p = remove_and_map_element_by(&mut game.permanent_incident_effects, |e| {
|
||||
if let PermanentIncidentEffect::PassedIncident(PassedIncident::NewPlayer(p)) = e {
|
||||
Some(*p)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
|
||||
if let Some(p) = p {
|
||||
fn passed_to_player(game: &mut Game, i: &mut IncidentInfo) -> bool {
|
||||
if let Some(PassedIncident::NewPlayer(p)) = i.passed {
|
||||
game.add_info_log_item(&format!(
|
||||
"Player {} has passed the incident to {}",
|
||||
game.player_name(player_index),
|
||||
game.player_name(i.active_player),
|
||||
game.player_name(p)
|
||||
));
|
||||
i.passed = Some(PassedIncident::AlreadyPassed);
|
||||
i.active_player = p;
|
||||
return true;
|
||||
}
|
||||
p
|
||||
false
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
|
@ -606,7 +609,7 @@ pub fn is_active(
|
|||
return false;
|
||||
}
|
||||
if priority >= BASE_EFFECT_PRIORITY {
|
||||
return play_base_effect(game);
|
||||
return play_base_effect(i);
|
||||
}
|
||||
// protection advance does not protect against base effects
|
||||
if let Some(advance) = &protection_advance {
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ pub mod resource;
|
|||
pub mod resource_pile;
|
||||
mod special_advance;
|
||||
pub mod status_phase;
|
||||
mod tactics_card;
|
||||
pub mod tactics_card;
|
||||
mod undo;
|
||||
pub mod unit;
|
||||
pub mod utils;
|
||||
mod wonder;
|
||||
pub mod wonder;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
#![allow(clippy::if_not_else)]
|
||||
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::content::action_cards;
|
||||
use crate::cultural_influence::influence_culture_boost_cost;
|
||||
use crate::game::ActionLogItem;
|
||||
use crate::player::Player;
|
||||
|
|
@ -18,6 +16,9 @@ use crate::{
|
|||
unit::{MovementAction, Units},
|
||||
utils,
|
||||
};
|
||||
use action_cards::get_action_card;
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct LogSliceOptions {
|
||||
|
|
@ -67,6 +68,10 @@ fn format_playing_action_log_item(action: &PlayingAction, game: &Game) -> String
|
|||
format_cultural_influence_attempt_log_item(game, player.index, &player_name, c)
|
||||
}
|
||||
PlayingAction::Custom(action) => action.format_log_item(game, player, &player_name),
|
||||
PlayingAction::ActionCard(a) => format!(
|
||||
"{player_name} played the action card {}",
|
||||
get_action_card(*a).civil_card.name
|
||||
),
|
||||
PlayingAction::EndTurn => format!(
|
||||
"{player_name} ended their turn{}",
|
||||
match game.actions_left {
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ pub(crate) fn move_units(
|
|||
let p = game.get_player(player_index);
|
||||
let from = p.get_unit(units[0]).position;
|
||||
let info = MoveInfo::new(player_index, units.to_vec(), from, to);
|
||||
game.trigger_event_with_game_value(player_index, |e| &mut e.before_move, &info, &(), &mut ());
|
||||
game.trigger_transient_event_with_game_value(player_index, |e| &mut e.before_move, &info, &());
|
||||
|
||||
for unit_id in units {
|
||||
move_unit(game, player_index, *unit_id, to, embark_carrier_id);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
use crate::action_card::ActionCard;
|
||||
use crate::advance::Advance;
|
||||
use crate::city_pieces::{DestroyedStructures, DestroyedStructuresData};
|
||||
use crate::consts::{UNIT_LIMIT_BARBARIANS, UNIT_LIMIT_PIRATES};
|
||||
use crate::content::advances::get_advance;
|
||||
use crate::content::wonders::get_wonder;
|
||||
use crate::content::{action_cards, builtin};
|
||||
use crate::content::builtin;
|
||||
use crate::events::{Event, EventOrigin};
|
||||
use crate::payment::PaymentOptions;
|
||||
use crate::player_events::CostInfo;
|
||||
use crate::player_events::{CostInfo, TransientEvents};
|
||||
use crate::resource::ResourceType;
|
||||
use crate::unit::{carried_units, UnitData, UnitType};
|
||||
use crate::{
|
||||
|
|
@ -67,7 +65,7 @@ pub struct Player {
|
|||
pub event_victory_points: f32,
|
||||
pub custom_actions: HashMap<CustomActionType, EventOrigin>,
|
||||
pub wonder_cards: Vec<String>,
|
||||
pub action_cards: Vec<ActionCard>,
|
||||
pub action_cards: Vec<u8>,
|
||||
pub next_unit_id: u32,
|
||||
pub played_once_per_turn_actions: Vec<CustomActionType>,
|
||||
pub event_info: HashMap<String, String>,
|
||||
|
|
@ -181,11 +179,7 @@ impl Player {
|
|||
event_victory_points: data.event_victory_points,
|
||||
custom_actions: HashMap::new(),
|
||||
wonder_cards: data.wonder_cards,
|
||||
action_cards: data
|
||||
.action_cards
|
||||
.iter()
|
||||
.map(|action_card| action_cards::get_action_card(*action_card))
|
||||
.collect(),
|
||||
action_cards: data.action_cards,
|
||||
next_unit_id: data.next_unit_id,
|
||||
played_once_per_turn_actions: data.played_once_per_turn_actions,
|
||||
event_info: data.event_info,
|
||||
|
|
@ -222,11 +216,7 @@ impl Player {
|
|||
captured_leaders: self.captured_leaders,
|
||||
event_victory_points: self.event_victory_points,
|
||||
wonder_cards: self.wonder_cards,
|
||||
action_cards: self
|
||||
.action_cards
|
||||
.into_iter()
|
||||
.map(|action_card| action_card.id)
|
||||
.collect(),
|
||||
action_cards: self.action_cards,
|
||||
next_unit_id: self.next_unit_id,
|
||||
played_once_per_turn_actions: self.played_once_per_turn_actions,
|
||||
event_info: self.event_info,
|
||||
|
|
@ -266,11 +256,7 @@ impl Player {
|
|||
captured_leaders: self.captured_leaders.clone(),
|
||||
event_victory_points: self.event_victory_points,
|
||||
wonder_cards: self.wonder_cards.clone(),
|
||||
action_cards: self
|
||||
.action_cards
|
||||
.iter()
|
||||
.map(|action_card| action_card.id)
|
||||
.collect(),
|
||||
action_cards: self.action_cards.clone(),
|
||||
next_unit_id: self.next_unit_id,
|
||||
played_once_per_turn_actions: self.played_once_per_turn_actions.clone(),
|
||||
event_info: self.event_info.clone(),
|
||||
|
|
@ -540,9 +526,8 @@ impl Player {
|
|||
}
|
||||
|
||||
pub fn strip_secret(&mut self) {
|
||||
self.wonder_cards = Vec::new();
|
||||
self.action_cards = Vec::new();
|
||||
//replace with empty strings to see the number of cards?
|
||||
self.wonder_cards = self.wonder_cards.iter().map(|_| String::new()).collect();
|
||||
self.action_cards = self.action_cards.iter().map(|_| 0).collect();
|
||||
//todo strip information about other hand cards
|
||||
}
|
||||
|
||||
|
|
@ -775,7 +760,7 @@ impl Player {
|
|||
#[must_use]
|
||||
pub(crate) fn trigger_event<T, U, V>(
|
||||
&self,
|
||||
event: fn(&PlayerEvents) -> &Event<T, U, V, ()>,
|
||||
event: fn(&TransientEvents) -> &Event<T, U, V, ()>,
|
||||
value: &mut T,
|
||||
info: &U,
|
||||
details: &V,
|
||||
|
|
@ -783,19 +768,19 @@ impl Player {
|
|||
where
|
||||
T: Clone + PartialEq,
|
||||
{
|
||||
let e = event(&self.events);
|
||||
let e = event(&self.events.transient);
|
||||
e.get().trigger(value, info, details, &mut ())
|
||||
}
|
||||
|
||||
pub(crate) fn trigger_cost_event<U, V>(
|
||||
&self,
|
||||
get_event: fn(&PlayerEvents) -> &Event<CostInfo, U, V>,
|
||||
get_event: impl Fn(&TransientEvents) -> &Event<CostInfo, U, V>,
|
||||
value: &PaymentOptions,
|
||||
info: &U,
|
||||
details: &V,
|
||||
execute: Option<&ResourcePile>,
|
||||
) -> CostInfo {
|
||||
let event = get_event(&self.events).get();
|
||||
let event = get_event(&self.events.transient).get();
|
||||
let mut cost_info = CostInfo::new(self, value.clone());
|
||||
if let Some(execute) = execute {
|
||||
event.trigger_with_minimal_modifiers(
|
||||
|
|
@ -815,18 +800,13 @@ impl Player {
|
|||
|
||||
pub(crate) fn trigger_player_event<U, V>(
|
||||
&mut self,
|
||||
event: fn(&mut PlayerEvents) -> &mut Event<Player, U, V>,
|
||||
event: impl Fn(&mut TransientEvents) -> &mut Event<Player, U, V>,
|
||||
info: &U,
|
||||
details: &V,
|
||||
) {
|
||||
let e = event(&mut self.events).take();
|
||||
let e = event(&mut self.events.transient).take();
|
||||
let _ = e.trigger(self, info, details, &mut ());
|
||||
event(&mut self.events).set(e);
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn wonder_cards(&self) -> Vec<Wonder> {
|
||||
self.wonder_cards.iter().map(|n| get_wonder(n)).collect()
|
||||
event(&mut self.events.transient).set(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use crate::combat_listeners::{CombatEnd, CombatRoundEnd, CombatRoundStart};
|
|||
use crate::events::Event;
|
||||
use crate::explore::ExploreResolutionState;
|
||||
use crate::game::Game;
|
||||
use crate::incident::{PassedIncident, PermanentIncidentEffect};
|
||||
use crate::incident::PassedIncident;
|
||||
use crate::map::Terrain;
|
||||
use crate::payment::PaymentOptions;
|
||||
use crate::playing_actions::{PlayingActionType, Recruit};
|
||||
|
|
@ -23,17 +23,17 @@ pub(crate) type CurrentEvent<V = ()> = Event<Game, CurrentEventInfo, (), V>;
|
|||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct PlayerEvents {
|
||||
pub on_construct: CurrentEvent<Building>,
|
||||
pub persistent: PersistentEvents,
|
||||
pub transient: TransientEvents,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct TransientEvents {
|
||||
pub on_construct_wonder: Event<Player, Position, Wonder>,
|
||||
pub on_draw_wonder_card: CurrentEvent,
|
||||
pub on_collect: Event<CollectInfo, Game>,
|
||||
pub on_advance: CurrentEvent<AdvanceInfo>,
|
||||
pub on_recruit: CurrentEvent<Recruit>,
|
||||
pub on_influence_culture_attempt: Event<InfluenceCultureInfo, City, Game>, // todo add listener method
|
||||
pub on_influence_culture_attempt: Event<InfluenceCultureInfo, City, Game>,
|
||||
pub on_influence_culture_success: Event<Game, usize>,
|
||||
pub on_influence_culture_resolution: CurrentEvent<ResourcePile>,
|
||||
pub before_move: Event<Game, MoveInfo>,
|
||||
pub on_explore_resolution: CurrentEvent<ExploreResolutionState>,
|
||||
|
||||
pub construct_cost: Event<CostInfo, City, Building>,
|
||||
pub wonder_cost: Event<CostInfo, City, Wonder>,
|
||||
|
|
@ -46,6 +46,18 @@ pub(crate) struct PlayerEvents {
|
|||
pub terrain_collect_options: Event<HashMap<Terrain, HashSet<ResourcePile>>>,
|
||||
pub collect_options: Event<CollectInfo, CollectContext, Game>,
|
||||
pub collect_total: Event<CollectInfo>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[allow(clippy::struct_field_names)]
|
||||
pub(crate) struct PersistentEvents {
|
||||
pub on_construct: CurrentEvent<Building>,
|
||||
pub on_draw_wonder_card: CurrentEvent,
|
||||
pub on_advance: CurrentEvent<AdvanceInfo>,
|
||||
pub on_recruit: CurrentEvent<Recruit>,
|
||||
pub on_influence_culture_resolution: CurrentEvent<ResourcePile>,
|
||||
pub on_explore_resolution: CurrentEvent<ExploreResolutionState>,
|
||||
pub on_play_action_card: CurrentEvent<u8>,
|
||||
|
||||
pub on_status_phase: CurrentEvent<StatusPhaseState>,
|
||||
pub on_turn_start: CurrentEvent,
|
||||
|
|
@ -101,6 +113,9 @@ pub enum IncidentTarget {
|
|||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct IncidentInfo {
|
||||
pub active_player: usize,
|
||||
#[serde(default)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub passed: Option<PassedIncident>,
|
||||
}
|
||||
|
||||
impl IncidentInfo {
|
||||
|
|
@ -108,17 +123,13 @@ impl IncidentInfo {
|
|||
pub fn new(origin: usize) -> IncidentInfo {
|
||||
IncidentInfo {
|
||||
active_player: origin,
|
||||
passed: None,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn is_active(&self, role: IncidentTarget, player: usize, game: &Game) -> bool {
|
||||
if game.permanent_incident_effects.iter().any(|e| {
|
||||
matches!(
|
||||
e,
|
||||
PermanentIncidentEffect::PassedIncident(PassedIncident::NewPlayer(_))
|
||||
)
|
||||
}) {
|
||||
if matches!(self.passed, Some(PassedIncident::NewPlayer(_))) {
|
||||
// wait until the new player is playing the advance
|
||||
return false;
|
||||
}
|
||||
|
|
@ -159,6 +170,7 @@ impl CostInfo {
|
|||
pub struct AdvanceInfo {
|
||||
pub name: String,
|
||||
pub payment: ResourcePile,
|
||||
pub take_incident_token: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ use serde::{Deserialize, Serialize};
|
|||
use PlayingAction::*;
|
||||
|
||||
use crate::action::Action;
|
||||
use crate::advance::advance_with_incident_token;
|
||||
use crate::advance::gain_advance;
|
||||
use crate::city::MoodState;
|
||||
use crate::collect::collect;
|
||||
use crate::content::action_cards::get_action_card;
|
||||
use crate::content::advances::get_advance;
|
||||
use crate::content::custom_phase_actions::CurrentEventType;
|
||||
use crate::cultural_influence::influence_culture_attempt;
|
||||
|
|
@ -73,6 +74,7 @@ pub enum PlayingActionType {
|
|||
MoveUnits,
|
||||
IncreaseHappiness,
|
||||
InfluenceCultureAttempt,
|
||||
ActionCard,
|
||||
Custom,
|
||||
EndTurn,
|
||||
}
|
||||
|
|
@ -111,6 +113,7 @@ pub enum PlayingAction {
|
|||
IncreaseHappiness(IncreaseHappiness),
|
||||
InfluenceCultureAttempt(InfluenceCultureAttempt),
|
||||
Custom(CustomAction),
|
||||
ActionCard(u8),
|
||||
EndTurn,
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +144,7 @@ impl PlayingAction {
|
|||
game.get_player(player_index)
|
||||
.advance_cost(&a, Some(&payment))
|
||||
.pay(game, &payment);
|
||||
advance_with_incident_token(game, &advance, player_index, payment);
|
||||
gain_advance(game, &advance, player_index, payment, true);
|
||||
}
|
||||
FoundCity { settler } => {
|
||||
let settler = game.players[player_index].remove_unit(settler);
|
||||
|
|
@ -177,7 +180,7 @@ impl PlayingAction {
|
|||
game.add_info_log_item("Academy gained 2 ideas");
|
||||
}
|
||||
cost.pay(game, &c.payment);
|
||||
Self::on_construct(game, player_index, c.city_piece);
|
||||
on_construct(game, player_index, c.city_piece);
|
||||
}
|
||||
Collect(c) => {
|
||||
if game.action_log.iter().any(|i| {
|
||||
|
|
@ -204,12 +207,15 @@ impl PlayingAction {
|
|||
} else {
|
||||
panic!("Cannot pay for units")
|
||||
}
|
||||
recruit(game, player_index, &r);
|
||||
recruit(game, player_index, r);
|
||||
}
|
||||
IncreaseHappiness(i) => {
|
||||
increase_happiness(game, player_index, &i.happiness_increases, Some(i.payment));
|
||||
}
|
||||
InfluenceCultureAttempt(c) => influence_culture_attempt(game, player_index, &c),
|
||||
ActionCard(a) => {
|
||||
play_action_card(game, player_index, a);
|
||||
}
|
||||
Custom(custom_action) => {
|
||||
assert!(
|
||||
game.is_custom_action_available(
|
||||
|
|
@ -238,16 +244,6 @@ impl PlayingAction {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn on_construct(game: &mut Game, player_index: usize, building: Building) {
|
||||
game.trigger_current_event(
|
||||
&[player_index],
|
||||
|e| &mut e.on_construct,
|
||||
&building,
|
||||
CurrentEventType::Construct,
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn action_type(&self) -> ActionType {
|
||||
match self {
|
||||
|
|
@ -269,6 +265,7 @@ impl PlayingAction {
|
|||
PlayingAction::InfluenceCultureAttempt { .. } => {
|
||||
PlayingActionType::InfluenceCultureAttempt
|
||||
}
|
||||
PlayingAction::ActionCard(_) => PlayingActionType::ActionCard,
|
||||
PlayingAction::Custom(_) => PlayingActionType::Custom,
|
||||
PlayingAction::EndTurn => PlayingActionType::EndTurn,
|
||||
}
|
||||
|
|
@ -349,3 +346,25 @@ pub(crate) fn increase_happiness(
|
|||
pub(crate) fn roll_boost_cost(roll: u8) -> ResourcePile {
|
||||
ResourcePile::culture_tokens(5 - roll as u32)
|
||||
}
|
||||
|
||||
pub(crate) fn play_action_card(game: &mut Game, player_index: usize, card_id: u8) {
|
||||
let card = get_action_card(card_id);
|
||||
let _ = game.trigger_current_event_with_listener(
|
||||
&[player_index],
|
||||
|e| &mut e.on_play_action_card,
|
||||
&card.civil_card.listeners,
|
||||
card_id,
|
||||
CurrentEventType::ActionCard,
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn on_construct(game: &mut Game, player_index: usize, building: Building) {
|
||||
let _ = game.trigger_current_event(
|
||||
&[player_index],
|
||||
|e| &mut e.on_construct,
|
||||
building,
|
||||
CurrentEventType::Construct,
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::position::Position;
|
|||
use crate::resource_pile::ResourcePile;
|
||||
use crate::unit::{UnitType, Units};
|
||||
|
||||
pub(crate) fn recruit(game: &mut Game, player_index: usize, r: &Recruit) {
|
||||
pub(crate) fn recruit(game: &mut Game, player_index: usize, r: Recruit) {
|
||||
if let Some(leader_name) = &r.leader_name {
|
||||
if let Some(previous_leader) = game.players[player_index].active_leader.take() {
|
||||
Player::with_leader(
|
||||
|
|
@ -64,7 +64,8 @@ fn set_active_leader(game: &mut Game, leader_name: String, player_index: usize)
|
|||
game.get_player_mut(player_index).active_leader = Some(leader_name);
|
||||
}
|
||||
|
||||
pub(crate) fn on_recruit(game: &mut Game, player_index: usize, r: &Recruit) {
|
||||
pub(crate) fn on_recruit(game: &mut Game, player_index: usize, r: Recruit) {
|
||||
let city_position = r.city_position;
|
||||
if game
|
||||
.trigger_current_event(
|
||||
&[player_index],
|
||||
|
|
@ -77,7 +78,6 @@ pub(crate) fn on_recruit(game: &mut Game, player_index: usize, r: &Recruit) {
|
|||
{
|
||||
return;
|
||||
}
|
||||
let city_position = r.city_position;
|
||||
|
||||
if let Some(port_position) = game.players[player_index]
|
||||
.try_get_city(city_position)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use crate::ability_initializer::AbilityInitializerSetup;
|
||||
use crate::advance::{advance_with_incident_token, do_advance, remove_advance};
|
||||
use crate::action_card::gain_action_card_from_pile;
|
||||
use crate::advance::{do_advance, gain_advance, remove_advance};
|
||||
use crate::consts::AGES;
|
||||
use crate::content::builtin::{status_phase_handler, Builtin};
|
||||
use crate::content::custom_phase_actions::{
|
||||
|
|
@ -7,7 +8,7 @@ use crate::content::custom_phase_actions::{
|
|||
CurrentEventResponse, CurrentEventType, PlayerRequest,
|
||||
};
|
||||
use crate::payment::PaymentOptions;
|
||||
use crate::player_events::{CurrentEvent, PlayerEvents};
|
||||
use crate::player_events::{CurrentEvent, PersistentEvents};
|
||||
use crate::{content::advances, game::Game, player::Player, resource_pile::ResourcePile, utils};
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
@ -39,7 +40,7 @@ pub const CHANGE_GOVERNMENT_COST: ResourcePile = ResourcePile::new(0, 0, 0, 0, 0
|
|||
|
||||
#[must_use]
|
||||
pub fn get_status_phase(game: &Game) -> Option<&StatusPhaseState> {
|
||||
game.current_events.iter().find_map(|e| {
|
||||
game.events.iter().find_map(|e| {
|
||||
if let CurrentEventType::StatusPhase(s) = &e.event_type {
|
||||
Some(s)
|
||||
} else {
|
||||
|
|
@ -60,18 +61,16 @@ pub(crate) fn play_status_phase(game: &mut Game, mut phase: StatusPhaseState) {
|
|||
use StatusPhaseState::*;
|
||||
|
||||
loop {
|
||||
if game
|
||||
.trigger_current_event_with_listener(
|
||||
&game.human_players(game.starting_player_index),
|
||||
|events| &mut events.on_status_phase,
|
||||
Some(&status_phase_handler(&phase).listeners),
|
||||
&phase,
|
||||
CurrentEventType::StatusPhase,
|
||||
None,
|
||||
)
|
||||
.is_none()
|
||||
{
|
||||
return;
|
||||
phase = match game.trigger_current_event_with_listener(
|
||||
&game.human_players(game.starting_player_index),
|
||||
|events| &mut events.on_status_phase,
|
||||
&status_phase_handler(&phase).listeners,
|
||||
phase,
|
||||
CurrentEventType::StatusPhase,
|
||||
None,
|
||||
) {
|
||||
Some(s) => s,
|
||||
None => return,
|
||||
};
|
||||
|
||||
phase = match phase {
|
||||
|
|
@ -113,7 +112,7 @@ pub(crate) fn complete_objectives() -> Builtin {
|
|||
|
||||
pub(crate) fn free_advance() -> Builtin {
|
||||
Builtin::builder("Free Advance", "Advance for free")
|
||||
.add_advance_reward_request_listener(
|
||||
.add_advance_request(
|
||||
|event| &mut event.on_status_phase,
|
||||
0,
|
||||
|game, player_index, _player_name| {
|
||||
|
|
@ -129,7 +128,7 @@ pub(crate) fn free_advance() -> Builtin {
|
|||
"{} advanced {} for free",
|
||||
c.player_name, c.choice
|
||||
));
|
||||
advance_with_incident_token(game, &c.choice, c.player_index, ResourcePile::empty());
|
||||
gain_advance(game, &c.choice, c.player_index, ResourcePile::empty(), true);
|
||||
},
|
||||
)
|
||||
.build()
|
||||
|
|
@ -140,8 +139,9 @@ pub(crate) fn draw_cards() -> Builtin {
|
|||
.add_simple_current_event_listener(
|
||||
|event| &mut event.on_status_phase,
|
||||
0,
|
||||
|_game, _p, _name, _s| {
|
||||
// todo every player draws 1 action card and 1 objective card
|
||||
|game, p, _name, _s| {
|
||||
gain_action_card_from_pile(game, p);
|
||||
// todo every player draws 1 objective card
|
||||
},
|
||||
)
|
||||
.build()
|
||||
|
|
@ -203,7 +203,7 @@ pub(crate) fn add_change_government<A, E, V>(
|
|||
cost: ResourcePile,
|
||||
) -> A
|
||||
where
|
||||
E: Fn(&mut PlayerEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
E: Fn(&mut PersistentEvents) -> &mut CurrentEvent<V> + 'static + Clone,
|
||||
A: AbilityInitializerSetup,
|
||||
V: Clone + PartialEq,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,12 +5,13 @@ use crate::action_card::ActionCard;
|
|||
use crate::advance::AdvanceBuilder;
|
||||
use crate::card::HandCard;
|
||||
use crate::combat::{update_combat_strength, Combat, CombatModifier};
|
||||
use crate::combat_listeners::{CombatRoundType, CombatStrength};
|
||||
use crate::combat_listeners::{CombatEventPhase, CombatRoundEnd, CombatStrength};
|
||||
use crate::content::action_cards;
|
||||
use crate::content::custom_phase_actions::HandCardsRequest;
|
||||
use crate::events::EventOrigin;
|
||||
use crate::game::Game;
|
||||
use crate::utils::remove_element_by;
|
||||
use action_cards::get_action_card;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Copy)]
|
||||
pub enum TacticsCardTarget {
|
||||
|
|
@ -24,12 +25,12 @@ impl TacticsCardTarget {
|
|||
self,
|
||||
player: usize,
|
||||
combat: &Combat,
|
||||
round_type: &CombatRoundType,
|
||||
round_type: &CombatEventPhase,
|
||||
) -> bool {
|
||||
match &self {
|
||||
TacticsCardTarget::ActivePlayer => match round_type {
|
||||
CombatRoundType::TacticsCardAttacker => combat.attacker == player,
|
||||
CombatRoundType::TacticsCardDefender => combat.defender == player,
|
||||
CombatEventPhase::TacticsCardAttacker => combat.attacker == player,
|
||||
CombatEventPhase::TacticsCardDefender => combat.defender == player,
|
||||
_ => panic!("TacticsCardTarget::ActivePlayer is not valid"),
|
||||
},
|
||||
TacticsCardTarget::AllPlayers => true,
|
||||
|
|
@ -37,6 +38,7 @@ impl TacticsCardTarget {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum FighterRequirement {
|
||||
Army,
|
||||
Fortress,
|
||||
|
|
@ -121,7 +123,7 @@ impl TacticsCardBuilder {
|
|||
|event| &mut event.on_combat_round_start_tactics,
|
||||
priority,
|
||||
move |game, p, _, s| {
|
||||
if target.is_active(p, &s.combat, &s.round_type) {
|
||||
if target.is_active(p, &s.combat, &s.phase) {
|
||||
update_combat_strength(game, p, s, {
|
||||
let l = listener.clone();
|
||||
move |game, combat, s, _role| l(p, game, combat, s)
|
||||
|
|
@ -131,6 +133,23 @@ impl TacticsCardBuilder {
|
|||
)
|
||||
}
|
||||
|
||||
pub(crate) fn add_resolve_listener(
|
||||
self,
|
||||
priority: i32,
|
||||
listener: impl Fn(usize, &mut Game, &mut CombatRoundEnd) + Clone + 'static,
|
||||
) -> Self {
|
||||
let target = self.tactics_card_target;
|
||||
self.add_simple_current_event_listener(
|
||||
|event| &mut event.on_combat_round_end_tactics,
|
||||
priority,
|
||||
move |game, p, _, s| {
|
||||
if target.is_active(p, &s.combat, &s.phase) {
|
||||
listener(p, game, s);
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn build(self) -> TacticsCard {
|
||||
TacticsCard {
|
||||
|
|
@ -190,15 +209,10 @@ pub(crate) fn play_tactics_card(b: AdvanceBuilder) -> AdvanceBuilder {
|
|||
panic!("Expected ActionCard, got {:?}", sel.choice[0]);
|
||||
};
|
||||
update_combat_strength(game, player, s, move |_game, _c, s, _role| {
|
||||
s.tactics_card = Some(
|
||||
action_cards::get_action_card(card)
|
||||
.tactics_card
|
||||
.name
|
||||
.clone(),
|
||||
);
|
||||
s.tactics_card = Some(get_action_card(card).tactics_card.name.clone());
|
||||
});
|
||||
remove_element_by(&mut game.get_player_mut(player).action_cards, |c| {
|
||||
c.id == card
|
||||
remove_element_by(&mut game.get_player_mut(player).action_cards, |&id| {
|
||||
id == card
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -209,6 +223,7 @@ fn available_tactics_cards(game: &Game, player: usize, combat: &Combat) -> Vec<H
|
|||
game.players[player]
|
||||
.action_cards
|
||||
.iter()
|
||||
.map(|id| get_action_card(*id))
|
||||
.filter(|a| can_play_tactics_card(game, player, a, combat))
|
||||
.map(|a| HandCard::ActionCard(a.id))
|
||||
.collect()
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ impl WonderBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn build(self) -> Wonder {
|
||||
Wonder {
|
||||
name: self.name,
|
||||
|
|
@ -92,10 +93,10 @@ impl AbilityInitializerSetup for WonderBuilder {
|
|||
}
|
||||
|
||||
pub(crate) fn draw_wonder_card(game: &mut Game, player_index: usize) {
|
||||
game.trigger_current_event(
|
||||
let _ = game.trigger_current_event(
|
||||
&[player_index],
|
||||
|e| &mut e.on_draw_wonder_card,
|
||||
&(),
|
||||
(),
|
||||
|()| CurrentEventType::DrawWonderCard,
|
||||
None,
|
||||
);
|
||||
|
|
|
|||
23
server/tests/action_card_tests.rs
Normal file
23
server/tests/action_card_tests.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use crate::common::TestAction;
|
||||
use common::JsonTest;
|
||||
use server::action::Action;
|
||||
use server::content::custom_phase_actions::CurrentEventResponse;
|
||||
use server::playing_actions::PlayingAction;
|
||||
|
||||
mod common;
|
||||
|
||||
const JSON: JsonTest = JsonTest::new("action_cards");
|
||||
|
||||
#[test]
|
||||
fn test_advance() {
|
||||
JSON.test(
|
||||
"advance",
|
||||
vec![
|
||||
TestAction::undoable(0, Action::Playing(PlayingAction::ActionCard(2))),
|
||||
TestAction::undoable(
|
||||
0,
|
||||
Action::Response(CurrentEventResponse::SelectAdvance("Storage".to_string())),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
use crate::common::{move_action, JsonTest, TestAction};
|
||||
use server::action::Action;
|
||||
use server::card::HandCard;
|
||||
use server::city_pieces::Building::Fortress;
|
||||
use server::content::custom_phase_actions::{CurrentEventResponse, Structure};
|
||||
use server::playing_actions;
|
||||
|
|
@ -604,8 +605,8 @@ fn test_pandemics() {
|
|||
),
|
||||
TestAction::not_undoable(
|
||||
0,
|
||||
Action::Response(CurrentEventResponse::Payment(vec![
|
||||
ResourcePile::culture_tokens(1),
|
||||
Action::Response(CurrentEventResponse::SelectHandCards(vec![
|
||||
HandCard::ActionCard(1),
|
||||
])),
|
||||
),
|
||||
TestAction::not_undoable(
|
||||
|
|
|
|||
|
|
@ -31,6 +31,12 @@ fn test_free_advance() {
|
|||
1,
|
||||
Action::Response(CurrentEventResponse::SelectAdvance("Storage".to_string())),
|
||||
),
|
||||
TestAction::not_undoable(
|
||||
0,
|
||||
Action::Response(CurrentEventResponse::SelectAdvance(
|
||||
"Philosophy".to_string(),
|
||||
)),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
@ -63,10 +69,16 @@ fn test_raze_city() {
|
|||
fn test_raze_city_decline() {
|
||||
JSON.test(
|
||||
"raze_city_decline",
|
||||
vec![TestAction::not_undoable(
|
||||
0,
|
||||
Action::Response(CurrentEventResponse::SelectPositions(vec![])),
|
||||
)],
|
||||
vec![
|
||||
TestAction::not_undoable(
|
||||
0,
|
||||
Action::Response(CurrentEventResponse::SelectPositions(vec![])),
|
||||
),
|
||||
TestAction::not_undoable(
|
||||
1,
|
||||
Action::Response(CurrentEventResponse::SelectPositions(vec![])),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
42
server/tests/tactics_card_tests.rs
Normal file
42
server/tests/tactics_card_tests.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
use crate::common::{move_action, TestAction};
|
||||
use common::JsonTest;
|
||||
use server::action::Action;
|
||||
use server::card::HandCard;
|
||||
use server::content::custom_phase_actions::CurrentEventResponse;
|
||||
use server::position::Position;
|
||||
|
||||
mod common;
|
||||
|
||||
const JSON: JsonTest = JsonTest::new("tactics_cards");
|
||||
|
||||
#[test]
|
||||
fn test_peltasts() {
|
||||
JSON.test(
|
||||
"peltasts",
|
||||
vec![
|
||||
TestAction::not_undoable(0, move_action(vec![0], Position::from_offset("C1"))),
|
||||
TestAction::not_undoable(
|
||||
0,
|
||||
Action::Response(CurrentEventResponse::SelectHandCards(vec![
|
||||
HandCard::ActionCard(1),
|
||||
])),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_encircled() {
|
||||
JSON.test(
|
||||
"encircled",
|
||||
vec![
|
||||
TestAction::not_undoable(0, move_action(vec![0], Position::from_offset("C1"))),
|
||||
TestAction::not_undoable(
|
||||
0,
|
||||
Action::Response(CurrentEventResponse::SelectHandCards(vec![
|
||||
HandCard::ActionCard(2),
|
||||
])),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
222
server/tests/test_games/action_cards/advance.json
Normal file
222
server/tests/test_games/action_cards/advance.json
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"players": [
|
||||
{
|
||||
"id": 0,
|
||||
"resources": {
|
||||
"food": 2,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 3,
|
||||
"gold": 7,
|
||||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"resource_limit": {
|
||||
"food": 2,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 7,
|
||||
"gold": 7,
|
||||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"cities": [
|
||||
{
|
||||
"city_pieces": {},
|
||||
"mood_state": "Happy",
|
||||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "A1"
|
||||
},
|
||||
{
|
||||
"city_pieces": {},
|
||||
"mood_state": "Neutral",
|
||||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "C2"
|
||||
}
|
||||
],
|
||||
"units": [
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Infantry",
|
||||
"id": 0
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Cavalry",
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Leader",
|
||||
"id": 2
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Elephant",
|
||||
"id": 3
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 4
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 5
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 6
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 7
|
||||
}
|
||||
],
|
||||
"civilization": "test0",
|
||||
"advances": [
|
||||
"Farming",
|
||||
"Mining",
|
||||
"Tactics"
|
||||
],
|
||||
"incident_tokens": 2,
|
||||
"action_cards": [
|
||||
2
|
||||
],
|
||||
"next_unit_id": 8
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"resources": {
|
||||
"food": 2,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 7,
|
||||
"gold": 7,
|
||||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"resource_limit": {
|
||||
"food": 2,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 7,
|
||||
"gold": 7,
|
||||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"cities": [
|
||||
{
|
||||
"city_pieces": {},
|
||||
"mood_state": "Angry",
|
||||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "C1"
|
||||
}
|
||||
],
|
||||
"units": [
|
||||
{
|
||||
"position": "C1",
|
||||
"unit_type": "Infantry",
|
||||
"id": 0
|
||||
},
|
||||
{
|
||||
"position": "C1",
|
||||
"unit_type": "Infantry",
|
||||
"id": 1
|
||||
}
|
||||
],
|
||||
"civilization": "test1",
|
||||
"advances": [
|
||||
"Fanaticism",
|
||||
"Farming",
|
||||
"Mining",
|
||||
"Tactics"
|
||||
],
|
||||
"incident_tokens": 3,
|
||||
"next_unit_id": 2
|
||||
}
|
||||
],
|
||||
"map": {
|
||||
"tiles": [
|
||||
[
|
||||
"A1",
|
||||
"Fertile"
|
||||
],
|
||||
[
|
||||
"A2",
|
||||
"Water"
|
||||
],
|
||||
[
|
||||
"A3",
|
||||
{
|
||||
"Exhausted": "Forest"
|
||||
}
|
||||
],
|
||||
[
|
||||
"B1",
|
||||
"Mountain"
|
||||
],
|
||||
[
|
||||
"B2",
|
||||
"Forest"
|
||||
],
|
||||
[
|
||||
"B3",
|
||||
"Fertile"
|
||||
],
|
||||
[
|
||||
"C1",
|
||||
"Barren"
|
||||
],
|
||||
[
|
||||
"C2",
|
||||
"Forest"
|
||||
],
|
||||
[
|
||||
"C3",
|
||||
"Water"
|
||||
],
|
||||
[
|
||||
"D2",
|
||||
"Water"
|
||||
]
|
||||
]
|
||||
},
|
||||
"starting_player_index": 0,
|
||||
"current_player_index": 0,
|
||||
"action_log": [],
|
||||
"action_log_index": 0,
|
||||
"log": [],
|
||||
"undo_limit": 0,
|
||||
"actions_left": 3,
|
||||
"successful_cultural_influence": false,
|
||||
"round": 2,
|
||||
"age": 1,
|
||||
"messages": [
|
||||
"The game has started"
|
||||
],
|
||||
"dice_roll_outcomes": [
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
11,
|
||||
11,
|
||||
11,
|
||||
11
|
||||
],
|
||||
"dice_roll_log": [],
|
||||
"dropped_players": [],
|
||||
"wonders_left": [
|
||||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
281
server/tests/test_games/action_cards/advance.outcome.json
Normal file
281
server/tests/test_games/action_cards/advance.outcome.json
Normal file
|
|
@ -0,0 +1,281 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"ActionCard": 2
|
||||
},
|
||||
"player": 0,
|
||||
"last_priority_used": 0,
|
||||
"handler": {
|
||||
"priority": 0,
|
||||
"request": {
|
||||
"SelectAdvance": {
|
||||
"choices": [
|
||||
"Storage",
|
||||
"Irrigation",
|
||||
"Husbandry",
|
||||
"Engineering",
|
||||
"Sanitation",
|
||||
"Roads",
|
||||
"Fishing",
|
||||
"Writing",
|
||||
"Siegecraft",
|
||||
"Steel Weapons",
|
||||
"Draft",
|
||||
"Myths",
|
||||
"Bartering",
|
||||
"Arts",
|
||||
"Math"
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin": {
|
||||
"ActionCard": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"players": [
|
||||
{
|
||||
"id": 0,
|
||||
"resources": {
|
||||
"food": 2,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 3,
|
||||
"gold": 7,
|
||||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"resource_limit": {
|
||||
"food": 2,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 7,
|
||||
"gold": 7,
|
||||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"cities": [
|
||||
{
|
||||
"city_pieces": {},
|
||||
"mood_state": "Happy",
|
||||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "A1"
|
||||
},
|
||||
{
|
||||
"city_pieces": {},
|
||||
"mood_state": "Neutral",
|
||||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "C2"
|
||||
}
|
||||
],
|
||||
"units": [
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Infantry",
|
||||
"id": 0
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Cavalry",
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Leader",
|
||||
"id": 2
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Elephant",
|
||||
"id": 3
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 4
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 5
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 6
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 7
|
||||
}
|
||||
],
|
||||
"civilization": "test0",
|
||||
"advances": [
|
||||
"Farming",
|
||||
"Mining",
|
||||
"Tactics"
|
||||
],
|
||||
"incident_tokens": 2,
|
||||
"action_cards": [
|
||||
2
|
||||
],
|
||||
"next_unit_id": 8
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"resources": {
|
||||
"food": 2,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 7,
|
||||
"gold": 7,
|
||||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"resource_limit": {
|
||||
"food": 2,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 7,
|
||||
"gold": 7,
|
||||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"cities": [
|
||||
{
|
||||
"city_pieces": {},
|
||||
"mood_state": "Angry",
|
||||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "C1"
|
||||
}
|
||||
],
|
||||
"units": [
|
||||
{
|
||||
"position": "C1",
|
||||
"unit_type": "Infantry",
|
||||
"id": 0
|
||||
},
|
||||
{
|
||||
"position": "C1",
|
||||
"unit_type": "Infantry",
|
||||
"id": 1
|
||||
}
|
||||
],
|
||||
"civilization": "test1",
|
||||
"advances": [
|
||||
"Fanaticism",
|
||||
"Farming",
|
||||
"Mining",
|
||||
"Tactics"
|
||||
],
|
||||
"incident_tokens": 3,
|
||||
"next_unit_id": 2
|
||||
}
|
||||
],
|
||||
"map": {
|
||||
"tiles": [
|
||||
[
|
||||
"A1",
|
||||
"Fertile"
|
||||
],
|
||||
[
|
||||
"A2",
|
||||
"Water"
|
||||
],
|
||||
[
|
||||
"A3",
|
||||
{
|
||||
"Exhausted": "Forest"
|
||||
}
|
||||
],
|
||||
[
|
||||
"B1",
|
||||
"Mountain"
|
||||
],
|
||||
[
|
||||
"B2",
|
||||
"Forest"
|
||||
],
|
||||
[
|
||||
"B3",
|
||||
"Fertile"
|
||||
],
|
||||
[
|
||||
"C1",
|
||||
"Barren"
|
||||
],
|
||||
[
|
||||
"C2",
|
||||
"Forest"
|
||||
],
|
||||
[
|
||||
"C3",
|
||||
"Water"
|
||||
],
|
||||
[
|
||||
"D2",
|
||||
"Water"
|
||||
]
|
||||
]
|
||||
},
|
||||
"starting_player_index": 0,
|
||||
"current_player_index": 0,
|
||||
"action_log": [
|
||||
{
|
||||
"action": {
|
||||
"Playing": {
|
||||
"ActionCard": 2
|
||||
}
|
||||
},
|
||||
"undo": [
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/actions_left",
|
||||
"value": 3
|
||||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/events"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"action_log_index": 1,
|
||||
"log": [
|
||||
[
|
||||
"Player1 played the action card Advance"
|
||||
]
|
||||
],
|
||||
"undo_limit": 0,
|
||||
"actions_left": 2,
|
||||
"successful_cultural_influence": false,
|
||||
"round": 2,
|
||||
"age": 1,
|
||||
"messages": [
|
||||
"The game has started"
|
||||
],
|
||||
"dice_roll_outcomes": [
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
11,
|
||||
11,
|
||||
11,
|
||||
11
|
||||
],
|
||||
"dice_roll_log": [],
|
||||
"dropped_players": [],
|
||||
"wonders_left": [
|
||||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
318
server/tests/test_games/action_cards/advance.outcome1.json
Normal file
318
server/tests/test_games/action_cards/advance.outcome1.json
Normal file
|
|
@ -0,0 +1,318 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"players": [
|
||||
{
|
||||
"id": 0,
|
||||
"resources": {
|
||||
"food": 2,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 3,
|
||||
"gold": 7,
|
||||
"mood_tokens": 8,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"resource_limit": {
|
||||
"food": 7,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 7,
|
||||
"gold": 7,
|
||||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"cities": [
|
||||
{
|
||||
"city_pieces": {},
|
||||
"mood_state": "Happy",
|
||||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "A1"
|
||||
},
|
||||
{
|
||||
"city_pieces": {},
|
||||
"mood_state": "Neutral",
|
||||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "C2"
|
||||
}
|
||||
],
|
||||
"units": [
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Infantry",
|
||||
"id": 0
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Cavalry",
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Leader",
|
||||
"id": 2
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Elephant",
|
||||
"id": 3
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 4
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 5
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 6
|
||||
},
|
||||
{
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 7
|
||||
}
|
||||
],
|
||||
"civilization": "test0",
|
||||
"advances": [
|
||||
"Farming",
|
||||
"Mining",
|
||||
"Storage",
|
||||
"Tactics"
|
||||
],
|
||||
"incident_tokens": 2,
|
||||
"action_cards": [
|
||||
2
|
||||
],
|
||||
"next_unit_id": 8
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"resources": {
|
||||
"food": 2,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 7,
|
||||
"gold": 7,
|
||||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"resource_limit": {
|
||||
"food": 2,
|
||||
"wood": 7,
|
||||
"ore": 7,
|
||||
"ideas": 7,
|
||||
"gold": 7,
|
||||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"cities": [
|
||||
{
|
||||
"city_pieces": {},
|
||||
"mood_state": "Angry",
|
||||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "C1"
|
||||
}
|
||||
],
|
||||
"units": [
|
||||
{
|
||||
"position": "C1",
|
||||
"unit_type": "Infantry",
|
||||
"id": 0
|
||||
},
|
||||
{
|
||||
"position": "C1",
|
||||
"unit_type": "Infantry",
|
||||
"id": 1
|
||||
}
|
||||
],
|
||||
"civilization": "test1",
|
||||
"advances": [
|
||||
"Fanaticism",
|
||||
"Farming",
|
||||
"Mining",
|
||||
"Tactics"
|
||||
],
|
||||
"incident_tokens": 3,
|
||||
"next_unit_id": 2
|
||||
}
|
||||
],
|
||||
"map": {
|
||||
"tiles": [
|
||||
[
|
||||
"A1",
|
||||
"Fertile"
|
||||
],
|
||||
[
|
||||
"A2",
|
||||
"Water"
|
||||
],
|
||||
[
|
||||
"A3",
|
||||
{
|
||||
"Exhausted": "Forest"
|
||||
}
|
||||
],
|
||||
[
|
||||
"B1",
|
||||
"Mountain"
|
||||
],
|
||||
[
|
||||
"B2",
|
||||
"Forest"
|
||||
],
|
||||
[
|
||||
"B3",
|
||||
"Fertile"
|
||||
],
|
||||
[
|
||||
"C1",
|
||||
"Barren"
|
||||
],
|
||||
[
|
||||
"C2",
|
||||
"Forest"
|
||||
],
|
||||
[
|
||||
"C3",
|
||||
"Water"
|
||||
],
|
||||
[
|
||||
"D2",
|
||||
"Water"
|
||||
]
|
||||
]
|
||||
},
|
||||
"starting_player_index": 0,
|
||||
"current_player_index": 0,
|
||||
"action_log": [
|
||||
{
|
||||
"action": {
|
||||
"Playing": {
|
||||
"ActionCard": 2
|
||||
}
|
||||
},
|
||||
"undo": [
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/actions_left",
|
||||
"value": 3
|
||||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/events"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": {
|
||||
"Response": {
|
||||
"SelectAdvance": "Storage"
|
||||
}
|
||||
},
|
||||
"undo": [
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/events",
|
||||
"value": [
|
||||
{
|
||||
"event_type": {
|
||||
"ActionCard": 2
|
||||
},
|
||||
"handler": {
|
||||
"origin": {
|
||||
"ActionCard": 2
|
||||
},
|
||||
"priority": 0,
|
||||
"request": {
|
||||
"SelectAdvance": {
|
||||
"choices": [
|
||||
"Storage",
|
||||
"Irrigation",
|
||||
"Husbandry",
|
||||
"Engineering",
|
||||
"Sanitation",
|
||||
"Roads",
|
||||
"Fishing",
|
||||
"Writing",
|
||||
"Siegecraft",
|
||||
"Steel Weapons",
|
||||
"Draft",
|
||||
"Myths",
|
||||
"Bartering",
|
||||
"Arts",
|
||||
"Math"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"last_priority_used": 0,
|
||||
"player": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/players/0/advances/2",
|
||||
"value": "Tactics"
|
||||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/players/0/advances/3"
|
||||
},
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/players/0/resource_limit/food",
|
||||
"value": 2
|
||||
},
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/players/0/resources/mood_tokens",
|
||||
"value": 7
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"action_log_index": 2,
|
||||
"log": [
|
||||
[
|
||||
"Player1 played the action card Advance"
|
||||
],
|
||||
[
|
||||
"Player gained 1 mood token as advance bonus",
|
||||
"Player1 gained Storage for 1 idea."
|
||||
]
|
||||
],
|
||||
"undo_limit": 0,
|
||||
"actions_left": 2,
|
||||
"successful_cultural_influence": false,
|
||||
"round": 2,
|
||||
"age": 1,
|
||||
"messages": [
|
||||
"The game has started"
|
||||
],
|
||||
"dice_roll_outcomes": [
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
11,
|
||||
11,
|
||||
11,
|
||||
11
|
||||
],
|
||||
"dice_roll_log": [],
|
||||
"dropped_players": [],
|
||||
"wonders_left": [
|
||||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"InfluenceCultureResolution": {
|
||||
|
|
@ -304,4 +304,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events",
|
||||
"path": "/events",
|
||||
"value": [
|
||||
{
|
||||
"event_type": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"Construct": "Temple"
|
||||
|
|
@ -430,7 +430,7 @@
|
|||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events"
|
||||
"path": "/events"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"Construct": "Temple"
|
||||
|
|
@ -416,7 +416,7 @@
|
|||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events"
|
||||
"path": "/events"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -431,17 +431,17 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/current_events/0/handler/origin/Advance",
|
||||
"path": "/events/0/handler/origin/Advance",
|
||||
"value": "Myths"
|
||||
},
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/current_events/0/handler/priority",
|
||||
"path": "/events/0/handler/priority",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events/0/handler/request/ResourceReward",
|
||||
"path": "/events/0/handler/request/ResourceReward",
|
||||
"value": {
|
||||
"name": "Select Temple bonus",
|
||||
"reward": {
|
||||
|
|
@ -466,11 +466,11 @@
|
|||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events/0/handler/request/SelectAdvance"
|
||||
"path": "/events/0/handler/request/SelectAdvance"
|
||||
},
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/current_events/0/last_priority_used",
|
||||
"path": "/events/0/last_priority_used",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@
|
|||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events"
|
||||
"path": "/events"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -408,17 +408,17 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/current_events/0/handler/origin/Advance",
|
||||
"path": "/events/0/handler/origin/Advance",
|
||||
"value": "Myths"
|
||||
},
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/current_events/0/handler/priority",
|
||||
"path": "/events/0/handler/priority",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events/0/handler/request/ResourceReward",
|
||||
"path": "/events/0/handler/request/ResourceReward",
|
||||
"value": {
|
||||
"name": "Select Temple bonus",
|
||||
"reward": {
|
||||
|
|
@ -443,11 +443,11 @@
|
|||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events/0/handler/request/SelectAdvance"
|
||||
"path": "/events/0/handler/request/SelectAdvance"
|
||||
},
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/current_events/0/last_priority_used",
|
||||
"path": "/events/0/last_priority_used",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
|
|
@ -466,7 +466,7 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events",
|
||||
"path": "/events",
|
||||
"value": [
|
||||
{
|
||||
"event_type": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"Advance": {
|
||||
|
|
@ -8,7 +8,8 @@
|
|||
"payment": {
|
||||
"food": 1,
|
||||
"gold": 1
|
||||
}
|
||||
},
|
||||
"take_incident_token": true
|
||||
}
|
||||
},
|
||||
"player": 0,
|
||||
|
|
@ -411,7 +412,7 @@
|
|||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events"
|
||||
"path": "/events"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@
|
|||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events"
|
||||
"path": "/events"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -371,7 +371,7 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events",
|
||||
"path": "/events",
|
||||
"value": [
|
||||
{
|
||||
"event_type": {
|
||||
|
|
@ -380,7 +380,8 @@
|
|||
"payment": {
|
||||
"food": 1,
|
||||
"gold": 1
|
||||
}
|
||||
},
|
||||
"take_incident_token": true
|
||||
}
|
||||
},
|
||||
"handler": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": "TurnStart",
|
||||
"player": 1,
|
||||
|
|
@ -457,4 +457,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events",
|
||||
"path": "/events",
|
||||
"value": [
|
||||
{
|
||||
"event_type": "TurnStart",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"InfluenceCultureResolution": {
|
||||
|
|
@ -302,4 +302,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events",
|
||||
"path": "/events",
|
||||
"value": [
|
||||
{
|
||||
"event_type": {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatEnd": {
|
||||
|
|
@ -386,4 +386,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatStart": {
|
||||
|
|
@ -332,4 +332,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatStart": {
|
||||
|
|
@ -371,4 +371,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatStart": {
|
||||
|
|
@ -368,4 +368,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatRoundStart": {
|
||||
|
|
@ -37,7 +37,6 @@
|
|||
"SteelWeaponsDefender"
|
||||
]
|
||||
},
|
||||
"round_type": "Default",
|
||||
"attacker_strength": {
|
||||
"extra_dies": 0,
|
||||
"extra_combat_value": 1,
|
||||
|
|
@ -385,4 +384,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatRoundStart": {
|
||||
|
|
@ -37,7 +37,6 @@
|
|||
"SteelWeaponsDefender"
|
||||
]
|
||||
},
|
||||
"round_type": "Default",
|
||||
"attacker_strength": {
|
||||
"extra_dies": 0,
|
||||
"extra_combat_value": 1,
|
||||
|
|
@ -403,4 +402,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,69 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatRoundEnd": {
|
||||
"attacker_casualties": {
|
||||
"fighters": 1,
|
||||
"tactics_card": "Peltasts"
|
||||
},
|
||||
"defender_casualties": {
|
||||
"fighters": 2,
|
||||
"tactics_card": "Encircled"
|
||||
},
|
||||
"can_retreat": false,
|
||||
"final_result": "AttackerWins",
|
||||
"combat": {
|
||||
"round": 1,
|
||||
"defender": 1,
|
||||
"defender_position": "C1",
|
||||
"attacker": 0,
|
||||
"attacker_position": "C2",
|
||||
"attackers": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
],
|
||||
"retreat": "CanRetreat",
|
||||
"modifiers": [
|
||||
"SteelWeaponsAttacker",
|
||||
"CancelFortressIgnoreHit",
|
||||
"SteelWeaponsDefender"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"player": 0,
|
||||
"last_priority_used": 1,
|
||||
"handler": {
|
||||
"priority": 1,
|
||||
"request": {
|
||||
"SelectUnits": {
|
||||
"player": 0,
|
||||
"choices": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3
|
||||
],
|
||||
"needed": {
|
||||
"start": 1,
|
||||
"end": 1
|
||||
},
|
||||
"description": "Remove 1 attacking units"
|
||||
}
|
||||
},
|
||||
"origin": {
|
||||
"Builtin": "Choose Casualties"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"players": [
|
||||
{
|
||||
"id": 0,
|
||||
|
|
@ -47,20 +110,11 @@
|
|||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "C2"
|
||||
},
|
||||
{
|
||||
"city_pieces": {
|
||||
"fortress": 0
|
||||
},
|
||||
"mood_state": "Angry",
|
||||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "C1"
|
||||
}
|
||||
],
|
||||
"units": [
|
||||
{
|
||||
"position": "C1",
|
||||
"position": "C2",
|
||||
"unit_type": "Infantry",
|
||||
"movement_restrictions": [
|
||||
"Battle"
|
||||
|
|
@ -68,7 +122,7 @@
|
|||
"id": 0
|
||||
},
|
||||
{
|
||||
"position": "C1",
|
||||
"position": "C2",
|
||||
"unit_type": "Cavalry",
|
||||
"movement_restrictions": [
|
||||
"Battle"
|
||||
|
|
@ -76,7 +130,7 @@
|
|||
"id": 1
|
||||
},
|
||||
{
|
||||
"position": "C1",
|
||||
"position": "C2",
|
||||
"unit_type": "Leader",
|
||||
"movement_restrictions": [
|
||||
"Battle"
|
||||
|
|
@ -84,7 +138,7 @@
|
|||
"id": 2
|
||||
},
|
||||
{
|
||||
"position": "C1",
|
||||
"position": "C2",
|
||||
"unit_type": "Elephant",
|
||||
"movement_restrictions": [
|
||||
"Battle"
|
||||
|
|
@ -92,12 +146,12 @@
|
|||
"id": 3
|
||||
},
|
||||
{
|
||||
"position": "C1",
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 4
|
||||
},
|
||||
{
|
||||
"position": "C1",
|
||||
"position": "C2",
|
||||
"unit_type": "Settler",
|
||||
"id": 5
|
||||
},
|
||||
|
|
@ -143,6 +197,29 @@
|
|||
"mood_tokens": 7,
|
||||
"culture_tokens": 7
|
||||
},
|
||||
"cities": [
|
||||
{
|
||||
"city_pieces": {
|
||||
"fortress": 1
|
||||
},
|
||||
"mood_state": "Angry",
|
||||
"activations": 0,
|
||||
"angry_activation": false,
|
||||
"position": "C1"
|
||||
}
|
||||
],
|
||||
"units": [
|
||||
{
|
||||
"position": "C1",
|
||||
"unit_type": "Infantry",
|
||||
"id": 0
|
||||
},
|
||||
{
|
||||
"position": "C1",
|
||||
"unit_type": "Infantry",
|
||||
"id": 1
|
||||
}
|
||||
],
|
||||
"civilization": "test1",
|
||||
"advances": [
|
||||
"Fanaticism",
|
||||
|
|
@ -300,14 +377,14 @@
|
|||
],
|
||||
[
|
||||
"Player2 played a Tactics Card",
|
||||
"Player1 rolled 6 (Infantry, +1 combat value), 6 (Infantry, no bonus), 1 (Leader, re-roll), 1 (Leader, re-roll), 1 (Leader, re-roll), 1 (Leader, re-roll), 1 (Leader, re-roll), 2 (Cavalry, +2 combat value), 6 (Infantry, no bonus) for combined combat value of 24 and gets 2 hits against defending units.",
|
||||
"Player2 rolled 1 (Leader, no bonus), 3 (Elephant, no bonus), 3 (Infantry, +1 combat value) for combined combat value of 9 and gets 0 hits against attacking units.",
|
||||
"Player1 reveals Tactics Card Peltasts",
|
||||
"Player2 reveals Tactics Card Encircled",
|
||||
"Player1 rolled 6 (Infantry, +1 combat value), 6 (Infantry, no bonus), 6 (Infantry, no bonus), 1 (Leader, re-roll), 1 (Leader, re-roll), 1 (Leader, re-roll), 1 (Leader, re-roll), 1 (Leader, re-roll), 2 (Cavalry, +2 combat value) for combined combat value of 24 and gets 2 hits against defending units.",
|
||||
"Player2 rolled 6 (Infantry, +1 combat value), 1 (Leader, no bonus), 3 (Elephant, no bonus) for combined combat value of 12 and gets 1 hits against attacking units.",
|
||||
"Player1 used the following combat modifiers: steel weapons added 1 combat value, Peltasts rolled a 6 and ignored a hit",
|
||||
"Player2 used the following combat modifiers: fortress added one extra die, steel weapons added 1 combat value, Peltasts rolled a 6 and ignored a hit",
|
||||
"Player2 has to remove all of their defending units",
|
||||
"Player2 removed 2 infantry",
|
||||
"Attacker wins and captured Player2's city at C1",
|
||||
"Player1 could not store 1 gold"
|
||||
"Player2 used the following combat modifiers: fortress added one extra die, steel weapons added 1 combat value",
|
||||
"Encircled cannot do damage - opponent has fewer losses",
|
||||
"Player1 has to remove 1 of their attacking units"
|
||||
]
|
||||
],
|
||||
"undo_limit": 6,
|
||||
|
|
@ -318,7 +395,7 @@
|
|||
"messages": [
|
||||
"The game has started"
|
||||
],
|
||||
"rng": "145085848379190613453225566047332025921",
|
||||
"rng": "295838188732677981854465749010340725692",
|
||||
"dice_roll_log": [
|
||||
11,
|
||||
11,
|
||||
|
|
@ -332,8 +409,7 @@
|
|||
2,
|
||||
10,
|
||||
0,
|
||||
4,
|
||||
5
|
||||
4
|
||||
],
|
||||
"dropped_players": [],
|
||||
"wonders_left": [
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"Recruit": {
|
||||
|
|
@ -359,7 +359,7 @@
|
|||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events"
|
||||
"path": "/events"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"Recruit": {
|
||||
|
|
@ -359,7 +359,7 @@
|
|||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events"
|
||||
"path": "/events"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -374,49 +374,49 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/current_events/0/handler/origin/Advance",
|
||||
"path": "/events/0/handler/origin/Advance",
|
||||
"value": "Nationalism"
|
||||
},
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/current_events/0/handler/priority",
|
||||
"path": "/events/0/handler/priority",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/current_events/0/handler/request/ResourceReward/name",
|
||||
"path": "/events/0/handler/request/ResourceReward/name",
|
||||
"value": "Select token to gain"
|
||||
},
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events/0/handler/request/ResourceReward/reward/conversions/0/from/0/mood_tokens",
|
||||
"path": "/events/0/handler/request/ResourceReward/reward/conversions/0/from/0/mood_tokens",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events/0/handler/request/ResourceReward/reward/conversions/0/from/0/wood"
|
||||
"path": "/events/0/handler/request/ResourceReward/reward/conversions/0/from/0/wood"
|
||||
},
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events/0/handler/request/ResourceReward/reward/conversions/0/to/culture_tokens",
|
||||
"path": "/events/0/handler/request/ResourceReward/reward/conversions/0/to/culture_tokens",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events/0/handler/request/ResourceReward/reward/conversions/0/to/gold"
|
||||
"path": "/events/0/handler/request/ResourceReward/reward/conversions/0/to/gold"
|
||||
},
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events/0/handler/request/ResourceReward/reward/default/mood_tokens",
|
||||
"path": "/events/0/handler/request/ResourceReward/reward/default/mood_tokens",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"op": "remove",
|
||||
"path": "/current_events/0/handler/request/ResourceReward/reward/default/wood"
|
||||
"path": "/events/0/handler/request/ResourceReward/reward/default/wood"
|
||||
},
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/current_events/0/last_priority_used",
|
||||
"path": "/events/0/last_priority_used",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatEnd": {
|
||||
|
|
@ -369,4 +369,4 @@
|
|||
"dropped_players": [],
|
||||
"wonders_left": [],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events",
|
||||
"path": "/events",
|
||||
"value": [
|
||||
{
|
||||
"event_type": {
|
||||
|
|
|
|||
|
|
@ -10,11 +10,10 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatRoundEnd": {
|
||||
"round_type": "Default",
|
||||
"attacker_casualties": {
|
||||
"fighters": 2
|
||||
},
|
||||
|
|
@ -319,4 +318,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events",
|
||||
"path": "/events",
|
||||
"value": [
|
||||
{
|
||||
"event_type": {
|
||||
|
|
@ -232,8 +232,7 @@
|
|||
"defender_casualties": {
|
||||
"fighters": 2
|
||||
},
|
||||
"final_result": "AttackerWins",
|
||||
"round_type": "Default"
|
||||
"final_result": "AttackerWins"
|
||||
}
|
||||
},
|
||||
"handler": {
|
||||
|
|
|
|||
|
|
@ -7,11 +7,10 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatRoundEnd": {
|
||||
"round_type": "Default",
|
||||
"attacker_casualties": {},
|
||||
"defender_casualties": {},
|
||||
"can_retreat": true,
|
||||
|
|
@ -282,4 +281,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events",
|
||||
"path": "/events",
|
||||
"value": [
|
||||
{
|
||||
"event_type": {
|
||||
|
|
@ -236,8 +236,7 @@
|
|||
"retreat": "CanRetreat",
|
||||
"round": 1
|
||||
},
|
||||
"defender_casualties": {},
|
||||
"round_type": "Default"
|
||||
"defender_casualties": {}
|
||||
}
|
||||
},
|
||||
"handler": {
|
||||
|
|
|
|||
|
|
@ -7,11 +7,10 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatRoundEnd": {
|
||||
"round_type": "Default",
|
||||
"attacker_casualties": {},
|
||||
"defender_casualties": {},
|
||||
"can_retreat": true,
|
||||
|
|
@ -282,4 +281,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,12 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatRoundEnd": {
|
||||
"round_type": "Default",
|
||||
"attacker_casualties": {
|
||||
"fighters": 1,
|
||||
"carried_units": 1
|
||||
"fighters": 1
|
||||
},
|
||||
"defender_casualties": {
|
||||
"fighters": 1
|
||||
|
|
|
|||
|
|
@ -269,13 +269,12 @@
|
|||
"undo": [
|
||||
{
|
||||
"op": "add",
|
||||
"path": "/current_events",
|
||||
"path": "/events",
|
||||
"value": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatRoundEnd": {
|
||||
"attacker_casualties": {
|
||||
"carried_units": 1,
|
||||
"fighters": 1
|
||||
},
|
||||
"can_retreat": false,
|
||||
|
|
@ -294,8 +293,7 @@
|
|||
"defender_casualties": {
|
||||
"fighters": 1
|
||||
},
|
||||
"final_result": "AttackerWins",
|
||||
"round_type": "Default"
|
||||
"final_result": "AttackerWins"
|
||||
}
|
||||
},
|
||||
"handler": {
|
||||
|
|
|
|||
|
|
@ -8,11 +8,10 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"CombatRoundEnd": {
|
||||
"round_type": "Default",
|
||||
"attacker_casualties": {
|
||||
"fighters": 1
|
||||
},
|
||||
|
|
@ -358,4 +357,4 @@
|
|||
"dropped_players": [],
|
||||
"wonders_left": [],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"StatusPhase": "FreeAdvance"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"StatusPhase": "FreeAdvance"
|
||||
|
|
@ -310,4 +310,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"StatusPhase": "FreeAdvance"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"StatusPhase": "FreeAdvance"
|
||||
|
|
@ -326,4 +326,4 @@
|
|||
"incidents_left": [
|
||||
28
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"state": "Playing",
|
||||
"current_events": [
|
||||
"events": [
|
||||
{
|
||||
"event_type": {
|
||||
"StatusPhase": "FreeAdvance"
|
||||
|
|
@ -317,4 +317,4 @@
|
|||
"Pyramids"
|
||||
],
|
||||
"action_cards_left": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue