public void SerializeCombinationSlotStateWithResult() { var address = new PrivateKey().PublicKey.ToAddress(); var state = new CombinationSlotState(address, 1); var item = ItemFactory.CreateItemUsable(_tableSheets.EquipmentItemSheet.Values.First(), Guid.Empty, default); var result = new CombinationConsumable.ResultModel { actionPoint = 1, gold = 1, materials = new Dictionary <Nekoyume.Model.Item.Material, int>(), itemUsable = item }; state.Update(result, 1, 10); var serialized = (Dictionary)state.Serialize(); Assert.IsTrue(serialized.ContainsKey((IKey)(Text)"address")); Assert.IsTrue(serialized.ContainsKey((IKey)(Text)"unlockBlockIndex")); Assert.IsTrue(serialized.ContainsKey((IKey)(Text)"unlockStage")); Assert.IsTrue(serialized.ContainsKey((IKey)(Text)"result")); Assert.IsTrue(serialized.ContainsKey((IKey)(Text)"startBlockIndex")); var deserialize = new CombinationSlotState(serialized); Assert.AreEqual(state.UnlockStage, deserialize.UnlockStage); Assert.AreEqual(state.UnlockBlockIndex, deserialize.UnlockBlockIndex); Assert.AreEqual(state.address, deserialize.address); Assert.AreEqual(state.Result.itemUsable, deserialize.Result.itemUsable); Assert.AreEqual(state.StartBlockIndex, deserialize.StartBlockIndex); }
public void CombinationSlotStateUpdate() { var address = new PrivateKey().PublicKey.ToAddress(); var state = new CombinationSlotState(address, 1); var result = new CombinationConsumable.ResultModel(); state.Update(result, 1, 10); Assert.AreEqual(result, state.Result); Assert.AreEqual(10, state.UnlockBlockIndex); Assert.AreEqual(1, state.StartBlockIndex); }
public void UpdateFromRapidCombination(CombinationConsumable.ResultModel result, long requiredIndex) { var mail = mailBox.First(m => m.id == result.id); mail.requiredBlockIndex = requiredIndex; var item = inventory.Items .Select(i => i.item) .OfType <ItemUsable>() .First(i => i.ItemId == result.itemUsable.ItemId); item.Update(requiredIndex); }
public static void ModifyCombinationSlotEquipment( TableSheets tableSheets, EquipmentItemRecipeSheet.Row row, CombinationPanel panel, Address slotAddress, int?subRecipeId ) { // When the layer is covered, additionally set the block height to prevent state updates until the actual state comes in. var blockIndex = Game.Game.instance.Agent.BlockIndex + 100; var requiredBlockIndex = row.RequiredBlockIndex + blockIndex; if (subRecipeId.HasValue) { var subRow = tableSheets.EquipmentItemSubRecipeSheet.Values.First(r => r.Id == subRecipeId); requiredBlockIndex += subRow.RequiredBlockIndex; } var equipRow = tableSheets.EquipmentItemSheet.Values.First(i => i.Id == row.ResultEquipmentId); var equipment = ItemFactory.CreateItemUsable(equipRow, Guid.Empty, requiredBlockIndex); var materials = new Dictionary <Material, int>(); foreach (var(material, count) in panel.materialPanel.MaterialList) { materials[material] = count; } var result = new CombinationConsumable.ResultModel { // id: When applying the local layer for the first time, if the id is the default, the notification is not applied. id = Guid.NewGuid(), actionPoint = panel.CostAP, gold = panel.CostNCG, materials = materials, itemUsable = equipment, recipeId = row.Id, subRecipeId = subRecipeId, itemType = ItemType.Equipment, }; var modifier = new CombinationSlotBlockIndexAndResultModifier(result, blockIndex, requiredBlockIndex); var slotState = States.Instance.CombinationSlotStates[slotAddress]; LocalLayer.Instance.Set(slotState.address, modifier); States.Instance.CombinationSlotStates[slotAddress] = modifier.Modify(slotState); CombinationSlotStateSubject.OnNext(slotState); }
public void AvatarNewAttachmentMailSetter() { var equipment = GetFirstEquipment(); var combinationResult = new CombinationConsumable.ResultModel { itemUsable = equipment }; var attachmentMail = new CombinationMail(combinationResult, 0, new Guid(), 0); Assert.False(attachmentMail.New); _avatarState.mailBox.Add(attachmentMail); var modifier = JsonTest(new AvatarAttachmentMailNewSetter(attachmentMail.id)); _avatarState = modifier.Modify(_avatarState); Assert.True(attachmentMail.New); }
public void Execute() { const int slotStateUnlockStage = 1; var avatarState = _initialState.GetAvatarState(_avatarAddress); avatarState.worldInformation = new WorldInformation( 0, _initialState.GetSheet <WorldSheet>(), slotStateUnlockStage); var material = ItemFactory.CreateMaterial( _tableSheets.MaterialItemSheet.Values.First(r => r.ItemSubType == ItemSubType.Hourglass)); avatarState.inventory.AddItem(material); var firstEquipmentRow = _tableSheets.EquipmentItemSheet.First; Assert.NotNull(firstEquipmentRow); var gameConfigState = _initialState.GetGameConfigState(); var requiredBlockIndex = gameConfigState.HourglassPerBlock; var equipment = (Equipment)ItemFactory.CreateItemUsable( firstEquipmentRow, Guid.NewGuid(), requiredBlockIndex); avatarState.inventory.AddItem(equipment); var result = new CombinationConsumable.ResultModel { actionPoint = 0, gold = 0, materials = new Dictionary <Material, int>(), itemUsable = equipment, recipeId = 0, itemType = ItemType.Equipment, }; var mail = new CombinationMail(result, 0, default, requiredBlockIndex);
public static void ModifyCombinationSlotConsumable( TableSheets tableSheets, ICombinationPanel panel, ConsumableItemRecipeSheet.Row recipeRow, Address slotAddress ) { // When the layer is covered, additionally set the block height to prevent state updates until the actual state comes in. var blockIndex = Game.Game.instance.Agent.BlockIndex + 100; var requiredBlockIndex = blockIndex + recipeRow.RequiredBlockIndex; var consumableRow = tableSheets.ConsumableItemSheet.Values.First(i => i.Id == recipeRow.ResultConsumableItemId); var consumable = ItemFactory.CreateItemUsable( consumableRow, Guid.Empty, requiredBlockIndex); var materials = new Dictionary <Material, int>(); foreach (var materialInfo in recipeRow.Materials) { var materialRow = tableSheets.MaterialItemSheet.Values.First(r => r.Id == materialInfo.Id); var material = ItemFactory.CreateMaterial(materialRow); materials[material] = materialInfo.Count; } var result = new CombinationConsumable.ResultModel { actionPoint = panel.CostAP, gold = panel.CostNCG, materials = materials, itemUsable = consumable, recipeId = recipeRow.Id, itemType = ItemType.Consumable, }; var modifier = new CombinationSlotBlockIndexAndResultModifier(result, blockIndex, requiredBlockIndex); var slotState = States.Instance.CombinationSlotStates[slotAddress]; LocalLayer.Instance.Set(slotState.address, modifier); States.Instance.CombinationSlotStates[slotAddress] = modifier.Modify(slotState); CombinationSlotStateSubject.OnNext(slotState); }
public CombinationMail(CombinationConsumable.ResultModel attachmentActionResult, long blockIndex, Guid id, long requiredBlockIndex) : base(attachmentActionResult, blockIndex, id, requiredBlockIndex) { }