コード例 #1
0
        public HackAndSlash10Test()
        {
            _sheets      = TableSheetsImporter.ImportSheets();
            _tableSheets = new TableSheets(_sheets);

            var privateKey = new PrivateKey();

            _agentAddress = privateKey.PublicKey.ToAddress();
            var agentState = new AgentState(_agentAddress);

            _avatarAddress = _agentAddress.Derive("avatar");
            var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]);

            _rankingMapAddress = _avatarAddress.Derive("ranking_map");
            _avatarState       = new AvatarState(
                _avatarAddress,
                _agentAddress,
                0,
                _tableSheets.GetAvatarSheets(),
                gameConfigState,
                _rankingMapAddress
                )
            {
                level = 100,
            };
            _inventoryAddress        = _avatarAddress.Derive(LegacyInventoryKey);
            _worldInformationAddress = _avatarAddress.Derive(LegacyWorldInformationKey);
            _questListAddress        = _avatarAddress.Derive(LegacyQuestListKey);
            agentState.avatarAddresses.Add(0, _avatarAddress);

            _weeklyArenaState = new WeeklyArenaState(0);

            _initialState = new State()
                            .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize())
                            .SetState(_agentAddress, agentState.SerializeV2())
                            .SetState(_avatarAddress, _avatarState.SerializeV2())
                            .SetState(_inventoryAddress, _avatarState.inventory.Serialize())
                            .SetState(_worldInformationAddress, _avatarState.worldInformation.Serialize())
                            .SetState(_questListAddress, _avatarState.questList.Serialize())
                            .SetState(_rankingMapAddress, new RankingMapState(_rankingMapAddress).Serialize())
                            .SetState(gameConfigState.address, gameConfigState.Serialize());

            foreach (var(key, value) in _sheets)
            {
                _initialState = _initialState
                                .SetState(Addresses.TableSheet.Derive(key), value.Serialize());
            }

            foreach (var address in _avatarState.combinationSlotAddresses)
            {
                var slotState = new CombinationSlotState(
                    address,
                    GameConfig.RequireClearedStageLevel.CombinationEquipmentAction);
                _initialState = _initialState.SetState(address, slotState.Serialize());
            }
        }
コード例 #2
0
        public void Execute(bool backward)
        {
            var dailyRewardAction = new DailyReward4
            {
                avatarAddress = _avatarAddress,
            };

            if (!backward)
            {
                AvatarState avatarState = _initialState.GetAvatarState(_avatarAddress);
                _initialState = _initialState
                                .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize())
                                .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), avatarState.worldInformation.Serialize())
                                .SetState(_avatarAddress.Derive(LegacyQuestListKey), avatarState.questList.Serialize())
                                .SetState(_avatarAddress, avatarState.SerializeV2());
            }

            var nextState = dailyRewardAction.Execute(new ActionContext
            {
                BlockIndex     = 0,
                PreviousStates = _initialState,
                Random         = new TestRandom(),
                Rehearsal      = false,
                Signer         = _agentAddress,
            });

            var gameConfigState = nextState.GetGameConfigState();
            var nextAvatarState = nextState.GetAvatarStateV2(_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);
        }
コード例 #3
0
        public ClaimMonsterCollectionReward2Test(ITestOutputHelper outputHelper)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Verbose()
                         .WriteTo.TestOutput(outputHelper)
                         .CreateLogger();

            _signer        = default;
            _avatarAddress = _signer.Derive("avatar");
            _state         = new State();
            Dictionary <string, string> sheets = TableSheetsImporter.ImportSheets();

            _tableSheets = new TableSheets(sheets);
            var rankingMapAddress = new PrivateKey().ToAddress();
            var agentState        = new AgentState(_signer);
            var avatarState       = new AvatarState(
                _avatarAddress,
                _signer,
                0,
                _tableSheets.GetAvatarSheets(),
                new GameConfigState(),
                rankingMapAddress);

            agentState.avatarAddresses[0] = _avatarAddress;

            var currency          = new Currency("NCG", 2, minters: null);
            var goldCurrencyState = new GoldCurrencyState(currency);

            _state = _state
                     .SetState(_signer, agentState.Serialize())
                     .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize())
                     .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), avatarState.worldInformation.Serialize())
                     .SetState(_avatarAddress.Derive(LegacyQuestListKey), avatarState.questList.Serialize())
                     .SetState(_avatarAddress, avatarState.SerializeV2())
                     .SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize());

            foreach ((string key, string value) in sheets)
            {
                _state = _state
                         .SetState(Addresses.TableSheet.Derive(key), value.Serialize());
            }
        }
コード例 #4
0
ファイル: DailyReward5Test.cs プロジェクト: dahlia/lib9c
 private IAccountStateDelta SetAvatarStateAsV2To(IAccountStateDelta state, AvatarState avatarState) =>
 state
 .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize())
 .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), avatarState.worldInformation.Serialize())
 .SetState(_avatarAddress.Derive(LegacyQuestListKey), avatarState.questList.Serialize())
 .SetState(_avatarAddress, avatarState.SerializeV2());