Example #1
0
        private static KgsGameInfo CreateGameInfo(GameChannel channel)
        {
            if (channel.GameType != GameType.Free &&
                channel.GameType != GameType.Ranked)
            {
                return(null);
            }

            var whiteInfo = new PlayerInfo(StoneColor.White, channel.Players["white"].Name,
                                           channel.Players["white"].Rank ?? "??");
            var blackInfo = new PlayerInfo(StoneColor.Black, channel.Players["black"].Name,
                                           channel.Players["black"].Rank ?? "??");
            string ruleset = channel.Rules ?? RulesDescription.RulesJapanese;

            if (!KgsHelpers.IsSupportedRuleset(ruleset))
            {
                return(null);
            }
            var kgi = new KgsGameInfo(
                whiteInfo,
                blackInfo,
                new GameBoardSize(channel.Size),
                KgsHelpers.ConvertRuleset(ruleset),
                channel.Handicap,
                KgsGameInfo.GetHandicapPlacementType(KgsHelpers.ConvertRuleset(ruleset)),
                channel.Komi,
                CountingType.Area,
                channel.ChannelId);

            return(kgi);
        }
Example #2
0
        public static KgsGameInfo FromGameJoin(KgsGameJoin kgsGameJoin)
        {
            var whiteInfo = new PlayerInfo(StoneColor.White,
                                           kgsGameJoin.GameSummary.Players["white"].Name,
                                           kgsGameJoin.GameSummary.Players["white"].Rank);
            var blackInfo = new PlayerInfo(StoneColor.Black,
                                           kgsGameJoin.GameSummary.Players["black"].Name,
                                           kgsGameJoin.GameSummary.Players["black"].Rank);
            var rules = kgsGameJoin.Rules;

            if (rules == null)
            {
                return(null);
            }
            if (!KgsHelpers.IsSupportedRuleset(rules.Rules))
            {
                return(null);
            }
            var kgi = new KgsGameInfo(
                whiteInfo,
                blackInfo,
                new Game.GameBoardSize(rules.Size),
                KgsHelpers.ConvertRuleset(rules.Rules),
                rules.Handicap,
                GetHandicapPlacementType(KgsHelpers.ConvertRuleset(rules.Rules)),
                rules.Komi,
                CountingType.Area,
                kgsGameJoin.ChannelId);

            return(kgi);
        }
Example #3
0
 public static KgsTrueGameChannel FromGameInfo(KgsGameInfo info, int channelId)
 {
     return(new Structures.KgsTrueGameChannel(channelId, info));
 }
Example #4
0
 public override void UpdateFrom(GameChannel gameChannel)
 {
     _gameInfo = CreateGameInfo(gameChannel);
 }
Example #5
0
 private KgsTrueGameChannel(int channelId, KgsGameInfo gameInfo) : base(channelId)
 {
     this._gameInfo = gameInfo;
 }
Example #6
0
 protected bool Equals(KgsGameInfo other)
 {
     return(ChannelId == other.ChannelId);
 }