You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.0 KiB
Go

package model
import "testing"
func TestSumGoldFromLootDrops(t *testing.T) {
drops := []LootDrop{
{ItemType: "gold", GoldAmount: 30, Rarity: RarityCommon},
{ItemType: "gold", GoldAmount: 12, Rarity: RarityCommon},
{ItemType: "main_hand", ItemName: "Blade", Rarity: RarityRare},
}
if g := SumGoldFromLootDrops(drops); g != 42 {
t.Fatalf("SumGoldFromLootDrops: want 42, got %d", g)
}
}
func TestLootDropsToLootItems_skipsGold_includesGearAndPotion(t *testing.T) {
drops := []LootDrop{
{ItemType: "gold", GoldAmount: 99, Rarity: RarityCommon},
{ItemType: "potion", Rarity: RarityCommon},
{ItemType: "chest", ItemName: "Chainmail", Rarity: RarityUncommon},
{ItemType: "head", ItemName: "", Rarity: RarityCommon}, // no name → omitted
}
items := LootDropsToLootItems(drops)
if len(items) != 2 {
t.Fatalf("want 2 loot lines (potion + chest), got %d: %+v", len(items), items)
}
if items[0].ItemType != "potion" || items[1].ItemType != "chest" || items[1].Name != "Chainmail" {
t.Fatalf("unexpected items: %+v", items)
}
}