@@ -397,6 +397,32 @@ func TestPickupGroundItemWithTemplateRejectsAuthoredRestrictionsWithoutMutation(
397397 }
398398}
399399
400+ func TestPickupGroundItemWithAntiStackTemplateUsesFreshCarriedSlot (t * testing.T ) {
401+ runtime := NewRuntime (loginticket.Character {
402+ Inventory : []inventory.ItemInstance {{ID : 41 , Vnum : 27001 , Count : 198 , Slot : 5 }},
403+ }, SessionLink {})
404+ template := itemcatalog.Template {Vnum : 27001 , Name : "Bound Red Potion" , Stackable : true , MaxCount : 200 , AntiStack : true }
405+ groundItem := inventory.ItemInstance {ID : 42 , Vnum : 27001 , Count : 2 }
406+
407+ result , ok := runtime .PickupGroundItemWithTemplate (groundItem , 5 , template )
408+ if ! ok {
409+ t .Fatal ("expected anti-stack pickup to use a fresh carried slot instead of merging" )
410+ }
411+ if result .Merged || result .Split || result .Updated .ID != 0 || len (result .UpdatedItems ) != 0 {
412+ t .Fatalf ("expected fresh-slot anti-stack pickup result, got %+v" , result )
413+ }
414+ if result .Placed .ID != 42 || result .Placed .Vnum != 27001 || result .Placed .Count != 2 || result .Placed .Slot != 0 {
415+ t .Fatalf ("unexpected anti-stack placed item: %+v" , result .Placed )
416+ }
417+ wantInventory := []inventory.ItemInstance {
418+ {ID : 42 , Vnum : 27001 , Count : 2 , Slot : 0 },
419+ {ID : 41 , Vnum : 27001 , Count : 198 , Slot : 5 },
420+ }
421+ if got := runtime .LiveInventory (); ! reflect .DeepEqual (got , wantInventory ) {
422+ t .Fatalf ("anti-stack pickup should not merge with compatible stack: got %#v want %#v" , got , wantInventory )
423+ }
424+ }
425+
400426func TestUseItemOnItemConsolidatesFullSourceAndKeepsTargetQuickslotStable (t * testing.T ) {
401427 runtime := NewRuntime (loginticket.Character {
402428 Inventory : []inventory.ItemInstance {
0 commit comments