private void ExecutePropertyRemoval(KgsSgfProperty prop, KgsGame ongame) { switch (prop.Name) { case "DEAD": if (ongame.Controller.Phase.Type != Modes.LiveGame.Phases.GamePhaseType.LifeDeathDetermination) { ongame.Controller.SetPhase(Modes.LiveGame.Phases.GamePhaseType.LifeDeathDetermination); } ongame.Controller.BlackDoneReceived = false; ongame.Controller.WhiteDoneReceived = false; ongame.Controller.KgsConnector.ForceRevivifyGroup( new Position(prop.Loc.X, KgsCoordinates.TheirsToOurs(prop.Loc.Y, ongame.Info.BoardSize))); break; default: break; } }
private void ExecuteProperty(KgsSgfProperty prop, KgsGame ongame) { switch (prop.Name) { case "RULES": RulesDescription rules = prop; ongame.Info.BoardSize = new GameBoardSize(rules.Size); foreach (var player in ongame.Controller.Players) { player.Clock = rules.CreateTimeControl(); } ongame.Info.NumberOfHandicapStones = rules.Handicap; ongame.Info.Komi = rules.Komi; ongame.Info.RulesetType = KgsHelpers.ConvertRuleset(rules.Rules); // (future work) TODO (Petr) ensure that even written late, these values are respected break; case "PLAYERNAME": case "PLAYERRANK": case "DATE": case "PLACE": // We do not need this information - we already have some and don't need the trest. break; case "PHANTOMCLEAR": // I don't know what to do with this yet. break; case "ADDSTONE": ongame.Controller.AddHandicapStonePosition(new Position(prop.Loc.X, KgsCoordinates.TheirsToOurs(prop.Loc.Y, ongame.Info.BoardSize))); break; case "COMMENT": // "Putti [2k]: hi\n string[] splitByNewlines = prop.Text.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (var s in splitByNewlines) { var tuple = KgsRegex.ParseCommentAsChat(s); if (tuple != null) { var chatMessage = new ChatMessage(tuple.Item1, tuple.Item2, DateTimeOffset.Now, tuple.Item1 == ongame.Controller.Server.Username ? ChatMessageKind.Outgoing : ChatMessageKind.Incoming); ongame.Controller.KgsConnector.ChatMessageFromServer(chatMessage); } } break; case "DEAD": if (ongame.Controller.Phase.Type != Modes.LiveGame.Phases.GamePhaseType.LifeDeathDetermination) { ongame.Controller.SetPhase(Modes.LiveGame.Phases.GamePhaseType.LifeDeathDetermination); } ongame.Controller.BlackDoneReceived = false; ongame.Controller.WhiteDoneReceived = false; ongame.Controller.KgsConnector.ForceKillGroup(new Position(prop.Loc.X, KgsCoordinates.TheirsToOurs(prop.Loc.Y, ongame.Info.BoardSize))); break; case "TIMELEFT": StoneColor colorTimeLeft = (prop.Color == "black" ? StoneColor.Black : StoneColor.White); ongame.Controller.Players[colorTimeLeft].Clock.UpdateFromKgsFloat(prop.Float); break; case "MOVE": Move move; string propColor = prop.Color; StoneColor color = propColor == "white" ? StoneColor.White : StoneColor.Black; if (!prop.Loc.IsPass) { XY whereTo = prop.Loc; Position position = new Game.Position(whereTo.X, KgsCoordinates.TheirsToOurs(whereTo.Y, ongame.Info.BoardSize)); move = Move.PlaceStone(color, position); } else { move = Move.Pass(color); } foreach (var player in ongame.Controller.Players) { if (player.Agent is KgsAgent) { ((KgsAgent)player.Agent).StoreMove(this.Layer, color, move); } } break; default: break; } }