public void Execute() { var dailyRewardAction = new DailyReward2 { avatarAddress = _avatarAddress, }; var nextState = dailyRewardAction.Execute(new ActionContext { BlockIndex = 0, PreviousStates = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, }); var gameConfigState = nextState.GetGameConfigState(); var nextAvatarState = nextState.GetAvatarState(_avatarAddress); Assert.Equal(gameConfigState.ActionPointMax, nextAvatarState.actionPoint); Assert.Single(nextAvatarState.mailBox); var mail = nextAvatarState.mailBox.First(); var rewardMail = mail as DailyRewardMail; Assert.NotNull(rewardMail); var rewardResult = rewardMail.attachment as DailyReward2.DailyRewardResult; Assert.NotNull(rewardResult); Assert.Single(rewardResult.materials); var material = rewardResult.materials.First(); Assert.Equal(400000, material.Key.Id); Assert.Equal(10, material.Value); }
public void Execute(ItemType itemType, string guid, bool contain) { var avatarState = _initialState.GetAvatarState(_avatarAddress); INonFungibleItem nonFungibleItem; Guid itemId = new Guid(guid); Guid productId = itemId; ItemSubType itemSubType; const long requiredBlockIndex = 0; ShopState legacyShopState = _initialState.GetShopState(); if (itemType == ItemType.Equipment) { var itemUsable = ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); nonFungibleItem = itemUsable; itemSubType = itemUsable.ItemSubType; } else { var costume = ItemFactory.CreateCostume(_tableSheets.CostumeItemSheet.First, itemId); costume.Update(requiredBlockIndex); nonFungibleItem = costume; itemSubType = costume.ItemSubType; } var result = new DailyReward2.DailyRewardResult() { id = default,
public void ExecuteThrowFailedLoadStateException() { var action = new DailyReward2 { avatarAddress = _avatarAddress, }; Assert.Throws <FailedLoadStateException>(() => action.Execute(new ActionContext() { PreviousStates = new State(), Signer = _agentAddress, BlockIndex = 0, }) ); }
public void Execute(params ShopItemData[] shopItemMembers) { AvatarState buyerAvatarState = _initialState.GetAvatarState(_buyerAvatarAddress); List <PurchaseInfo0> purchaseInfos = new List <PurchaseInfo0>(); Dictionary <Address, ShardedShopState> shardedShopStates = new Dictionary <Address, ShardedShopState>(); ShopState legacyShopState = _initialState.GetShopState(); foreach (var shopItemData in shopItemMembers) { (AvatarState sellerAvatarState, AgentState sellerAgentState) = CreateAvatarState( shopItemData.SellerAgentAddress, shopItemData.SellerAvatarAddress ); ITradableItem tradableItem; Guid productId = shopItemData.ProductId; Guid itemId = shopItemData.ItemId; long requiredBlockIndex = shopItemData.RequiredBlockIndex; ItemSubType itemSubType; if (shopItemData.ItemType == ItemType.Equipment) { var itemUsable = ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); tradableItem = itemUsable; itemSubType = itemUsable.ItemSubType; } else if (shopItemData.ItemType == ItemType.Costume) { var costume = ItemFactory.CreateCostume(_tableSheets.CostumeItemSheet.First, itemId); costume.Update(requiredBlockIndex); tradableItem = costume; itemSubType = costume.ItemSubType; } else { var material = ItemFactory.CreateTradableMaterial( _tableSheets.MaterialItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Hourglass)); material.RequiredBlockIndex = requiredBlockIndex; tradableItem = material; itemSubType = ItemSubType.Hourglass; } var result = new DailyReward2.DailyRewardResult() { id = default,
public void Execute( ItemType itemType, string guid, int itemCount, int inventoryCount, int expectedCount, bool backward ) { var avatarState = _initialState.GetAvatarState(_avatarAddress); ITradableItem tradableItem; Guid itemId = new Guid(guid); Guid orderId = Guid.NewGuid(); ItemSubType itemSubType; const long requiredBlockIndex = Order.ExpirationInterval; if (itemType == ItemType.Equipment) { var itemUsable = ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); tradableItem = itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) { var costume = ItemFactory.CreateCostume(_tableSheets.CostumeItemSheet.First, itemId); costume.Update(requiredBlockIndex); tradableItem = costume; itemSubType = costume.ItemSubType; } else { var material = ItemFactory.CreateTradableMaterial( _tableSheets.MaterialItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Hourglass)); itemSubType = material.ItemSubType; material.RequiredBlockIndex = requiredBlockIndex; tradableItem = material; } var result = new DailyReward2.DailyRewardResult() { id = default,
public void Execute() { var dailyRewardAction = new DailyReward2 { avatarAddress = _avatarAddress, }; var nextState = dailyRewardAction.Execute(new ActionContext { BlockIndex = 0, PreviousStates = _initialState, Rehearsal = false, Signer = _agentAddress, }); var gameConfigState = nextState.GetGameConfigState(); var nextAvatarState = nextState.GetAvatarState(_avatarAddress); Assert.Equal(gameConfigState.ActionPointMax, nextAvatarState.actionPoint); }
public void Execute(params OrderData[] orderDataList) { AvatarState buyerAvatarState = _initialState.GetAvatarState(_buyerAvatarAddress); List <PurchaseInfo> purchaseInfos = new List <PurchaseInfo>(); ShopState legacyShopState = _initialState.GetShopState(); foreach (var orderData in orderDataList) { (AvatarState sellerAvatarState, AgentState sellerAgentState) = CreateAvatarState( orderData.SellerAgentAddress, orderData.SellerAvatarAddress ); ITradableItem tradableItem; Guid orderId = orderData.OrderId; Guid itemId = orderData.TradableId; ItemSubType itemSubType; if (orderData.ItemType == ItemType.Equipment) { var itemUsable = ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, itemId, 0); tradableItem = itemUsable; itemSubType = itemUsable.ItemSubType; } else if (orderData.ItemType == ItemType.Costume) { var costume = ItemFactory.CreateCostume(_tableSheets.CostumeItemSheet.First, itemId); tradableItem = costume; itemSubType = costume.ItemSubType; } else { var material = ItemFactory.CreateTradableMaterial( _tableSheets.MaterialItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Hourglass)); tradableItem = material; itemSubType = ItemSubType.Hourglass; } var result = new DailyReward2.DailyRewardResult() { id = default,