server/gamedata/npc_visuals_test.go (2192B)
1 package gamedata 2 3 import ( 4 "reflect" 5 "testing" 6 ) 7 8 func TestOfficerUniformsCoverBothSexesAtEveryPost(t *testing.T) { 9 profiles := map[string]struct { 10 monster, head, helmet uint32 11 }{ 12 "MACA": {26151, 40171, 20038}, 13 "FECA": {26137, 40209, 20055}, 14 "MALI": {26088, 40687, 20106}, 15 "FELI": {26076, 40635, 20089}, 16 "FECO": {26090, 40629, 20089}, 17 "MACO": {26088, 40687, 20106}, 18 } 19 20 counts := make(map[string]int) 21 for id, group := range NPCGroups { 22 profile, officer := profiles[group.TemplateCode] 23 if !officer { 24 continue 25 } 26 counts[group.TemplateCode]++ 27 want := NPCVisual{ 28 Head: profile.head, 29 Textures: [][2]uint32{{0, 15806}, {1, 15809}, {2, 15807}, {3, 15808}, {4, 15805}}, 30 Meshes: [][4]uint32{{0, profile.helmet, 0, 2}, {0, profile.head, 0, 4}, {1, 35566, 0, 2}}, 31 } 32 33 if group.MonsterData != profile.monster || !reflect.DeepEqual(group.Visual, want) { 34 t.Errorf("officer %s (%s) lacks its body-specific uniform: %+v", id, group.TemplateCode, group.Visual) 35 } 36 } 37 if !reflect.DeepEqual(counts, map[string]int{"MACA": 35, "FECA": 8, "MALI": 52, "FELI": 15, "FECO": 25, "MACO": 21}) { 38 t.Fatal("officer population changed", counts) 39 } 40 } 41 42 func TestRecoveredNPCVisualsHaveBoundedPopulationAssignments(t *testing.T) { 43 counts := make(map[string]int) 44 45 for id, group := range NPCGroups { 46 if group.Visual.Head == 0 { 47 continue 48 } 49 counts[group.TemplateCode]++ 50 if len(NPCOutfits[id]) != 0 || len(group.Visual.Textures) != 5 || len(group.Visual.Meshes) == 0 { 51 t.Fatal("recovered appearance conflicts with equipment or lacks resources", id) 52 } 53 } 54 55 if len(counts) != 14 || counts["MACA"] != 35 || counts["MALI"] != 52 || counts["FECA"] != 8 || counts["FELI"] != 15 || 56 counts["FECO"] != 25 || counts["MACO"] != 21 || counts["FEEL"] != 8 || counts["MAEL"] != 21 || counts["CSBI"] != 3 || 57 counts["BQAU"] != 4 || counts["BQPW"] != 3 || counts["BQWR"] != 5 || counts["BTMV"] != 1 || counts["TAIL"] != 4 { 58 t.Fatal("appearance coverage differs from the original-post and population-code matches", counts) 59 } 60 if NPCGroups["950/district/1/fixed/0"].Visual.Head != 0 { 61 t.Fatal("modern vendor appearance was assigned without matching evidence") 62 } 63 }