package game import ( "strings" "testing" ) func TestCrew(t *testing.T) { mapDef := `map: |1- HST HSF TSW symbols: T: tower H: house F: farm S: street W: deep water ` s := NewState() r := strings.NewReader(mapDef) s.Map, _ = readMap(r) s.AddNewPlayer("player", NewDeck()) p := s.Players[0] f := NewUnit(NewCard("nautics/fisher"), s.Map.TileAt(Position{2, 2}), p) s.addPermanent(f) a := NewUnit(NewCard("base/archer"), s.Map.TileAt(Position{1, 1}), p) s.addPermanent(a) sword := newEquipmentFromPath("base/sword", s.Map.TileAt(Position{0, 1}), p) s.addPermanent(sword) movePermanent(a, f.Tile()) if len(f.Pile()) != 1 { t.Fatalf("fisher's pile size is not 1") } if f.Pile()[0] != a { t.Fatalf("fisher's pile does not contain the archer") } if a.Tile() != nil { t.Fatalf("piled archer has still a tile %v", a.Tile()) } for r, d := range f.Attack.attacks { if d != a.Attack.attacks[r] { t.Fatalf("fisher's attack %d is not equal to the archer's attack %d at range %d", d, a.Attack.attacks[r], r) } } if INVALID_ATTACK(f.Attack) { t.Fatalf("fisher has an invalid attack") } if a.Attackable() { t.Fatalf("Piled archer is attackable") } if len(a.AttackableTiles(s.Map)) != 0 { t.Fatalf("Piled archer has attackable tiles") } movePermanent(a, s.Map.TileAt(Position{1, 1})) if len(f.Pile()) != 0 { t.Fatalf("fisher's pile is not empty") } if !INVALID_ATTACK(f.Attack) { t.Fatalf("fisher has still a valid atack") } addPermanentToPile(a, sword) if a.Attack.attacks[0] != 2 { t.Fatalf("archer's mele attack is not 2") } }