Skip to content

Commit

Permalink
Rename charm to grimoire
Browse files Browse the repository at this point in the history
  • Loading branch information
ipdae committed Jun 18, 2024
1 parent d41f3b5 commit 2ebe159
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ namespace Lib9c.Tests.Action.Scenario
using Nekoyume.TableData;
using Xunit;

public class CharmScenarioTest
public class GrimoireScenarioTest
{
private readonly Address _agentAddress;
private readonly Address _avatarAddress;
private readonly Address _enemyAvatarAddress;
private readonly IWorld _initialState;
private readonly Charm _charm;
private readonly Grimoire _grimoire;
private readonly TableSheets _tableSheets;
private readonly Currency _currency;

public CharmScenarioTest()
public GrimoireScenarioTest()
{
_agentAddress = new PrivateKey().Address;
var agentState = new AgentState(_agentAddress);
Expand All @@ -43,13 +43,13 @@ public CharmScenarioTest()
var sheets = TableSheetsImporter.ImportSheets();
_tableSheets = new TableSheets(sheets);
var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]);
var charmRow =
_tableSheets.EquipmentItemSheet.Values.First(r => r.ItemSubType == ItemSubType.Charm);
_charm = (Charm)ItemFactory.CreateItemUsable(charmRow, Guid.NewGuid(), 0L);
_charm.StatsMap.AddStatAdditionalValue(StatType.CRI, 1);
var grimoireRow =
_tableSheets.EquipmentItemSheet.Values.First(r => r.ItemSubType == ItemSubType.Grimoire);
_grimoire = (Grimoire)ItemFactory.CreateItemUsable(grimoireRow, Guid.NewGuid(), 0L);
_grimoire.StatsMap.AddStatAdditionalValue(StatType.CRI, 1);
var skillRow = _tableSheets.SkillSheet[210011];
var skill = SkillFactory.Get(skillRow, 0, 100, 0, StatType.NONE);
_charm.Skills.Add(skill);
_grimoire.Skills.Add(skill);
var addresses = new[] { _avatarAddress, _enemyAvatarAddress };
_initialState = new World(MockUtil.MockModernWorldState);
for (int i = 0; i < addresses.Length; i++)
Expand All @@ -63,7 +63,7 @@ public CharmScenarioTest()
_tableSheets.GetAvatarSheets(),
rankingMapAddress
);
avatarState.inventory.AddItem(_charm);
avatarState.inventory.AddItem(_grimoire);
_initialState = _initialState.SetAvatarState(avatarAddress, avatarState)
.SetActionPoint(avatarAddress, DailyReward.ActionPointMax);
}
Expand Down Expand Up @@ -95,8 +95,8 @@ public void HackAndSlash()
AvatarAddress = _avatarAddress,
Equipments = new List<Guid>
{
_charm.ItemId,
_charm.ItemId,
_grimoire.ItemId,
_grimoire.ItemId,
},
Costumes = new List<Guid>(),
Foods = new List<Guid>(),
Expand All @@ -114,10 +114,10 @@ public void HackAndSlash()

has.Equipments = new List<Guid>
{
_charm.ItemId,
_grimoire.ItemId,
};

// equip charm because charmIgnoreSheet is empty
// equip grimoire because grimoireIgnoreSheet is empty
var nextState = has.Execute(new ActionContext
{
BlockIndex = 3,
Expand Down Expand Up @@ -148,7 +148,7 @@ public void Raid()
AvatarAddress = _avatarAddress,
EquipmentIds = new List<Guid>
{
_charm.ItemId,
_grimoire.ItemId,
},
CostumeIds = new List<Guid>(),
FoodIds = new List<Guid>(),
Expand Down Expand Up @@ -191,7 +191,7 @@ public void Arena()
costumes = new List<Guid>(),
equipments = new List<Guid>
{
_charm.ItemId,
_grimoire.ItemId,
},
runeInfos = new List<RuneSlotInfo>(),
};
Expand Down Expand Up @@ -223,7 +223,7 @@ public void Arena()
costumes = new List<Guid>(),
equipments = new List<Guid>
{
_charm.ItemId,
_grimoire.ItemId,
},
runeInfos = new List<RuneSlotInfo>(),
};
Expand Down Expand Up @@ -281,14 +281,14 @@ public void Arena()
public void Grinding()
{
var avatarState = _initialState.GetAvatarState(_avatarAddress);
Assert.True(avatarState.inventory.TryGetNonFungibleItem(_charm.ItemId, out _));
Assert.True(avatarState.inventory.TryGetNonFungibleItem(_grimoire.ItemId, out _));

var grinding = new Grinding
{
AvatarAddress = _avatarAddress,
EquipmentIds = new List<Guid>
{
_charm.ItemId,
_grimoire.ItemId,
},
};
var nextState = grinding.Execute(new ActionContext
Expand All @@ -299,7 +299,7 @@ public void Grinding()
});

var nextAvatarState = nextState.GetAvatarState(_avatarAddress);
Assert.False(nextAvatarState.inventory.TryGetNonFungibleItem(_charm.ItemId, out _));
Assert.False(nextAvatarState.inventory.TryGetNonFungibleItem(_grimoire.ItemId, out _));
var previousCrystal = _initialState.GetBalance(_agentAddress, Currencies.Crystal);
Assert.True(nextState.GetBalance(_agentAddress, Currencies.Crystal) > previousCrystal);
}
Expand All @@ -308,10 +308,10 @@ public void Grinding()
public void Market()
{
var avatarState = _initialState.GetAvatarState(_avatarAddress);
avatarState.inventory.TryGetNonFungibleItem(_charm.ItemId, out Charm charm);
Assert.NotNull(charm);
Assert.IsAssignableFrom<Equipment>(charm);
Assert.Null(charm as ITradableItem);
avatarState.inventory.TryGetNonFungibleItem(_grimoire.ItemId, out Grimoire grimoire);
Assert.NotNull(grimoire);
Assert.IsAssignableFrom<Equipment>(grimoire);
Assert.Null(grimoire as ITradableItem);
for (int i = 0; i < GameConfig.RequireClearedStageLevel.ActionsInShop; i++)
{
avatarState.worldInformation.ClearStage(1, i + 1, 0, _tableSheets.WorldSheet, _tableSheets.WorldUnlockSheet);
Expand All @@ -328,14 +328,14 @@ public void Market()
{
AvatarAddress = _avatarAddress,
Price = 1 * _currency,
TradableId = _charm.ItemId,
TradableId = _grimoire.ItemId,
ItemCount = 1,
Type = ProductType.NonFungible,
},
},
ChargeAp = false,
};
// Because Charm is not ITradableItem.
// Because Grimoire is not ITradableItem.
Assert.Throws<ItemDoesNotExistException>(() => register.Execute(new ActionContext
{
Signer = _agentAddress,
Expand All @@ -347,23 +347,23 @@ public void Market()
private void Assert_Player(AvatarState avatarState, IWorld state, Address avatarAddress, Address itemSlotStateAddress)
{
var nextAvatarState = state.GetAvatarState(avatarAddress);
var equippedItem = Assert.IsType<Charm>(nextAvatarState.inventory.Equipments.First());
var equippedItem = Assert.IsType<Grimoire>(nextAvatarState.inventory.Equipments.First());
Assert.True(equippedItem.equipped);
Assert_ItemSlot(state, itemSlotStateAddress);
var player = new Player(avatarState, _tableSheets.GetSimulatorSheets());
var equippedPlayer = new Player(nextAvatarState, _tableSheets.GetSimulatorSheets());
int diffLevel = equippedPlayer.Level - player.Level;
var row = _tableSheets.CharacterSheet[player.CharacterId];
Assert.Null(player.charm);
Assert.NotNull(equippedPlayer.charm);
Assert.Null(player.Grimoire);
Assert.NotNull(equippedPlayer.Grimoire);
Assert.Equal(player.HIT + 310 + (int)(row.LvHIT * diffLevel), equippedPlayer.HIT);
Assert.Equal(player.CRI + 1, equippedPlayer.CRI);
}

private void Assert_Equipments(IEnumerable<Guid> equipments)
{
var equipmentId = Assert.Single(equipments);
Assert.Equal(_charm.ItemId, equipmentId);
Assert.Equal(_grimoire.ItemId, equipmentId);
}

private ItemSlotState Assert_ItemSlot(IWorld state, Address itemSlotStateAddress)
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/GameConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static class MaxEquipmentSlotCount
public const int Necklace = 1;
public const int Ring = 2;
public const int Aura = 1;
public const int Charm = 1;
public const int Grimoire = 1;
}
}
}
2 changes: 1 addition & 1 deletion Lib9c/Model/Character/EnemyPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ EquipmentItemSetEffectSheet equipmentItemSetEffectSheet
necklace = null;
ring = null;
aura = null;
charm = null;
Grimoire = null;
monsterMap = new CollectionMap();
eventMap = new CollectionMap();
hairIndex = enemyPlayerDigest.HairIndex;
Expand Down
14 changes: 7 additions & 7 deletions Lib9c/Model/Character/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public object Clone()
public Necklace necklace;
public Ring ring;
public Aura aura;
public Charm charm;
public Grimoire Grimoire;

public CollectionMap monsterMap;
public CollectionMap eventMap;
Expand Down Expand Up @@ -106,7 +106,7 @@ public Player(AvatarState avatarState, Simulator simulator)
necklace = null;
ring = null;
aura = null;
charm = null;
Grimoire = null;
monsterMap = new CollectionMap();
eventMap = new CollectionMap();
monsterMapForBeforeV100310 = new CollectionMap();
Expand Down Expand Up @@ -139,7 +139,7 @@ EquipmentItemSetEffectSheet equipmentItemSetEffectSheet
necklace = null;
ring = null;
aura = null;
charm = null;
Grimoire = null;
monsterMap = new CollectionMap();
eventMap = new CollectionMap();
monsterMapForBeforeV100310 = new CollectionMap();
Expand Down Expand Up @@ -171,7 +171,7 @@ EquipmentItemSetEffectSheet equipmentItemSetEffectSheet
necklace = null;
ring = null;
aura = null;
charm = null;
Grimoire = null;
monsterMap = new CollectionMap();
eventMap = new CollectionMap();
monsterMapForBeforeV100310 = new CollectionMap();
Expand Down Expand Up @@ -222,7 +222,7 @@ protected Player(Player value) : base(value)
necklace = value.necklace;
ring = value.ring;
aura = value.aura;
charm = value.charm;
Grimoire = value.Grimoire;
monsterMap = value.monsterMap;
eventMap = value.eventMap;
monsterMapForBeforeV100310 = value.monsterMapForBeforeV100310;
Expand Down Expand Up @@ -330,8 +330,8 @@ protected void SetEquipmentStat(EquipmentItemSetEffectSheet sheet)
case ItemSubType.Aura:
aura = equipment as Aura;
break;
case ItemSubType.Charm:
charm = equipment as Charm;
case ItemSubType.Grimoire:
Grimoire = equipment as Grimoire;
break;
default:
throw new RequiredBlockIndexException();
Expand Down
23 changes: 0 additions & 23 deletions Lib9c/Model/Item/Charm.cs

This file was deleted.

23 changes: 23 additions & 0 deletions Lib9c/Model/Item/Grimoire.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Runtime.Serialization;
using Bencodex.Types;
using Nekoyume.TableData;

namespace Nekoyume.Model.Item
{
[Serializable]
public class Grimoire : Equipment
{
public Grimoire(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex, bool madeWithMimisbrunnrRecipe = false) : base(data, id, requiredBlockIndex, madeWithMimisbrunnrRecipe)
{
}

public Grimoire(Dictionary serialized) : base(serialized)
{
}

protected Grimoire(SerializationInfo info, StreamingContext _) : base(info, _)
{
}
}
}
8 changes: 4 additions & 4 deletions Lib9c/Model/Item/ItemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public static ItemUsable CreateItemUsable(ItemSheet.Row itemRow, Guid id,
equipment = new Aura((EquipmentItemSheet.Row) itemRow, id, requiredBlockIndex,
madeWithMimisbrunnrRecipe);
break;
case ItemSubType.Charm:
equipment = new Charm((EquipmentItemSheet.Row) itemRow, id, requiredBlockIndex, madeWithMimisbrunnrRecipe);
case ItemSubType.Grimoire:
equipment = new Grimoire((EquipmentItemSheet.Row) itemRow, id, requiredBlockIndex, madeWithMimisbrunnrRecipe);
break;
default:
throw new ArgumentOutOfRangeException(
Expand Down Expand Up @@ -155,8 +155,8 @@ public static ItemBase Deserialize(Dictionary serialized)
return new Ring(serialized);
case ItemSubType.Aura:
return new Aura(serialized);
case ItemSubType.Charm:
return new Charm(serialized);
case ItemSubType.Grimoire:
return new Grimoire(serialized);
}
break;
case ItemType.Material:
Expand Down
4 changes: 2 additions & 2 deletions Lib9c/Model/Item/ItemType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public enum ItemSubType
// Aura
Aura = 19,

// Charm
Charm = 20,
// Grimoire
Grimoire = 20,
}

public class ItemTypeComparer : IEqualityComparer<ItemType>
Expand Down
6 changes: 3 additions & 3 deletions Lib9c/Model/State/AvatarState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -801,10 +801,10 @@ public List<Equipment> ValidateEquipmentsV3(List<Guid> equipmentIds, long blockI
requiredLevel = isSlotEnough ?
gameConfigState.RequireCharacterLevel_EquipmentSlotAura : int.MaxValue;
break;
case ItemSubType.Charm:
isSlotEnough = countMap[type] <= GameConfig.MaxEquipmentSlotCount.Charm;
case ItemSubType.Grimoire:
isSlotEnough = countMap[type] <= GameConfig.MaxEquipmentSlotCount.Grimoire;
requiredLevel = isSlotEnough ?
gameConfigState.RequireCharacterLevel_EquipmentSlotCharm : int.MaxValue;
gameConfigState.RequireCharacterLevel_EquipmentSlotGrimoire : int.MaxValue;
break;
default:
throw new ArgumentOutOfRangeException($"{equipment.ItemSubType} / invalid equipment type");
Expand Down
Loading

0 comments on commit 2ebe159

Please sign in to comment.