1
1
use crate :: content:: custom_phase_actions:: new_position_request;
2
- use crate :: game:: Game ;
3
2
use crate :: incident:: { Incident , IncidentBaseEffect , IncidentBuilder } ;
4
- use crate :: player_events:: { IncidentInfo , IncidentTarget } ;
3
+ use crate :: player_events:: IncidentTarget ;
5
4
use crate :: unit:: UnitType ;
6
5
7
6
pub ( crate ) fn population_booms ( ) -> Vec < Incident > {
@@ -13,16 +12,14 @@ pub(crate) fn population_booms() -> Vec<Incident> {
13
12
14
13
fn population_boom ( id : u8 , effect : IncidentBaseEffect ) -> Incident {
15
14
let mut b = Incident :: builder ( id, "Population Boom" , "-" , effect) ;
16
- b = select_settler ( b, 13 , |_game, player, i| {
17
- i. is_active ( IncidentTarget :: ActivePlayer , player)
18
- } ) ;
15
+ b = select_settler ( b, 13 , IncidentTarget :: ActivePlayer ) ;
19
16
select_player_to_gain_settler ( b) . build ( )
20
17
}
21
18
22
19
pub ( crate ) fn select_player_to_gain_settler ( mut b : IncidentBuilder ) -> IncidentBuilder {
23
20
b = b. add_incident_player_request (
24
21
"Select a player to gain 1 settler" ,
25
- |p| p. available_units ( ) . settlers > 0 && !p. cities . is_empty ( ) ,
22
+ |p, _ | p. available_units ( ) . settlers > 0 && !p. cities . is_empty ( ) ,
26
23
12 ,
27
24
|game, c| {
28
25
game. add_info_log_item ( & format ! (
@@ -32,22 +29,16 @@ pub(crate) fn select_player_to_gain_settler(mut b: IncidentBuilder) -> IncidentB
32
29
game. current_event_mut ( ) . selected_player = Some ( c. choice ) ;
33
30
} ,
34
31
) ;
35
- select_settler ( b, 11 , |game, player, _| {
36
- game. current_event ( ) . selected_player == Some ( player)
37
- } )
32
+ select_settler ( b, 11 , IncidentTarget :: SelectedPlayer )
38
33
}
39
34
40
- fn select_settler (
41
- b : IncidentBuilder ,
42
- priority : i32 ,
43
- pred : impl Fn ( & Game , usize , & IncidentInfo ) -> bool + ' static + Clone ,
44
- ) -> IncidentBuilder {
35
+ fn select_settler ( b : IncidentBuilder , priority : i32 , target : IncidentTarget ) -> IncidentBuilder {
45
36
b. add_incident_position_request (
46
- IncidentTarget :: AllPlayers ,
37
+ target ,
47
38
priority,
48
- move |game, player_index, incident | {
39
+ move |game, player_index, _ | {
49
40
let p = game. get_player ( player_index) ;
50
- if pred ( game , player_index , incident ) && p. available_units ( ) . settlers > 0 {
41
+ if p. available_units ( ) . settlers > 0 {
51
42
Some ( new_position_request (
52
43
p. cities . iter ( ) . map ( |c| c. position ) . collect ( ) ,
53
44
1 ..=1 ,
0 commit comments