-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscience.rs
110 lines (103 loc) · 3.31 KB
/
science.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
use crate::ability_initializer::AbilityInitializerSetup;
use crate::advance::Bonus::CultureToken;
use crate::advance::{Advance, AdvanceBuilder};
use crate::city_pieces::Building::Observatory;
use crate::content::advances::{advance_group_builder, AdvanceGroup, METALLURGY};
use crate::content::custom_phase_actions::ResourceRewardRequest;
use crate::payment::PaymentOptions;
use crate::resource::ResourceType;
pub(crate) fn science() -> AdvanceGroup {
advance_group_builder(
"Science",
vec![math(), astronomy(), medicine(), metallurgy()],
)
}
fn math() -> AdvanceBuilder {
Advance::builder(
"Math",
"Engineering and Roads can be bought at no food cost",
)
.add_player_event_listener(
|event| &mut event.advance_cost,
1,
|i, a, ()| {
if a.name == "Engineering" || a.name == "Roads" {
i.info.log.push("Math reduced the cost to 0".to_string());
i.set_zero();
}
},
)
.with_advance_bonus(CultureToken)
.with_unlocked_building(Observatory)
}
fn astronomy() -> AdvanceBuilder {
Advance::builder(
"Astronomy",
"Navigation and Cartography can be bought at no food cost",
)
.add_player_event_listener(
|event| &mut event.advance_cost,
0,
|i, a, ()| {
if a.name == "Navigation" || a.name == "Cartography" {
i.set_zero();
i.info
.log
.push("Astronomy reduced the cost to 0".to_string());
}
},
)
.with_advance_bonus(CultureToken)
}
fn medicine() -> AdvanceBuilder {
Advance::builder(
"Medicine",
"After recruiting, gain one of the paid resources back",
)
.with_advance_bonus(CultureToken)
.add_resource_request(
|event| &mut event.on_recruit,
0,
|_game, _player_index, recruit| {
let types: Vec<ResourceType> = ResourceType::all()
.into_iter()
.filter(|r| recruit.payment.get(r) > 0 && r.is_resource())
.collect();
if types.is_empty() {
return None;
}
Some(ResourceRewardRequest::new(
PaymentOptions::sum(1, &types),
"Select resource to gain back".to_string(),
))
},
|_game, s| {
let verb = if s.actively_selected {
"selected"
} else {
"gained"
};
vec![format!(
"{} {verb} {} for Medicine Advance",
s.player_name, s.choice
)]
},
)
}
fn metallurgy() -> AdvanceBuilder {
Advance::builder(
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(
|event| &mut event.collect_total,
0,
|i, (),()| {
if i.total.ore >= 2 {
i.total.ore -= 1;
i.total.gold += 1;
i.info.log.push("Metallurgy converted 1 ore to 1 gold".to_string());
}
},
)
}