Masters for a match: the four sides red, green, blue and yellow (side 4 gets its own owner), and start_masters gives every master his core and his starting area
This commit is contained in:
1 parent
35ddfa134c
commit
87890adc53
10 files changed
+132
-9
No files matched your search
+16
-1
@@ -169,7 +169,7 @@ impl Game {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::game::{EK, Job, STEP};
|
||||
use crate::map::idx;
|
||||
use crate::map::{idx, Kind, Owner, mh, mw};
|
||||
|
||||
fn game(seed: u32) -> Game {
|
||||
let mut g = Game::new(seed, 64, 64);
|
||||
@@ -272,4 +272,19 @@ mod tests {
|
||||
let json = serde_json::to_string(&c).unwrap();
|
||||
assert_eq!(serde_json::from_str::<Command>(&json).unwrap(), c);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_match_command_builds_on_the_ground_of_its_own_master() {
|
||||
let mut g = Game::new(13, 96, 128);
|
||||
g.init_fog();
|
||||
assert!(g.start_masters(&[0, 2], 0), "a match of two masters");
|
||||
let home = g.map.t.iter().position(|t| t.kind == Kind::Core && t.owner == Owner::Rival1).expect("the green master got his core");
|
||||
let (cx, cy) = ((home % mw() as usize) as i32, (home / mh() as usize) as i32);
|
||||
let gold = g.gold;
|
||||
g.apply_turn(&[Command { side: 2, seq: 0, act: Act::Room { room: 0, r: Rect::new(cx + 4, cy + 4, cx + 4, cy + 4) } }], 1);
|
||||
let t = &g.map.t[idx(cx + 4, cy + 4)];
|
||||
assert_eq!(t.kind, Kind::Treasury, "he builds on his own ground");
|
||||
assert_eq!(t.owner, Owner::Rival1);
|
||||
assert_eq!(g.gold, gold, "my gold is untouched");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user