예제 #1
0
        public void Execute()
        {
            var privateKey   = new PrivateKey();
            var agentAddress = privateKey.PublicKey.ToAddress();
            var agent        = new AgentState(agentAddress);

            var avatarAddress = agentAddress.Derive("avatar");
            var avatar        = new AvatarState(avatarAddress, agentAddress, 0, _tableSheets, new GameConfigState());

            agent.avatarAddresses.Add(0, avatarAddress);

            var weekly = new WeeklyArenaState(default(Address));

            weekly.Set(avatar, _tableSheets.CharacterSheet);
            weekly.End();

            var gold = new GoldCurrencyState(new Currency("NCG", minter: null));

            var state = new State(ImmutableDictionary <Address, IValue> .Empty
                                  .Add(default, weekly.Serialize())
예제 #2
0
        public async Task Query(bool ended)
        {
            const string query = @"
            {
                address
                ended
                orderedArenaInfos {
                    agentAddress
                    avatarAddress
                    arenaRecord {
                        win
                        lose
                        draw
                    }
                    level
                    combatPoint
                    armorId
                    active
                    dailyChallengeCount
                    score
                }
            }";

            var weeklyArenaState = new WeeklyArenaState(WeeklyArenaState.DeriveAddress(0));

            if (ended)
            {
                weeklyArenaState.End();
            }
            var queryResult = await ExecuteQueryAsync <WeeklyArenaStateType>(query, source : weeklyArenaState);

            Assert.Equal(
                new Dictionary <string, object>
            {
                ["address"]           = WeeklyArenaState.DeriveAddress(0).ToString(),
                ["ended"]             = ended,
                ["orderedArenaInfos"] = new List <object>(),
            },
                queryResult.Data
                );
        }