| 1247 | |
| 1248 | #[inline(never)] |
| 1249 | pub fn print_game_ansi(&self) { |
| 1250 | let log_unit = |unit: &Unit| { |
| 1251 | let symbol = match unit.unit_type() { |
| 1252 | Worker => "W", |
| 1253 | Knight => "K", |
| 1254 | Ranger => "R", |
| 1255 | Mage => "M", |
| 1256 | Healer => "H", |
| 1257 | Factory => "=", |
| 1258 | Rocket => "^", |
| 1259 | }; |
| 1260 | let mut style = Style::new(); |
| 1261 | |
| 1262 | if let Ok(mc) = unit.movement_heat() { |
| 1263 | if mc >= 10 { |
| 1264 | style = style.underline(); |
| 1265 | } |
| 1266 | } |
| 1267 | if let Ok(ac) = unit.ability_heat() { |
| 1268 | if ac >= 10 { |
| 1269 | style = style.strikethrough(); |
| 1270 | } |
| 1271 | } |
| 1272 | if unit.unit_type().is_structure() && !unit.structure_is_built().unwrap() { |
| 1273 | style = style.reverse(); |
| 1274 | } |
| 1275 | if unit.team() == Red { |
| 1276 | style = style.fg(Colour::Red); |
| 1277 | } else { |
| 1278 | style = style.fg(Colour::Blue); |
| 1279 | } |
| 1280 | style.paint(symbol) |
| 1281 | }; |
| 1282 | |
| 1283 | let earth_map = &self.world.planet_maps[&Earth]; |
| 1284 | let earth_units = &self.world.planet_states.get(&Earth); |
| 1285 | let mars_map = &self.world.planet_maps[&Mars]; |
| 1286 | let mars_units = &self.world.planet_states.get(&Mars); |
| 1287 | let bg = Style::new().on(Colour::White); |
| 1288 | |
| 1289 | let ew = earth_map.width; |
| 1290 | let eh = earth_map.height; |
| 1291 | let mw = mars_map.width; |
| 1292 | let mh = mars_map.height; |
| 1293 | |
| 1294 | let eb = Style::new().fg(Colour::Green); |
| 1295 | let mb = Style::new().fg(Colour::Yellow); |
| 1296 | |
| 1297 | let strike = self.world.asteroids.pattern.get(&self.round()); |
| 1298 | let sb = Style::new().on(Fixed(11)); |
| 1299 | |
| 1300 | let edge = |st: Style, w: usize| { |
| 1301 | print!("{}", st.paint("+")); |
| 1302 | for _ in 0..w { |
| 1303 | print!("{}", st.paint("-")); |
| 1304 | } |
| 1305 | print!("{}", st.paint("+")); |
| 1306 | }; |