示例#1
0
        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(),
            }));
        }
示例#2
0
        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);
        }
示例#3
0
        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(),
            }));
        }
示例#4
0
        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(),
            }));
        }
示例#5
0
        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);
        }