Exemple #1
0
        public void ExecuteCreateNextWeeklyArenaState()
        {
            var weekly          = new WeeklyArenaState(0);
            var gameConfigState = new GameConfigState();

            gameConfigState.Set(_tableSheets.GameConfigSheet);
            var state = _baseState
                        .SetState(weekly.address, weekly.Serialize())
                        .SetState(gameConfigState.address, gameConfigState.Serialize());
            var action = new RewardGold();

            var nextState = action.Execute(new ActionContext()
            {
                PreviousStates = state,
                Miner          = default,
Exemple #2
0
        public DailyReward5Test(ITestOutputHelper outputHelper)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Verbose()
                         .WriteTo.TestOutput(outputHelper)
                         .CreateLogger();

            _initialState = new State();
            var sheets = TableSheetsImporter.ImportSheets();

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

            var tableSheets     = new TableSheets(sheets);
            var gameConfigState = new GameConfigState();

            gameConfigState.Set(tableSheets.GameConfigSheet);
            _agentAddress = new PrivateKey().ToAddress();
            var agentState = new AgentState(_agentAddress);

            _avatarAddress = new PrivateKey().ToAddress();
            var rankingMapAddress = new PrivateKey().ToAddress();
            var avatarState       = new AvatarState(
                _avatarAddress,
                _agentAddress,
                0,
                tableSheets.GetAvatarSheets(),
                gameConfigState,
                rankingMapAddress)
            {
                actionPoint = 0,
            };

            agentState.avatarAddresses[0] = _avatarAddress;

            _initialState = _initialState
                            .SetState(Addresses.GameConfig, gameConfigState.Serialize())
                            .SetState(_agentAddress, agentState.Serialize())
                            .SetState(_avatarAddress, avatarState.Serialize());
        }
Exemple #3
0
        public void WeeklyArenaRankingBoard(bool resetCount, bool updateNext)
        {
            var weekly = new WeeklyArenaState(0);

            weekly.Set(_avatarState, _tableSheets.CharacterSheet);
            weekly[_avatarState.address].Update(weekly[_avatarState.address], BattleLog.Result.Lose);
            var gameConfigState = new GameConfigState();

            gameConfigState.Set(_tableSheets.GameConfigSheet);
            var state = _baseState
                        .SetState(weekly.address, weekly.Serialize())
                        .SetState(gameConfigState.address, gameConfigState.Serialize());
            var blockIndex = 0;

            if (resetCount)
            {
                blockIndex = gameConfigState.DailyArenaInterval;
            }

            if (updateNext)
            {
                weekly[_avatarState.address].Activate();
                blockIndex = gameConfigState.WeeklyArenaInterval;
                // Avoid NRE in test case.
                var nextWeekly = new WeeklyArenaState(1);
                state = state
                        .SetState(weekly.address, weekly.Serialize())
                        .SetState(nextWeekly.address, nextWeekly.Serialize());
            }

            Assert.False(weekly.Ended);
            Assert.Equal(4, weekly[_avatarState.address].DailyChallengeCount);

            var action = new RewardGold();

            var ctx = new ActionContext()
            {
                BlockIndex     = blockIndex,
                PreviousStates = _baseState,
                Miner          = default,