Unlock summoning and spawn starting imps for every match master, with side-correct worker counting
This commit is contained in:
1 parent
eb11cca8cb
commit
7ed630c6f2
3 files changed
+35
-2
No files matched your search
+9
-1
@@ -138,6 +138,7 @@ pub struct St {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub const RUNE_TOOL: usize = 20; // index of the rune forge tower in ui::TOOLS
|
pub const RUNE_TOOL: usize = 20; // index of the rune forge tower in ui::TOOLS
|
||||||
|
pub const SUMMON_TOOL: usize = 11; // index of summoning in ui::TOOLS
|
||||||
|
|
||||||
pub fn st(k: EK) -> St {
|
pub fn st(k: EK) -> St {
|
||||||
let s = |name, hp, atk, range, speed, interval, wage, bounty| St { name, hp, atk, range, speed, interval, wage, bounty };
|
let s = |name, hp, atk, range, speed, interval, wage, bounty| St { name, hp, atk, range, speed, interval, wage, bounty };
|
||||||
@@ -1123,7 +1124,7 @@ impl Game {
|
|||||||
self.ents.iter().filter(|e| e.alive && e.creature()).count()
|
self.ents.iter().filter(|e| e.alive && e.creature()).count()
|
||||||
}
|
}
|
||||||
pub fn worker_count(&self) -> usize {
|
pub fn worker_count(&self) -> usize {
|
||||||
self.ents.iter().filter(|e| e.alive && !e.hero && e.kind == EK::Worker).count()
|
self.ents.iter().filter(|e| e.alive && !e.hero && e.kind == EK::Worker && e.side == self.me_side && !e.chained).count()
|
||||||
}
|
}
|
||||||
pub fn summon_cost(&self) -> f32 {
|
pub fn summon_cost(&self) -> f32 {
|
||||||
80.0 + 20.0 * (self.worker_count() as f32 - 4.0).max(0.0)
|
80.0 + 20.0 * (self.worker_count() as f32 - 4.0).max(0.0)
|
||||||
@@ -1137,6 +1138,7 @@ impl Game {
|
|||||||
e.id = id;
|
e.id = id;
|
||||||
e.kind = kind;
|
e.kind = kind;
|
||||||
e.hero = hero;
|
e.hero = hero;
|
||||||
|
e.side = self.me_side;
|
||||||
e.x = x;
|
e.x = x;
|
||||||
e.y = y;
|
e.y = y;
|
||||||
e.disp_x = x;
|
e.disp_x = x;
|
||||||
@@ -1377,6 +1379,12 @@ impl Game {
|
|||||||
}
|
}
|
||||||
self.carve_master_area(*side, cores[k]);
|
self.carve_master_area(*side, cores[k]);
|
||||||
self.add_master(*side, cores[k]);
|
self.add_master(*side, cores[k]);
|
||||||
|
self.switch_to(*side);
|
||||||
|
let (cx, cy) = cores[k];
|
||||||
|
// a new master needs the same starting crew side 0 already has
|
||||||
|
for j in 0..4 {
|
||||||
|
self.spawn(EK::Worker, false, cx as f32 - 0.5, cy as f32 + j as f32 * 0.7 + 0.3, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.local_side = local;
|
self.local_side = local;
|
||||||
self.switch_to(local);
|
self.switch_to(local);
|
||||||
|
|||||||
@@ -52,6 +52,15 @@ impl Game {
|
|||||||
if !self.start_masters(sides, local) {
|
if !self.start_masters(sides, local) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// every master has to be able to build his dungeon at once
|
||||||
|
if let Some(v) = self.known.get_mut(crate::game::SUMMON_TOOL) {
|
||||||
|
*v = true;
|
||||||
|
}
|
||||||
|
for m in self.masters.iter_mut() {
|
||||||
|
if let Some(v) = m.known.get_mut(crate::game::SUMMON_TOOL) {
|
||||||
|
*v = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
self.netplay = Some(Netplay::default());
|
self.netplay = Some(Netplay::default());
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@@ -271,6 +280,22 @@ mod tests {
|
|||||||
assert_eq!(a.checksum(), b.checksum());
|
assert_eq!(a.checksum(), b.checksum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_new_match_master_can_summon_at_once() {
|
||||||
|
let mut g = client(24, 2);
|
||||||
|
assert!(g.tool_allowed(crate::game::SUMMON_TOOL), "summoning is known in a match");
|
||||||
|
assert_eq!(g.worker_count(), 4, "a new master starts with his own four imps");
|
||||||
|
let (cx, cy) = core_of(&g, Owner::Rival1);
|
||||||
|
let mana = g.mana;
|
||||||
|
let cost = g.summon_cost();
|
||||||
|
g.queue(Act::Summon { x: cx as f32 - 0.5, y: cy as f32 + 0.5 });
|
||||||
|
let turn = g.take_orders();
|
||||||
|
g.receive_turn(&turn);
|
||||||
|
assert!(cost > 0.0 && g.mana < mana, "summoning costs mana");
|
||||||
|
assert!(g.ents.iter().any(|e| e.kind == crate::game::EK::Worker && e.side == 2 && e.alive), "the summoned imp belongs to the master who summoned it");
|
||||||
|
assert_eq!(g.worker_count(), 5, "the summon counts as the master's own worker");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_client_without_the_next_turn_stands_still_and_its_orders_wait() {
|
fn a_client_without_the_next_turn_stands_still_and_its_orders_wait() {
|
||||||
let mut g = client(22, 0);
|
let mut g = client(22, 0);
|
||||||
|
|||||||
Reference in new issue
Block a user