예제 #1
0
        public static KgsChallenge FromChannel(GameChannel channel)
        {
            if (channel.GameType != GameType.Challenge)
            {
                return(null);
            }
            KgsChallenge challenge = new KgsChallenge(channel.InitialProposal, channel.ChannelId);

            if (channel.InitialProposal.GameType != GameType.Free &&
                channel.InitialProposal.GameType != GameType.Ranked)
            {
                return(null);
            }

            return(challenge);
        }
예제 #2
0
        public void AddChannel(GameChannel channel, KgsConnection connection)
        {
            var kChallenge = KgsChallenge.FromChannel(channel);

            if (kChallenge != null)
            {
                connection.Data.EnsureChannelExists(kChallenge);
                Challenges.Add(kChallenge);
                AllChannelsCollection.Add(kChallenge);
                return;
            }
            var kGame = KgsTrueGameChannel.FromChannel(channel);

            if (kGame != null)
            {
                connection.Data.EnsureChannelExists(kGame);
                Games.Add(kGame);
                AllChannelsCollection.Add(kGame);
                return;
            }
        }