Skip to content

Commit 13e44aa

Browse files
committed
fix rituals
1 parent bc0c3e9 commit 13e44aa

7 files changed

+33
-37
lines changed

server/src/log.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub fn format_happiness_increase(
164164
})
165165
.collect::<Vec<String>>();
166166
format!(
167-
"{player_name} paid {} increased happiness in {}",
167+
"{player_name} paid {} to increase happiness in {}",
168168
i.payment,
169169
utils::format_list(&happiness_increases, "no city")
170170
)

server/src/playing_actions.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -522,17 +522,14 @@ pub(crate) fn increase_happiness(game: &mut Game, player_index: usize, i: Increa
522522
}
523523

524524
pub(crate) fn undo_increase_happiness(game: &mut Game, player_index: usize, i: IncreaseHappiness) {
525-
let mut cost = 0;
526525
let player = &mut game.players[player_index];
527526
for (city_position, steps) in i.happiness_increases {
528-
let city = player.get_city(city_position).expect("Illegal action");
529-
cost += city.size() as u32 * steps;
530527
let city = player.get_city_mut(city_position).expect("Illegal action");
531528
for _ in 0..steps {
532529
city.decrease_mood_state();
533530
}
534531
}
535-
player.gain_resources(ResourcePile::mood_tokens(cost));
532+
player.gain_resources(i.payment);
536533

537534
if let Some(UndoContext::IncreaseHappiness { angry_activations }) =
538535
game.undo_context_stack.pop()

server/tests/game_api_tests.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,6 @@ fn test_increase_happiness_voting() {
715715
);
716716
}
717717

718-
719718
#[test]
720719
fn test_increase_happiness_voting_rituals() {
721720
test_action(
@@ -726,7 +725,7 @@ fn test_increase_happiness_voting_rituals() {
726725
(Position::from_offset("C2"), 1),
727726
(Position::from_offset("B3"), 2),
728727
],
729-
payment: ResourcePile::new(1,0,1,1,1,1,0),
728+
payment: ResourcePile::new(1, 0, 1, 1, 1, 1, 0),
730729
},
731730
))),
732731
0,

server/tests/test_games/increase_happiness.outcome.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@
369369
"The game has started",
370370
"Age 1 has started",
371371
"Round 1/3",
372-
"Player1 increased happiness in the city at C2 by 1 steps, making it Neutral and the city at B3 by 2 steps, making it Happy"
372+
"Player1 paid 5 mood tokens to increase happiness in the city at C2 by 1 steps, making it Neutral and the city at B3 by 2 steps, making it Happy"
373373
],
374374
"undo_limit": 0,
375375
"actions_left": 2,
@@ -444,4 +444,4 @@
444444
}
445445
}
446446
]
447-
}
447+
}

server/tests/test_games/increase_happiness_voting.outcome.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -348,30 +348,30 @@
348348
"Playing": {
349349
"Custom": {
350350
"VotingIncreaseHappiness": {
351-
"happiness_increases": [
352-
[
353-
"C2",
354-
1
351+
"happiness_increases": [
352+
[
353+
"C2",
354+
1
355+
],
356+
[
357+
"B3",
358+
2
359+
]
355360
],
356-
[
357-
"B3",
358-
2
359-
]
360-
],
361-
"payment": {
362-
"mood_tokens": 5
361+
"payment": {
362+
"mood_tokens": 5
363+
}
363364
}
364365
}
365366
}
366367
}
367-
}
368368
],
369369
"action_log_index": 1,
370370
"log": [
371371
"The game has started",
372372
"Age 1 has started",
373373
"Round 1/3",
374-
"Player1 increased happiness in the city at C2 by 1 steps, making it Neutral and the city at B3 by 2 steps, making it Happy using Voting"
374+
"Player1 paid 5 mood tokens to increase happiness in the city at C2 by 1 steps, making it Neutral and the city at B3 by 2 steps, making it Happy using Voting"
375375
],
376376
"undo_limit": 0,
377377
"actions_left": 3,
@@ -446,4 +446,4 @@
446446
}
447447
}
448448
]
449-
}
449+
}

server/tests/test_games/increase_happiness_voting_rituals.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@
139139
"Farming",
140140
"Free Economy",
141141
"Mining",
142-
"Voting",
143-
"Rituals"
142+
"Rituals",
143+
"Voting"
144144
],
145145
"unlocked_special_advance": [],
146146
"wonders_build": [],

server/tests/test_games/increase_happiness_voting_rituals.outcome.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -349,34 +349,34 @@
349349
"Playing": {
350350
"Custom": {
351351
"VotingIncreaseHappiness": {
352-
"happiness_increases": [
353-
[
354-
"C2",
355-
1
352+
"happiness_increases": [
353+
[
354+
"C2",
355+
1
356+
],
357+
[
358+
"B3",
359+
2
360+
]
356361
],
357-
[
358-
"B3",
359-
2
360-
]
361-
],
362-
"payment": {
362+
"payment": {
363363
"food": 1,
364364
"ore": 1,
365365
"ideas": 1,
366366
"gold": 1,
367367
"mood_tokens": 1
368+
}
368369
}
369370
}
370371
}
371372
}
372-
}
373373
],
374374
"action_log_index": 1,
375375
"log": [
376376
"The game has started",
377377
"Age 1 has started",
378378
"Round 1/3",
379-
"Player1 increased happiness in the city at C2 by 1 steps, making it Neutral and the city at B3 by 2 steps, making it Happy using Voting"
379+
"Player1 paid 1 food, 1 ore, 1 idea, 1 gold and 1 mood token to increase happiness in the city at C2 by 1 steps, making it Neutral and the city at B3 by 2 steps, making it Happy using Voting"
380380
],
381381
"undo_limit": 0,
382382
"actions_left": 3,

0 commit comments

Comments
 (0)