server/gamedata/npc_outfits_test.go (2384B)
1 package gamedata 2 3 import ( 4 "reflect" 5 "testing" 6 ) 7 8 func TestReviewedCivilianOutfitsCoverEveryPlacement(t *testing.T) { 9 uniform := []NPCOutfitItem{{82912, 21}, {82919, 23}, {82919, 25}, {82911, 27}, {82913, 30}} 10 rustic := []NPCOutfitItem{{82102, 21}, {82092, 23}, {82092, 25}, {82101, 27}, {82100, 30}} 11 profiles := map[string]struct { 12 monster uint32 13 items []NPCOutfitItem 14 }{ 15 "OFPO": {26092, uniform}, "OTGD": {26076, uniform}, "NEGD": {26076, uniform}, 16 "CLGD": {26076, rustic}, "H320": {26135, rustic}, "H476": {26076, rustic}, 17 "H410": {26088, rustic}, "H660": {26088, rustic}, 18 } 19 20 // Check the loaded population, including authored points with multiple actors. 21 counts := make(map[string]int) 22 for id, group := range NPCGroups { 23 profile, reviewed := profiles[group.TemplateCode] 24 if !reviewed { 25 continue 26 } 27 counts[group.TemplateCode] += len(group.Positions) 28 if group.MonsterData != profile.monster || !reflect.DeepEqual(NPCOutfits[id], profile.items) || group.Visual.Head != 0 { 29 t.Errorf("civilian %s (%s) lacks its reviewed outfit", id, group.TemplateCode) 30 } 31 } 32 if !reflect.DeepEqual(counts, map[string]int{"OFPO": 11, "OTGD": 61, "NEGD": 23, "CLGD": 49, "H320": 4, "H476": 30, "H410": 4, "H660": 14}) { 33 t.Fatal("reviewed civilian population changed", counts) 34 } 35 } 36 37 func TestEliteGuardVisualsFillUnassignedPosts(t *testing.T) { 38 counts := make(map[string]int) 39 for id, group := range NPCGroups { 40 if group.TemplateCode != "FEEL" && group.TemplateCode != "MAEL" { 41 continue 42 } 43 // Preserve the seven existing item outfits, including their armor bonuses. 44 if len(NPCOutfits[id]) != 0 { 45 counts["equipped"]++ 46 if group.Visual.Head != 0 { 47 t.Fatal("visual fallback replaced an explicit item outfit", id) 48 } 49 continue 50 } 51 counts[group.TemplateCode]++ 52 head, helmet := uint32(40629), uint32(20089) 53 if group.TemplateCode == "MAEL" { 54 head, helmet = 40111, 20005 55 } 56 want := NPCVisual{ 57 Head: head, Textures: [][2]uint32{{0, 15806}, {1, 15809}, {2, 15807}, {3, 15808}, {4, 15805}}, 58 Meshes: [][4]uint32{{0, helmet, 0, 2}, {0, head, 0, 4}}, 59 } 60 if !reflect.DeepEqual(group.Visual, want) { 61 t.Errorf("elite guard %s lacks its body-specific armor: %+v", id, group.Visual) 62 } 63 } 64 if !reflect.DeepEqual(counts, map[string]int{"FEEL": 8, "MAEL": 21, "equipped": 7}) { 65 t.Fatal("elite guard population changed", counts) 66 } 67 }