server/implant_catalog_test.go (22986B)
1 package main 2 3 import ( 4 "ao/server/gamedata" 5 "bytes" 6 "encoding/binary" 7 "fmt" 8 "reflect" 9 "slices" 10 "testing" 11 "time" 12 ) 13 14 func newCatalogImplantWorld(t *testing.T, template uint32) (*server, *combatTestConn) { 15 t.Helper() 16 world, conn := newEquipmentWorld(t) 17 player, client := world.characters[1], world.clients[1] 18 player.stats.NanoAiding.Treatment = 9 19 if err := world.saveUser(player); err != nil { 20 t.Fatal(err) 21 } 22 for _, id := range []uint32{43552, template} { 23 if granted, err := world.grantItem(player, id); err != nil || !granted { 24 t.Fatal(granted, err) 25 } 26 } 27 client.selectedTarget = [2]uint32{50000, 1} 28 if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 65, 1)[20:]); err != nil { 29 t.Fatal(err) 30 } 31 conn.packets = nil 32 return world, conn 33 } 34 35 func TestImplantCatalogAdmissionMatchesCompleteAuthoredContracts(t *testing.T) { 36 // Counts come from the complete original-payload audit, including unknown sections. 37 accepted := make(map[uint32]int) 38 total := 0 39 40 for id, definition := range gamedata.ItemTemplates { 41 if definition.HeaderWords[0] != 51022 || itemStat(definition, 76) != 3 { 42 continue 43 } 44 total++ 45 inventory := playerInventory{LastID: 1, Items: []ownedItem{{ID: 1, Type: 51022, Template: id, 46 Quality: *definition.Quality, Slot: 32 + itemStat(definition, 88), Count: 1}}} 47 if inventory.validate() == nil { 48 accepted[*definition.Quality]++ 49 } 50 } 51 52 if total != 44356 || !reflect.DeepEqual(accepted, map[uint32]int{1: 9996, 200: 9993, 201: 9861, 300: 9862}) { 53 t.Fatal("implant admission diverged from the original complete-effect audit", total, accepted) 54 } 55 } 56 57 func TestCatalogImplantsUseEveryAnatomicalSlotAndPreserveIdentity(t *testing.T) { 58 for _, fixture := range []struct { 59 template, slot, stat uint32 60 bonus int32 61 }{ 62 {101103, 33, 108, 2}, {101119, 34, 135, 2}, {101135, 35, 117, 2}, 63 {101151, 36, 94, 3}, {101167, 37, 107, 2}, {101183, 38, 93, 3}, 64 {101199, 39, 101, 2}, {101215, 40, 90, 3}, {101231, 41, 168, 2}, 65 {101247, 42, 97, 3}, {101263, 43, 91, 3}, {101279, 44, 95, 3}, {101295, 45, 153, 2}, 66 } { 67 t.Run(fmt.Sprint(fixture.slot), func(t *testing.T) { 68 world, owner := newCatalogImplantWorld(t, fixture.template) 69 player, client := world.characters[1], world.clients[1] 70 observer := &combatTestConn{} 71 world.characters[2] = &character{id: 2, playfield: 950, health: 100} 72 world.clients[2] = &worldClient{id: 2, players: map[uint32]bool{1: true}, conn: observer, target: true, ready: true} 73 before := slices.Clone(player.inventory.Items) 74 75 started := time.Now() 76 if err := world.handleInventory(client, inventoryMovePacket(1, 66, fixture.slot)[20:]); err != nil { 77 t.Fatal(err) 78 } 79 if client.equipment == nil || client.equipment.readyAt.Before(started.Add(100*time.Millisecond)) || client.equipment.readyAt.After(time.Now().Add(100*time.Millisecond)) { 80 t.Fatal("catalog implant did not start its inherited equip delay") 81 } 82 world.advanceEquipment(client.equipment.readyAt.Add(-time.Nanosecond)) 83 if !reflect.DeepEqual(player.inventory.Items, before) || len(owner.packets) != 0 || len(observer.packets) != 0 { 84 t.Fatal("implant changed before the equip deadline") 85 } 86 world.advanceEquipment(client.equipment.readyAt) 87 restored := newTestInventoryServer(t).characters[1] 88 if restored.inventory.Items[2].Slot != fixture.slot || restored.equipmentBonus(fixture.stat) != fixture.bonus || len(equippedItemPackets(restored)) != 1 { 89 t.Fatal("cold restore lost the implant, its bonus or observer wear", restored.inventory.Items) 90 } 91 if len(owner.packets) != 2 || len(observer.packets) != 1 || !bytes.Equal(owner.packets[1][16:], observer.packets[0][16:]) || 92 binary.BigEndian.Uint32(owner.packets[1][49:53]) != 103 || binary.BigEndian.Uint32(owner.packets[1][53:57]) != fixture.slot { 93 t.Fatal("owner/observer wear used the wrong implant page or slot") 94 } 95 player.stats.NanoAiding.Treatment = 0 96 if player.equipmentBonus(fixture.stat) != fixture.bonus { 97 t.Fatal("implant bonuses incorrectly became overequipped") 98 } 99 if err := world.handleInventory(client, itemMovePacket(1, fixture.slot, 111)[20:]); err != nil { 100 t.Fatal(err) 101 } 102 if client.equipment == nil { 103 t.Fatal("removal incorrectly rechecked installation requirements") 104 } 105 world.advanceEquipment(client.equipment.readyAt) 106 removed := newTestInventoryServer(t).characters[1] 107 108 if !reflect.DeepEqual(player.inventory.Items, before) || !reflect.DeepEqual(removed.inventory.Items, before) || player.equipmentBonus(fixture.stat) != 0 || 109 len(owner.packets) != 4 || len(observer.packets) != 2 || binary.BigEndian.Uint32(observer.packets[1][45:49]) != 7 || 110 binary.BigEndian.Uint32(owner.packets[3][29:33]) != 103 || binary.BigEndian.Uint32(owner.packets[3][33:37]) != fixture.slot { 111 t.Fatal("implant removal lost identity, retained its bonus or used an incorrect source page") 112 } 113 }) 114 } 115 } 116 117 func TestImplantSurgeryRevalidatesOutsideChestSlot(t *testing.T) { 118 for _, scenario := range []string{"no access", "expired at completion", "requirements changed", "failed save", "wrong removal page", "full inventory"} { 119 t.Run(scenario, func(t *testing.T) { 120 world, conn := newCatalogImplantWorld(t, 101295) 121 player, client := world.characters[1], world.clients[1] 122 if scenario == "wrong removal page" || scenario == "full inventory" { 123 world.handleInventory(client, inventoryMovePacket(1, 66, 45)[20:]) 124 world.advanceEquipment(client.equipment.readyAt) 125 } 126 if scenario == "full inventory" { 127 for { 128 granted, err := world.grantItem(player, 121567) 129 if err != nil { 130 t.Fatal(err) 131 } 132 if !granted { 133 break 134 } 135 } 136 } 137 if scenario == "no access" { 138 player.implantChangesUntil = time.Now().Add(-time.Second) 139 } 140 before := slices.Clone(player.inventory.Items) 141 stored, _ := readTestItemStore(world) 142 conn.packets = nil 143 144 request := inventoryMovePacket(1, 66, 45) 145 if scenario == "wrong removal page" || scenario == "full inventory" { 146 request = itemMovePacket(1, 45, 111) 147 if scenario == "wrong removal page" { 148 binary.BigEndian.PutUint32(request[36:40], 102) 149 } 150 } 151 err := world.handleInventory(client, request[20:]) 152 if scenario == "expired at completion" || scenario == "requirements changed" || scenario == "failed save" { 153 if client.equipment == nil { 154 t.Fatal("initial valid implant move did not start") 155 } 156 if scenario == "expired at completion" { 157 player.implantChangesUntil = client.equipment.readyAt 158 } else if scenario == "requirements changed" { 159 player.stats.NanoAiding.Treatment = 0 160 } else { 161 failDatabaseWrites(t, world) 162 } 163 world.advanceEquipment(client.equipment.readyAt) 164 } 165 after, _ := readTestItemStore(world) 166 167 if err != nil || client.equipment != nil || !reflect.DeepEqual(player.inventory.Items, before) || !bytes.Equal(stored, after) { 168 t.Fatal("rejected surgery outside the chest slot changed item identity or placement", err) 169 } 170 for _, packet := range conn.packets { 171 if binary.BigEndian.Uint32(packet[16:20]) == 0x35505644 { 172 t.Fatal("rejected surgery published wear effects") 173 } 174 } 175 }) 176 } 177 } 178 179 func TestCatalogImplantsRejectIncompleteEffectsAsWholeItems(t *testing.T) { 180 for _, template := range []uint32{ 181 130263, 204649, 181297, 181846, 181321, 182584, 179455, 182822, 180292, 183214, 182 177719, 193040, 204613, 204614, 204647, 204650, 204651, 206246, 183 } { 184 t.Run(fmt.Sprint(template), func(t *testing.T) { 185 world, conn := newCatalogImplantWorld(t, template) 186 player, client := world.characters[1], world.clients[1] 187 player.level = 200 188 for _, field := range player.stats.trainingStats() { 189 *field.value = 5000 190 } 191 before := slices.Clone(player.inventory.Items) 192 stored, _ := readTestItemStore(world) 193 194 err := world.handleInventory(client, inventoryMovePacket(1, 66, 32+itemStat(gamedata.ItemTemplates[template], 88))[20:]) 195 after, _ := readTestItemStore(world) 196 197 if err != nil || client.equipment != nil || !reflect.DeepEqual(player.inventory.Items, before) || !bytes.Equal(stored, after) || len(conn.packets) != 2 { 198 t.Fatal("incomplete implant was admitted or changed ownership", err) 199 } 200 }) 201 } 202 } 203 204 func TestJobeImplantsEnforceAuthoredQualityAndStrictRequirements(t *testing.T) { 205 for _, fixture := range []struct { 206 template, quality uint32 207 level, treatment, stamina uint16 208 bonus int32 209 }{ 210 {191026, 1, 50, 9, 16, 5}, {191027, 200, 100, 1003, 414, -5}, 211 {191028, 201, 150, 999, 426, -5}, {191029, 300, 190, 2049, 1095, -9}, 212 } { 213 for _, scenario := range []string{"accepted", "Treatment equality", "stamina equality", "title equality", "unauthored quality"} { 214 t.Run(fmt.Sprintf("%d/%s", fixture.template, scenario), func(t *testing.T) { 215 world, _ := newCatalogImplantWorld(t, fixture.template) 216 player, client := world.characters[1], world.clients[1] 217 player.level, player.stats.NanoAiding.Treatment, player.stats.Abilities.Stamina = fixture.level, fixture.treatment, fixture.stamina 218 switch scenario { 219 case "Treatment equality": 220 player.stats.NanoAiding.Treatment-- 221 case "stamina equality": 222 player.stats.Abilities.Stamina-- 223 case "title equality": 224 player.level-- 225 case "unauthored quality": 226 player.inventory.Items[2].Quality++ 227 } 228 if err := world.saveUser(player); err != nil { 229 t.Fatal(err) 230 } 231 if err := world.saveInventory(player, player.inventory); err != nil { 232 t.Fatal(err) 233 } 234 235 err := world.handleInventory(client, inventoryMovePacket(1, 66, 43)[20:]) 236 if client.equipment != nil { 237 world.advanceEquipment(client.equipment.readyAt) 238 } 239 restored := newTestInventoryServer(t).characters[1] 240 241 if err != nil || (player.inventory.Items[2].Slot == 43) != (scenario == "accepted") || !reflect.DeepEqual(player.inventory.Items, restored.inventory.Items) { 242 t.Fatal("Jobe implant ignored its strict endpoint requirements or lost its instance", err) 243 } 244 if scenario == "accepted" && (restored.equipmentBonus(382) != fixture.bonus || restored.inventory.Items[2].Quality != fixture.quality) { 245 t.Fatal("Jobe modifier changed sign or authored quality") 246 } 247 }) 248 } 249 } 250 } 251 252 func TestRealJobeModifierChangesNewLocksButNotExistingDeadlines(t *testing.T) { 253 for _, fixture := range []struct { 254 template uint32 255 level, treatment uint16 256 stamina uint16 257 seconds int 258 }{{191026, 50, 9, 16, 41}, {191027, 100, 1003, 414, 38}, {191029, 190, 2049, 1095, 36}} { 259 t.Run(fmt.Sprint(fixture.template), func(t *testing.T) { 260 world, conn := newCatalogImplantWorld(t, fixture.template) 261 player, client := world.characters[1], world.clients[1] 262 player.level, player.stats.NanoAiding.Treatment, player.stats.Abilities.Stamina = fixture.level, fixture.treatment, fixture.stamina 263 player.stats.NanoAiding.FirstAid = 6 264 if err := world.saveUser(player); err != nil { 265 t.Fatal(err) 266 } 267 world.handleInventory(client, inventoryMovePacket(1, 66, 43)[20:]) 268 world.advanceEquipment(client.equipment.readyAt) 269 if granted, err := world.grantItem(player, 85366); err != nil || !granted { 270 t.Fatal(granted, err) 271 } 272 clinicDeadline := player.skillLocks[124] 273 conn.packets = nil 274 started := time.Now() 275 276 err := world.handleOwnedItemUse(client, backpackUseRequest(1, 66, 2)[20:]) 277 deadline := player.skillLocks[123] 278 world.handleInventory(client, itemMovePacket(1, 43, 111)[20:]) 279 if client.equipment == nil { 280 t.Fatal("Jobe modifier could not be removed during an independent skill lock") 281 } 282 world.advanceEquipment(client.equipment.readyAt) 283 restored := newTestInventoryServer(t).characters[1] 284 285 if err != nil || deadline.Before(started.Add(time.Duration(fixture.seconds)*time.Second)) || deadline.After(time.Now().Add(time.Duration(fixture.seconds)*time.Second)) || 286 !player.skillLocks[123].Equal(deadline) || !restored.skillLocks[123].Equal(deadline) || !restored.skillLocks[124].Equal(clinicDeadline) || 287 restored.equipmentBonus(382) != 0 || restored.inventory.Items[2].ID != 3 || restored.inventory.Items[2].Slot != 67 || restored.inventory.Items[3].ID != 4 || restored.inventory.Items[3].Count != 24 { 288 t.Fatalf("real Jobe use/removal: duration=%v expected=%ds live=%v cold=%v clinic=%v items=%+v err=%v", deadline.Sub(started), fixture.seconds, player.skillLocks, restored.skillLocks, clinicDeadline, restored.inventory.Items, err) 289 } 290 starts := 0 291 for _, packet := range conn.packets { 292 if binary.BigEndian.Uint32(packet[16:20]) == 0x5e477770 && binary.BigEndian.Uint32(packet[29:33]) == 170 { 293 starts++ 294 if binary.BigEndian.Uint32(packet[41:45]) != 123 || binary.BigEndian.Uint32(packet[45:49]) != 40 { 295 t.Fatal("new lock sent scaled seconds to the native client") 296 } 297 } 298 } 299 if starts != 1 { 300 t.Fatal("new use did not publish exactly one raw First Aid lock") 301 } 302 }) 303 } 304 } 305 306 func TestMultiSlotImplantsUseTheirFullMasksAndBreedRequirements(t *testing.T) { 307 for _, fixture := range []struct{ template, slot uint32 }{{164831, 36}, {164831, 38}, {164833, 39}, {164833, 41}, {204980, 39}, {204980, 41}} { 308 for _, breed := range []uint16{1, 4} { 309 t.Run(fmt.Sprintf("%d/%d/breed%d", fixture.template, fixture.slot, breed), func(t *testing.T) { 310 world, _ := newCatalogImplantWorld(t, fixture.template) 311 player, client := world.characters[1], world.clients[1] 312 appearance := unpackAppearance(player.appearance) 313 appearance.Breed = breed 314 player.appearance = appearance.packed() 315 if err := world.saveUser(player); err != nil { 316 t.Fatal(err) 317 } 318 319 err := world.handleInventory(client, inventoryMovePacket(1, 66, fixture.slot)[20:]) 320 if client.equipment != nil { 321 world.advanceEquipment(client.equipment.readyAt) 322 } 323 restored := newTestInventoryServer(t).characters[1] 324 325 if err != nil || (player.inventory.Items[2].Slot == fixture.slot) != (breed == 4 || fixture.template == 204980) || 326 !reflect.DeepEqual(player.inventory.Items, restored.inventory.Items) { 327 t.Fatal("implant used only its default slot or ignored breed equality", err) 328 } 329 if fixture.template == 204980 && (restored.maximumNCU() != 9 || restored.inventory.equipmentBonus(221) != 1) { 330 t.Fatal("multi-slot NCU implant lost one of its complete bonuses") 331 } 332 }) 333 } 334 } 335 } 336 337 func TestImplantRemovalUsesItsOwnActionCriteria(t *testing.T) { 338 for _, scenario := range []string{"allowed", "blocked initially", "changed during removal"} { 339 t.Run(scenario, func(t *testing.T) { 340 world, _ := newCatalogImplantWorld(t, 101295) 341 player, client := world.characters[1], world.clients[1] 342 original := gamedata.ItemTemplates[101295] 343 definition := *original 344 definition.Sections = slices.Clone(original.Sections) 345 for index, section := range definition.Sections { 346 if section.Actions != nil { 347 actions := append(slices.Clone(*section.Actions), gamedata.ItemAction{Type: 7, 348 Requirements: []gamedata.ItemRequirement{{Stat: 33, Value: 2, Operator: 0}}}) 349 definition.Sections[index].Actions = &actions 350 } 351 } 352 gamedata.ItemTemplates[101295] = &definition 353 t.Cleanup(func() { gamedata.ItemTemplates[101295] = original }) 354 appearance := unpackAppearance(player.appearance) 355 appearance.Side = 2 356 player.appearance = appearance.packed() 357 world.handleInventory(client, inventoryMovePacket(1, 66, 45)[20:]) 358 world.advanceEquipment(client.equipment.readyAt) 359 player.stats.NanoAiding.Treatment = 0 360 if scenario == "blocked initially" { 361 appearance.Side = 0 362 player.appearance = appearance.packed() 363 } 364 365 err := world.handleInventory(client, itemMovePacket(1, 45, 111)[20:]) 366 if scenario == "changed during removal" { 367 if client.equipment == nil { 368 t.Fatal("initial action7 requirements were not accepted") 369 } 370 appearance.Side = 0 371 player.appearance = appearance.packed() 372 } 373 if client.equipment != nil { 374 world.advanceEquipment(client.equipment.readyAt) 375 } 376 restored := newTestInventoryServer(t).characters[1] 377 378 if err != nil || (player.inventory.Items[2].Slot == 66) != (scenario == "allowed") || 379 !reflect.DeepEqual(player.inventory.Items, restored.inventory.Items) { 380 t.Fatal("removal ignored action7 or incorrectly required action6 again", err) 381 } 382 }) 383 } 384 } 385 386 func TestImplantResourcesSkillsAndAbilitiesApplyOnceAndClampOnRemoval(t *testing.T) { 387 for _, fixture := range []struct { 388 template, slot, stat uint32 389 bonus int32 390 }{ 391 {108466, 37, 1, 7}, {105187, 34, 221, 7}, {107483, 36, 16, 5}, 392 {101253, 42, 100, 6}, {166669, 39, 181, 3}, 393 } { 394 t.Run(fmt.Sprint(fixture.template), func(t *testing.T) { 395 world, _ := newCatalogImplantWorld(t, fixture.template) 396 player, client := world.characters[1], world.clients[1] 397 if fixture.stat == 181 { 398 player.level, player.stats.Abilities.Agility = 50, 16 399 } 400 if err := world.saveUser(player); err != nil { 401 t.Fatal(err) 402 } 403 health, nano, ncu := player.maximumHealth(), player.maximumNano(), player.maximumNCU() 404 ability, skill := player.effectiveAbility(16), player.attackRating() 405 406 world.handleInventory(client, inventoryMovePacket(1, 66, fixture.slot)[20:]) 407 if client.equipment == nil { 408 t.Fatal("resource/ability implant was rejected") 409 } 410 world.advanceEquipment(client.equipment.readyAt) 411 restored := newTestInventoryServer(t).characters[1] 412 if restored.equipmentBonus(fixture.stat) != fixture.bonus || player.equipmentBonus(fixture.stat) != fixture.bonus { 413 t.Fatal("implant modifier was missing or duplicated after cold recovery") 414 } 415 switch fixture.stat { 416 case 1: 417 if restored.maximumHealth() != health+7 { 418 t.Fatal("maximum health did not include the implant once") 419 } 420 case 221: 421 if restored.maximumNano() != nano+7 { 422 t.Fatal("maximum nano did not include the implant once") 423 } 424 case 16: 425 if restored.effectiveAbility(16) != ability+5 { 426 t.Fatal("strength did not include the implant once") 427 } 428 case 100: 429 if restored.attackRating() != skill+6 { 430 t.Fatal("Martial Arts did not affect the attack rating once") 431 } 432 case 181: 433 if restored.maximumNCU() != ncu+3 { 434 t.Fatal("NCU did not include the implant once") 435 } 436 } 437 player.health, player.nano = player.maximumHealth(), player.maximumNano() 438 if err := world.savePosition(player); err != nil { 439 t.Fatal(err) 440 } 441 world.handleInventory(client, itemMovePacket(1, fixture.slot, 111)[20:]) 442 world.advanceEquipment(client.equipment.readyAt) 443 removed := newTestInventoryServer(t).characters[1] 444 445 if removed.maximumHealth() != health || removed.maximumNano() != nano || removed.maximumNCU() != ncu || 446 removed.effectiveAbility(16) != ability || removed.attackRating() != skill || removed.equipmentBonus(fixture.stat) != 0 || 447 removed.health != health || removed.nano != nano || player.health != health || player.nano != nano || removed.inventory.Items[2].ID != 3 || removed.inventory.Items[2].Slot != 66 { 448 t.Fatal("implant removal retained effects, lost its instance or failed atomic resource clamps") 449 } 450 }) 451 } 452 } 453 454 func TestImplantMalformedAndTimedContractsPreserveOwnedItems(t *testing.T) { 455 for _, scenario := range []string{"wrong type", "cannot wear", "empty mask", "unknown mask bit", "unknown function", "wrong target", "repeated modifier", "modifier interval", "missing argument", "undecoded data"} { 456 t.Run(scenario, func(t *testing.T) { 457 world, conn := newCatalogImplantWorld(t, 101295) 458 player, client := world.characters[1], world.clients[1] 459 original := gamedata.ItemTemplates[101295] 460 definition := *original 461 definition.Stats, definition.Sections = slices.Clone(original.Stats), slices.Clone(original.Sections) 462 for index, stat := range definition.Stats { 463 if scenario == "cannot wear" && stat[0] == 30 { 464 definition.Stats[index][1] &^= 4 465 } 466 if stat[0] == 298 { 467 if scenario == "empty mask" { 468 definition.Stats[index][1] = 0 469 } else if scenario == "unknown mask bit" { 470 definition.Stats[index][1] |= 1 471 } 472 } 473 } 474 for index, section := range definition.Sections { 475 if section.Functions == nil { 476 continue 477 } 478 functions := slices.Clone(*section.Functions) 479 switch scenario { 480 case "unknown function": 481 functions[0].ID = 53051 482 case "wrong target": 483 functions[0].Target = 3 484 case "repeated modifier": 485 functions[0].TickCount = 2 486 case "modifier interval": 487 functions[0].TickInterval = 1 488 case "missing argument": 489 functions[0].Arguments = nil 490 } 491 definition.Sections[index].Functions = &functions 492 } 493 if scenario == "undecoded data" { 494 definition.Undecoded = &gamedata.UndecodedItemData{Reason: "unknown effect data"} 495 } else if scenario == "wrong type" { 496 player.inventory.Items[2].Type = 51018 497 } 498 gamedata.ItemTemplates[101295] = &definition 499 t.Cleanup(func() { gamedata.ItemTemplates[101295] = original }) 500 if err := world.saveInventory(player, player.inventory); err != nil { 501 t.Fatal(err) 502 } 503 before := slices.Clone(player.inventory.Items) 504 stored, _ := readTestItemStore(world) 505 506 err := world.handleInventory(client, inventoryMovePacket(1, 66, 45)[20:]) 507 after, _ := readTestItemStore(world) 508 509 if err != nil || client.equipment != nil || !reflect.DeepEqual(player.inventory.Items, before) || !bytes.Equal(stored, after) || len(conn.packets) != 2 { 510 t.Fatal("malformed/timed implant produced partial effects or changed ownership", err) 511 } 512 }) 513 } 514 } 515 516 func TestImplantsWithoutWearCriteriaKeepTheirAuthoredDelays(t *testing.T) { 517 for _, fixture := range []struct { 518 template uint32 519 delay time.Duration 520 runSpeed int32 521 }{{25806, 500 * time.Millisecond, 3}, {25807, 500 * time.Millisecond, 100}, {101101, 100 * time.Millisecond, 0}} { 522 t.Run(fmt.Sprint(fixture.template), func(t *testing.T) { 523 world, _ := newCatalogImplantWorld(t, fixture.template) 524 player, client := world.characters[1], world.clients[1] 525 player.stats.NanoAiding.Treatment = 0 526 player.stats.Abilities = characterAbilitiesStats{1, 1, 1, 1, 1, 1} 527 if err := world.saveUser(player); err != nil { 528 t.Fatal(err) 529 } 530 slot := uint32(45) 531 if fixture.template == 101101 { 532 slot = 33 533 } 534 535 started := time.Now() 536 err := world.handleInventory(client, inventoryMovePacket(1, 66, slot)[20:]) 537 if client.equipment == nil || client.equipment.readyAt.Before(started.Add(fixture.delay)) || client.equipment.readyAt.After(time.Now().Add(fixture.delay)) { 538 t.Fatal("missing action6 invented wear requirements or ignored EquipDelay211") 539 } 540 world.advanceEquipment(client.equipment.readyAt) 541 restored := newTestInventoryServer(t).characters[1] 542 543 if err != nil || restored.inventory.Items[2].ID != 3 || restored.inventory.Items[2].Slot != slot || restored.equipmentBonus(156) != fixture.runSpeed { 544 t.Fatal("blank/Plastic Muscles implant lost identity, slot or complete effects", err) 545 } 546 }) 547 } 548 }