construct test

This commit is contained in:
Gregor Zeitlinger 2023-09-23 21:17:25 +02:00
commit 3789103bce
4 changed files with 627 additions and 32 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@ dist/
.history/
*.cmd/
*.result.json
game.json

View file

@ -511,6 +511,23 @@ fn test_found_city() {
);
}
#[test]
fn test_construct() {
test_action(
"construct",
Action::Playing(Construct {
city_position: Position::from_offset("C2"),
city_piece: Observatory,
payment: ResourcePile::new(1, 1, 1, 0, 0, 0, 0),
port_position: None,
temple_bonus: None,
}),
0,
true,
false,
);
}
#[test]
#[should_panic(expected = "Illegal action")]
fn test_wrong_status_phase_action() {

View file

@ -5,12 +5,12 @@
"name": null,
"id": 0,
"resources": {
"food": 1,
"wood": 6,
"ore": 6,
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 5,
"gold": 7,
"mood_tokens": 7,
"mood_tokens": 6,
"culture_tokens": 7
},
"resource_limit": {
@ -47,13 +47,13 @@
"market": null,
"obelisk": null,
"observatory": null,
"fortress": 1,
"fortress": null,
"port": null,
"temple": null,
"wonders": []
},
"mood_state": "Angry",
"activations": 0,
"mood_state": "Happy",
"activations": 8,
"angry_activation": false,
"player_index": 0,
"position": "C2",
@ -132,7 +132,7 @@
"advances": [
"Farming",
"Mining",
"Tactics"
"Math"
],
"unlocked_special_advance": [],
"wonders": [],
@ -218,7 +218,7 @@
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 3
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
@ -279,7 +279,7 @@
"wonders_build": 0,
"leader_position": null,
"game_event_tokens": 3,
"influenced_buildings": 1,
"influenced_buildings": 0,
"completed_objectives": [],
"captured_leaders": [],
"event_victory_points": 0.0,
@ -290,7 +290,7 @@
"markets": 5,
"obelisks": 5,
"observatories": 5,
"fortresses": 4,
"fortresses": 5,
"ports": 5,
"temples": 5
},
@ -361,7 +361,9 @@
],
[
"A3",
"Mountain"
{
"Exhausted": "Forest"
}
],
[
"B1",
@ -394,20 +396,39 @@
]
},
"starting_player_index": 0,
"current_player_index": 1,
"current_player_index": 0,
"action_log": [
{
"Playing": {
"InfluenceCultureAttempt": {
"starting_city_position": "C1",
"target_player_index": 0,
"target_city_position": "C2",
"city_piece": "Fortress"
"IncreaseHappiness": {
"happiness_increases": [
[
"A1",
0
],
[
"C2",
1
]
]
}
}
},
{
"CulturalInfluenceResolution": true
"Playing": {
"Advance": {
"advance": "Math",
"payment": {
"food": 0,
"wood": 0,
"ore": 0,
"ideas": 2,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
}
}
}
],
"action_log_index": 2,
@ -415,26 +436,31 @@
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 payed 2 ideas to get the Tactics advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Fortress in the city at C2 making it Angry",
"Player1 ended his turn with 1 actions left",
"It's Player2's turn",
"Player2 tried to influence culture the Fortress in the city at C2 by Player1 with the city at C1and rolled a 1. Player2 now has the option to pay 4 culture tokens to increase the dice roll and proceed with the cultural influence",
"Player2 payed 1 culture tokens to increased the dice roll and proceed with the cultural influence"
"Player1 increased happiness in the city at C2 by 1 steps, making it Happy",
"Player1 payed 2 ideas to get the Math advance"
],
"undo_limit": 1,
"undo_limit": 0,
"played_once_per_turn_actions": [],
"actions_left": 2,
"successful_cultural_influence": true,
"actions_left": 1,
"successful_cultural_influence": false,
"round": 1,
"age": 1,
"messages": [
"The game has started"
],
"dice_roll_outcomes": [],
"dice_roll_log": [
1
"dice_roll_outcomes": [
1,
1,
10,
10,
10,
10,
10,
10,
10,
10
],
"dice_roll_log": [],
"dropped_players": [],
"wonders_left": [
"X"
@ -502,4 +528,4 @@
}
}
]
}
}

View file

@ -0,0 +1,551 @@
{
"state": "Playing",
"players": [
{
"name": null,
"id": 0,
"resources": {
"food": 1,
"wood": 6,
"ore": 6,
"ideas": 5,
"gold": 7,
"mood_tokens": 6,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"city_pieces": {
"academy": null,
"market": null,
"obelisk": null,
"observatory": null,
"fortress": null,
"port": null,
"temple": null,
"wonders": []
},
"mood_state": "Happy",
"activations": 0,
"angry_activation": false,
"player_index": 0,
"position": "A1",
"port_position": null
},
{
"city_pieces": {
"academy": null,
"market": null,
"obelisk": null,
"observatory": 0,
"fortress": null,
"port": null,
"temple": null,
"wonders": []
},
"mood_state": "Neutral",
"activations": 9,
"angry_activation": false,
"player_index": 0,
"position": "C2",
"port_position": null
}
],
"units": [
{
"player_index": 0,
"position": "C2",
"unit_type": "Infantry",
"movement_restriction": "None",
"transporter_position": null,
"id": 0
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Cavalry",
"movement_restriction": "None",
"transporter_position": null,
"id": 1
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Leader",
"movement_restriction": "None",
"transporter_position": null,
"id": 2
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Elephant",
"movement_restriction": "None",
"transporter_position": null,
"id": 3
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"transporter_position": null,
"id": 4
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"transporter_position": null,
"id": 5
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"transporter_position": null,
"id": 6
},
{
"player_index": 0,
"position": "C2",
"unit_type": "Settler",
"movement_restriction": "None",
"transporter_position": null,
"id": 7
}
],
"civilization": "test0",
"active_leader": null,
"available_leaders": [],
"advances": [
"Farming",
"Mining",
"Math"
],
"unlocked_special_advance": [],
"wonders": [],
"wonders_build": 0,
"leader_position": null,
"game_event_tokens": 2,
"influenced_buildings": 0,
"completed_objectives": [],
"captured_leaders": [],
"event_victory_points": 0.0,
"wonder_cards": [],
"available_settlements": 7,
"available_buildings": {
"academies": 5,
"markets": 5,
"obelisks": 5,
"observatories": 4,
"fortresses": 5,
"ports": 5,
"temples": 5
},
"available_units": {
"settlers": 0,
"infantry": 15,
"ships": 4,
"cavalry": 3,
"elephants": 3,
"leaders": 0
},
"collect_options": [
[
"Mountain",
[
{
"food": 0,
"wood": 0,
"ore": 1,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Fertile",
[
{
"food": 1,
"wood": 0,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Forest",
[
{
"food": 0,
"wood": 1,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
]
],
"next_unit_id": 8
},
{
"name": null,
"id": 1,
"resources": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"city_pieces": {
"academy": null,
"market": null,
"obelisk": null,
"observatory": null,
"fortress": null,
"port": null,
"temple": null,
"wonders": []
},
"mood_state": "Angry",
"activations": 2,
"angry_activation": false,
"player_index": 1,
"position": "C1",
"port_position": null
}
],
"units": [
{
"player_index": 1,
"position": "C1",
"unit_type": "Infantry",
"movement_restriction": "None",
"transporter_position": null,
"id": 0
},
{
"player_index": 1,
"position": "C1",
"unit_type": "Infantry",
"movement_restriction": "None",
"transporter_position": null,
"id": 1
}
],
"civilization": "test1",
"active_leader": null,
"available_leaders": [],
"advances": [
"Farming",
"Mining"
],
"unlocked_special_advance": [],
"wonders": [],
"wonders_build": 0,
"leader_position": null,
"game_event_tokens": 3,
"influenced_buildings": 0,
"completed_objectives": [],
"captured_leaders": [],
"event_victory_points": 0.0,
"wonder_cards": [],
"available_settlements": 7,
"available_buildings": {
"academies": 5,
"markets": 5,
"obelisks": 5,
"observatories": 5,
"fortresses": 5,
"ports": 5,
"temples": 5
},
"available_units": {
"settlers": 4,
"infantry": 14,
"ships": 4,
"cavalry": 4,
"elephants": 4,
"leaders": 1
},
"collect_options": [
[
"Mountain",
[
{
"food": 0,
"wood": 0,
"ore": 1,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Fertile",
[
{
"food": 1,
"wood": 0,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
],
[
"Forest",
[
{
"food": 0,
"wood": 1,
"ore": 0,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
]
]
],
"next_unit_id": 2
}
],
"map": {
"tiles": [
[
"A1",
"Fertile"
],
[
"A2",
"Water"
],
[
"A3",
{
"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": [
{
"Playing": {
"IncreaseHappiness": {
"happiness_increases": [
[
"A1",
0
],
[
"C2",
1
]
]
}
}
},
{
"Playing": {
"Advance": {
"advance": "Math",
"payment": {
"food": 0,
"wood": 0,
"ore": 0,
"ideas": 2,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
}
}
}
},
{
"Playing": {
"Construct": {
"city_position": "C2",
"city_piece": "Observatory",
"payment": {
"food": 1,
"wood": 1,
"ore": 1,
"ideas": 0,
"gold": 0,
"mood_tokens": 0,
"culture_tokens": 0
},
"port_position": null,
"temple_bonus": null
}
}
}
],
"action_log_index": 3,
"log": [
"The game has started",
"Age 1 has started",
"Round 1/3",
"Player1 increased happiness in the city at C2 by 1 steps, making it Happy",
"Player1 payed 2 ideas to get the Math advance",
"Player1 payed 1 food, 1 wood and 1 ore to construct a Observatory in the city at C2 making it Neutral"
],
"undo_limit": 0,
"played_once_per_turn_actions": [],
"actions_left": 0,
"successful_cultural_influence": false,
"round": 1,
"age": 1,
"messages": [
"The game has started"
],
"dice_roll_outcomes": [
1,
1,
10,
10,
10,
10,
10,
10,
10,
10
],
"dice_roll_log": [],
"dropped_players": [],
"wonders_left": [
"X"
],
"wonder_amount_left": 1,
"undo_context_stack": [
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
},
{
"Recruit": {
"replaced_units": [],
"replaced_leader": null
}
}
]
}