Skip to content

Commit

Permalink
remove obsolete add item
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-doobu committed Dec 27, 2024
1 parent 5a221f1 commit ccf695e
Show file tree
Hide file tree
Showing 16 changed files with 118 additions and 325 deletions.
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/BuyMultipleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public void Execute(params ShopItemData[] productDatas)
// Case for backward compatibility of `Buy`
if (product.ContainsInInventory)
{
sellerAvatarState.inventory.AddItem2((ItemBase)nonFungibleItem);
sellerAvatarState.inventory.AddItem((ItemBase)nonFungibleItem);
}

var shopItemId = Guid.NewGuid();
Expand Down
4 changes: 1 addition & 3 deletions .Lib9c.Tests/Action/BuyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace Lib9c.Tests.Action
using Nekoyume;
using Nekoyume.Action;
using Nekoyume.Action.Guild.Migration.LegacyModels;
using Nekoyume.Arena;
using Nekoyume.Model;
using Nekoyume.Model.Item;
using Nekoyume.Model.Mail;
Expand All @@ -26,7 +25,6 @@ namespace Lib9c.Tests.Action
using Serilog;
using Xunit;
using Xunit.Abstractions;
using static Lib9c.SerializeKeys;

public class BuyTest
{
Expand Down Expand Up @@ -685,7 +683,7 @@ public void Execute_ReconfigureFungibleItem(params OrderData[] orderDataList)

var dummyItem = ItemFactory.CreateTradableMaterial(
_tableSheets.MaterialItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Hourglass));
sellerAvatarState.inventory.AddItem2((ItemBase)dummyItem, orderDataList.Sum(x => x.ItemCount));
sellerAvatarState.inventory.AddItem((ItemBase)dummyItem, orderDataList.Sum(x => x.ItemCount));

foreach (var orderData in orderDataList)
{
Expand Down
93 changes: 0 additions & 93 deletions .Lib9c.Tests/Model/Item/InventoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ public Inventory AddItem_Consumable()
return AddItem_Consumable_After(inventory);
}

[Fact]
public Inventory AddItem2_Consumable()
{
var item = GetFirstConsumable();
var inventory = new Inventory();
Assert.Empty(inventory.Items);

inventory.AddItem2(item);
return AddItem_Consumable_After(inventory);
}

[Fact]
public Inventory AddItem_Costume()
{
Expand All @@ -81,17 +70,6 @@ public Inventory AddItem_Costume()
return AddItem_Costume_After(inventory);
}

[Fact]
public Inventory AddItem2_Costume()
{
var item = GetFirstCostume();
var inventory = new Inventory();
Assert.Empty(inventory.Items);

inventory.AddItem2(item);
return AddItem_Costume_After(inventory);
}

[Theory]
[InlineData(1)]
[InlineData(2)]
Expand All @@ -109,23 +87,6 @@ public Inventory AddItem_Material(int count)
return AddItem_Material_After(inventory, count);
}

[Theory]
[InlineData(1)]
[InlineData(2)]
public Inventory AddItem2_Material(int count)
{
var item = GetFirstMaterial();
var inventory = new Inventory();
Assert.Empty(inventory.Items);

for (var i = 0; i < count; i++)
{
inventory.AddItem2(item);
}

return AddItem_Material_After(inventory, count);
}

[Fact]
public Inventory AddItem_Equipment()
{
Expand All @@ -137,17 +98,6 @@ public Inventory AddItem_Equipment()
return AddItem_Equipment_After(inventory);
}

[Fact]
public Inventory AddItem2_Equipment()
{
var item = GetFirstEquipment();
var inventory = new Inventory();
Assert.Empty(inventory.Items);

inventory.AddItem2(item);
return AddItem_Equipment_After(inventory);
}

[Theory]
[InlineData(1)]
[InlineData(2)]
Expand All @@ -165,23 +115,6 @@ public Inventory AddItem_TradableMaterial(int count)
return AddItem_Material_After(inventory, count);
}

[Theory]
[InlineData(1)]
[InlineData(2)]
public Inventory AddItem2_TradableMaterial(int count)
{
var item = GetFirstTradableMaterial();
var inventory = new Inventory();
Assert.Empty(inventory.Items);

for (var i = 0; i < count; i++)
{
inventory.AddItem2(item);
}

return AddItem_Material_After(inventory, count);
}

[Theory]
[InlineData(1)]
[InlineData(2)]
Expand All @@ -195,19 +128,6 @@ public Inventory AddFungibleItem_Material(int count)
return AddItem_Material_After(inventory, count);
}

[Theory]
[InlineData(1)]
[InlineData(2)]
public Inventory AddFungibleItem2_Material(int count)
{
var item = GetFirstMaterial();
var inventory = new Inventory();
Assert.Empty(inventory.Items);

inventory.AddFungibleItem2(item, count);
return AddItem_Material_After(inventory, count);
}

[Theory]
[InlineData(1)]
[InlineData(2)]
Expand All @@ -221,19 +141,6 @@ public Inventory AddFungibleItem_TradableMaterial(int count)
return AddItem_Material_After(inventory, count);
}

[Theory]
[InlineData(1)]
[InlineData(2)]
public Inventory AddFungibleItem2_TradableMaterial(int count)
{
var item = GetFirstTradableMaterial();
var inventory = new Inventory();
Assert.Empty(inventory.Items);

inventory.AddFungibleItem2(item, count);
return AddItem_Material_After(inventory, count);
}

[Fact]
public Inventory AddNonFungibleItem_Consumable()
{
Expand Down
4 changes: 2 additions & 2 deletions .Lib9c.Tests/Model/State/ShardedShopStateV2Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ public void Remove()
var item2 = (Weapon)ItemFactory.CreateItem(
tableSheets.ItemSheet.Values.First(r => r.ItemSubType == ItemSubType.Weapon),
random);
avatarState.inventory.AddItem2(item);
avatarState.inventory.AddItem2(item2);
avatarState.inventory.AddItem(item);
avatarState.inventory.AddItem(item2);

var orderId = new Guid("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4");
var orderId2 = new Guid("936DA01F-9ABD-4d9d-80C7-02AF85C822A8");
Expand Down
8 changes: 4 additions & 4 deletions Lib9c/Action/Buy7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public override IWorld Execute(IActionContext context)
buyerAvatarState.Update(buyerMail);
if (purchaseResult.itemUsable != null)
{
buyerAvatarState.UpdateFromAddItem2(purchaseResult.itemUsable, false);
buyerAvatarState.UpdateFromAddItem(purchaseResult.itemUsable, false);
}

if (purchaseResult.costume != null)
Expand All @@ -437,7 +437,7 @@ public override IWorld Execute(IActionContext context)

if (purchaseResult.tradableFungibleItem is TradableMaterial material)
{
buyerAvatarState.UpdateFromAddItem2(material, shopItem.TradableFungibleItemCount, false);
buyerAvatarState.UpdateFromAddItem(material, shopItem.TradableFungibleItemCount, false);
}

sellerAvatarState.Update(sellerMail);
Expand All @@ -449,8 +449,8 @@ public override IWorld Execute(IActionContext context)
sellerAvatarState.updatedAt = ctx.BlockIndex;
sellerAvatarState.blockIndex = ctx.BlockIndex;

buyerAvatarState.UpdateQuestRewards2(materialSheet);
sellerAvatarState.UpdateQuestRewards2(materialSheet);
buyerAvatarState.UpdateQuestRewards(materialSheet);
sellerAvatarState.UpdateQuestRewards(materialSheet);

states = states.SetAvatarState(sellerAvatarAddress, sellerAvatarState);
sw.Stop();
Expand Down
6 changes: 3 additions & 3 deletions Lib9c/Action/BuyMultiple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public override IWorld Execute(IActionContext context)
buyerAvatarState.Update(buyerMail);
if (purchaseResult.itemUsable != null)
{
buyerAvatarState.UpdateFromAddItem2(purchaseResult.itemUsable, false);
buyerAvatarState.UpdateFromAddItem(purchaseResult.itemUsable, false);
}
if (purchaseResult.costume != null)
{
Expand All @@ -398,7 +398,7 @@ public override IWorld Execute(IActionContext context)

sellerAvatarState.updatedAt = ctx.BlockIndex;
sellerAvatarState.blockIndex = ctx.BlockIndex;
sellerAvatarState.UpdateQuestRewards2(materialSheet);
sellerAvatarState.UpdateQuestRewards(materialSheet);

sw.Restart();
states = states.SetAvatarState(productInfo.sellerAvatarAddress, sellerAvatarState);
Expand All @@ -412,7 +412,7 @@ public override IWorld Execute(IActionContext context)
buyerAvatarState.updatedAt = ctx.BlockIndex;
buyerAvatarState.blockIndex = ctx.BlockIndex;

buyerAvatarState.UpdateQuestRewards2(materialSheet);
buyerAvatarState.UpdateQuestRewards(materialSheet);

sw.Restart();
states = states.SetAvatarState(buyerAvatarAddress, buyerAvatarState);
Expand Down
4 changes: 2 additions & 2 deletions Lib9c/Action/CombinationConsumable5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ public override IWorld Execute(IActionContext context)
);
result.id = mail.id;
avatarState.Update(mail);
avatarState.UpdateFromCombination2(itemUsable);
avatarState.UpdateFromCombination(itemUsable);
sw.Stop();
Log.Verbose("{AddressesHex}Combination Update AvatarState: {Elapsed}", addressesHex, sw.Elapsed);
sw.Restart();

var materialSheet = states.GetSheet<MaterialItemSheet>();
avatarState.UpdateQuestRewards2(materialSheet);
avatarState.UpdateQuestRewards(materialSheet);

avatarState.updatedAt = ctx.BlockIndex;
avatarState.blockIndex = ctx.BlockIndex;
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Action/DailyReward2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public override IWorld Execute(IActionContext context)
result.id = mail.id;
dailyRewardResult = result;
avatarState.Update(mail);
avatarState.UpdateFromAddItem2(material, rewardItemCount, false);
avatarState.UpdateFromAddItem(material, rewardItemCount, false);
return states.SetAvatarState(avatarAddress, avatarState);
}

Expand Down
4 changes: 2 additions & 2 deletions Lib9c/Action/ItemEnhancement7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ public override IWorld Execute(IActionContext context)
avatarState.inventory.RemoveNonFungibleItem(enhancementEquipment);

avatarState.Update(mail);
avatarState.UpdateFromItemEnhancement2(enhancementEquipment);
avatarState.UpdateFromItemEnhancement(enhancementEquipment);

var materialSheet = states.GetSheet<MaterialItemSheet>();
avatarState.UpdateQuestRewards2(materialSheet);
avatarState.UpdateQuestRewards(materialSheet);

slotState.Update(result, ctx.BlockIndex, requiredBlockIndex);

Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Action/RedeemCode2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public override IWorld Execute(IActionContext context)
ItemBase item = ItemFactory.CreateItem(itemSheets[itemId], random);
// We should fix count as 1 because ItemFactory.CreateItem
// will create a new item every time.
avatarState.inventory.AddItem2(item, count: 1);
avatarState.inventory.AddItem(item, count: 1);
}
}
break;
Expand Down
Loading

0 comments on commit ccf695e

Please sign in to comment.