- a card lands one tick after its command fires, since the client hashes after LogicTime::increaseTick, not before - answer RequestSectorState immediately except in the two ticks after a firing tick, where a full update would teleport the client past the command it just queued - the old blanket refusal left every card the player tapped silently deleted while it held - carry both pending commands and queued deploys in the same delivery ledger so the quiet window covers what the player actually paid for - add the regression tests for the birth tick and the deferred answer
45 lines
1.6 KiB
Rust
45 lines
1.6 KiB
Rust
use logic::data::{table, LogicDataRef, LogicDataTables};
|
|
use std::path::Path;
|
|
use std::sync::Arc;
|
|
fn tables() {
|
|
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../assets");
|
|
LogicDataTables::install(Arc::new(
|
|
LogicDataTables::load_from_dir(&root).expect("tables"),
|
|
));
|
|
}
|
|
#[test]
|
|
fn a_single_valued_column_is_scaled_not_indexed() {
|
|
tables();
|
|
let spear = LogicDataRef::by_name(table::PROJECTILES, "SpearGoblinProjectile")
|
|
.as_projectile()
|
|
.expect("SpearGoblinProjectile");
|
|
assert_eq!(spear.damage(0), 24);
|
|
assert_eq!(spear.damage(2), 29, "the level that crashed the client");
|
|
assert_eq!(spear.damage(6), 42, "the bot's deck level");
|
|
}
|
|
#[test]
|
|
fn a_tower_scales_at_its_own_percentage() {
|
|
tables();
|
|
let princess = LogicDataRef::by_name(table::BUILDINGS, "PrincessTower")
|
|
.as_character()
|
|
.expect("PrincessTower");
|
|
let base = princess.hitpoints(0);
|
|
assert!(base > 0);
|
|
assert_eq!(princess.hitpoints(1), base * 109 / 100);
|
|
assert_eq!(princess.hitpoints(2), base * (109 * 109 / 100) / 100);
|
|
let king = LogicDataRef::by_name(table::BUILDINGS, "KingTower")
|
|
.as_character()
|
|
.expect("KingTower");
|
|
let king_base = king.hitpoints(0);
|
|
assert_eq!(king.hitpoints(1), king_base * 108 / 100);
|
|
}
|
|
#[test]
|
|
fn an_ordinary_card_scales_at_the_card_percentage() {
|
|
tables();
|
|
let knight = LogicDataRef::by_name(table::CHARACTERS_COMBINED, "Knight")
|
|
.as_character()
|
|
.expect("Knight");
|
|
let base = knight.hitpoints(0);
|
|
assert_eq!(knight.hitpoints(1), base * 110 / 100);
|
|
assert_eq!(knight.hitpoints(3), base * 133 / 100);
|
|
}
|