private static void AddOption( SkillSheet skillSheet, Equipment equipment, IEnumerable <EquipmentItemOptionSheet.Row> optionRows, IRandom random) { var optionIds = new HashSet <int>(); foreach (var optionRow in optionRows.OrderBy(r => r.Id)) { if (optionRow.StatType != StatType.NONE) { var statMap = CombinationEquipment5.GetStat(optionRow, random); equipment.StatsMap.AddStatAdditionalValue(statMap.StatType, statMap.Value); } else { var skill = CombinationEquipment5.GetSkill(optionRow, skillSheet, random); if (!(skill is null)) { equipment.Skills.Add(skill); } } optionIds.Add(optionRow.Id); } }
public void ExecuteThrowNotEnoughMaterialException() { var row = _tableSheets.EquipmentItemRecipeSheet.Values.First(); const int requiredStage = GameConfig.RequireClearedStageLevel.CombinationEquipmentAction; for (var i = 1; i < requiredStage + 1; i++) { _avatarState.worldInformation.ClearStage( 1, i, 0, _tableSheets.WorldSheet, _tableSheets.WorldUnlockSheet ); } _initialState = _initialState.SetState(_avatarAddress, _avatarState.Serialize()); var action = new CombinationEquipment5() { AvatarAddress = _avatarAddress, RecipeId = row.Id, SlotIndex = 0, }; Assert.Throws <NotEnoughMaterialException>(() => action.Execute(new ActionContext() { PreviousStates = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); }
public void ExecuteWithSubRecipe() { var row = _tableSheets.EquipmentItemRecipeSheet.Values.First(r => r.SubRecipeIds.Any()); var subRecipeId = row.SubRecipeIds.First(); var materialRow = _tableSheets.MaterialItemSheet[row.MaterialId]; var material = ItemFactory.CreateItem(materialRow, _random); _avatarState.inventory.AddItem(material, row.MaterialCount); var subRecipeRow = _tableSheets.EquipmentItemSubRecipeSheet.Values.First(r => r.Id == subRecipeId); foreach (var materialInfo in subRecipeRow.Materials) { materialRow = _tableSheets.MaterialItemSheet[materialInfo.Id]; material = ItemFactory.CreateItem(materialRow, _random); _avatarState.inventory.AddItem(material, materialInfo.Count); } for (var i = 1; i < row.UnlockStage + 1; i++) { _avatarState.worldInformation.ClearStage( 1, i, 0, _tableSheets.WorldSheet, _tableSheets.WorldUnlockSheet ); } _initialState = _initialState.SetState(_avatarAddress, _avatarState.Serialize()); var action = new CombinationEquipment5() { AvatarAddress = _avatarAddress, RecipeId = row.Id, SubRecipeId = subRecipeId, SlotIndex = 0, }; var nextState = action.Execute(new ActionContext() { PreviousStates = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, }); var slotState = nextState.GetCombinationSlotState(_avatarAddress, 0); Assert.NotNull(slotState.Result); Assert.NotNull(slotState.Result.itemUsable); }
public void ExecuteThrowCombinationSlotUnlockException() { var row = _tableSheets.EquipmentItemRecipeSheet.Values.First(r => r.SubRecipeIds.Any()); var subRecipeId = row.SubRecipeIds.First(); var materialRow = _tableSheets.MaterialItemSheet[row.MaterialId]; var material = ItemFactory.CreateItem(materialRow, _random); _avatarState.inventory.AddItem(material, row.MaterialCount); var subRecipeRow = _tableSheets.EquipmentItemSubRecipeSheet.Values.First(r => r.Id == subRecipeId); foreach (var materialInfo in subRecipeRow.Materials) { materialRow = _tableSheets.MaterialItemSheet[materialInfo.Id]; material = ItemFactory.CreateItem(materialRow, _random); _avatarState.inventory.AddItem(material, materialInfo.Count); } for (var i = 1; i < row.UnlockStage + 1; i++) { _avatarState.worldInformation.ClearStage( 1, i, 0, _tableSheets.WorldSheet, _tableSheets.WorldUnlockSheet ); } _initialState = _initialState .SetState(_avatarAddress, _avatarState.Serialize()) .SetState( _slotAddress, new CombinationSlotState(_slotAddress, row.UnlockStage + 10).Serialize() ); var action = new CombinationEquipment5() { AvatarAddress = _avatarAddress, RecipeId = row.Id, SubRecipeId = subRecipeId, SlotIndex = 0, }; Assert.Throws <CombinationSlotUnlockException>(() => action.Execute(new ActionContext() { PreviousStates = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); }
public void ExecuteThrowFailedLoadStateException() { var action = new CombinationEquipment5() { AvatarAddress = _avatarAddress, RecipeId = 1, SubRecipeId = 1, SlotIndex = 0, }; Assert.Throws <FailedLoadStateException>(() => action.Execute(new ActionContext() { PreviousStates = new State(), Signer = _agentAddress, Random = new TestRandom(), })); }
public void Execute() { var row = _tableSheets.EquipmentItemRecipeSheet.Values.First(); var materialRow = _tableSheets.MaterialItemSheet[row.MaterialId]; var material = ItemFactory.CreateItem(materialRow, _random); _avatarState.inventory.AddItem(material, row.MaterialCount); const int requiredStage = GameConfig.RequireClearedStageLevel.CombinationEquipmentAction; for (var i = 1; i < requiredStage + 1; i++) { _avatarState.worldInformation.ClearStage( 1, i, 0, _tableSheets.WorldSheet, _tableSheets.WorldUnlockSheet ); } _initialState = _initialState.SetState(_avatarAddress, _avatarState.Serialize()); var action = new CombinationEquipment5() { AvatarAddress = _avatarAddress, RecipeId = row.Id, SlotIndex = 0, }; var nextState = action.Execute(new ActionContext() { PreviousStates = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, }); var slotState = nextState.GetCombinationSlotState(_avatarAddress, 0); Assert.NotNull(slotState.Result); Assert.NotNull(slotState.Result.itemUsable); }