aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


server/gamedata/loot_test.go (2961B)


      1 package gamedata_test
      2 
      3 import (
      4 	"ao/server/gamedata"
      5 	"testing"
      6 )
      7 
      8 func TestLootPoolsCoverOriginalFamiliesAtReachableLevels(t *testing.T) {
      9 	covered := make(map[uint32]bool)
     10 	for name, pool := range gamedata.LootPools {
     11 		reachable := make(map[uint32]bool)
     12 		for level, candidates := range pool.Candidates {
     13 			for _, template := range candidates {
     14 				low, high := pool.Quality(template, level)
     15 				if low > high || !gamedata.ItemQualitySupported(template, low) || !gamedata.ItemQualitySupported(template, high) {
     16 					t.Fatal(name, template, level, low, high)
     17 				}
     18 				reachable[template] = true
     19 			}
     20 		}
     21 		for _, template := range pool.Items {
     22 			if !reachable[template] {
     23 				t.Fatal("pool member has no actual population", name, template)
     24 			}
     25 			covered[template] = true
     26 		}
     27 	}
     28 	if len(covered) < 36000 {
     29 		t.Fatal("broad pool coverage regressed", len(covered))
     30 	}
     31 	for _, template := range []uint32{147073, 160840, 147272, 147903, 163097, 203120, 161160, 162725} {
     32 		if !covered[template] {
     33 			t.Fatal("compatible CellAO seed missing", template)
     34 		}
     35 	}
     36 	for _, template := range []uint32{153311, 163990, 70292, 100001, 151405, 206704, 96351, 155172, 154896, 205608, 136622} {
     37 		if covered[template] {
     38 			t.Fatal("internal, issued, summoned or named-only item leaked into ordinary pools", template)
     39 		}
     40 	}
     41 }
     42 
     43 func TestLootPoolQualityDoesNotPromoteLowLevelEnemies(t *testing.T) {
     44 	for _, scenario := range []struct {
     45 		pool      string
     46 		template  uint32
     47 		level     uint16
     48 		low, high uint32
     49 	}{
     50 		{"weapons", 122123, 10, 21, 11}, {"weapons", 122123, 30, 27, 33},
     51 		{"implants", 104087, 1, 1, 2}, {"rare_equipment", 84164, 99, 1, 0},
     52 		{"rare_equipment", 84164, 100, 15, 15}, {"rare_equipment", 201943, 100, 1, 0},
     53 		{"rare_equipment", 201943, 200, 200, 200},
     54 		{"robot_components", 164529, 100, 1, 0}, {"robot_components", 164529, 200, 200, 200},
     55 	} {
     56 		low, high := gamedata.LootPools[scenario.pool].Quality(scenario.template, scenario.level)
     57 		if low != scenario.low || high != scenario.high {
     58 			t.Fatal(scenario, low, high)
     59 		}
     60 	}
     61 }
     62 
     63 func TestLootPopulationsKeepTownsAndTrainingSeparate(t *testing.T) {
     64 	for _, id := range []string{"950/district/2/group/0/authored_point", "950/district/6/fixed/0", "952/district/5/fixed/0", "954/district/5/fixed/0"} {
     65 		if gamedata.NPCLootTables[id] != nil {
     66 			t.Fatal("training table changed", id)
     67 		}
     68 	}
     69 	for _, group := range gamedata.NPCGroups {
     70 		for level, profile := range gamedata.NPCCombatProfiles[group.MonsterData] {
     71 			if level >= group.Levels[0] && level <= group.Levels[1] && group.SupportsCombatProfile(group.MonsterData, profile) && gamedata.NPCLootTables[group.ID] != nil {
     72 				t.Fatal("curated rewards would roll twice", group.ID)
     73 			}
     74 		}
     75 		if group.ShopTemplate != 0 || group.StaticMesh != 0 || group.Name == "Resident" || group.Name == "Bartender" || group.Name == "Guide" {
     76 			if gamedata.NPCLootTables[group.ID] != nil {
     77 				t.Fatal("friendly population admitted", group.ID)
     78 			}
     79 		}
     80 	}
     81 }