Example #1
0
        /// <summary>
        /// Starts the initialization phase
        /// </summary>
        public override void StartPhase()
        {
            Controller.OnDebuggingMessage("Game begins!");
            bool thisIsAGoodFuegoGame = false;

            foreach (var player in Controller.Players)
            {
                if (player.Agent is AiAgent && (player.Agent as AiAgent).AI is Fuego)
                {
                    if (FuegoSingleton.Instance.CurrentGame != null && !thisIsAGoodFuegoGame)
                    {
                        // Fuego can't be in two games at once.
                        Controller.EndGame(GameEndInformation.CreateCancellation(Controller.Players));
                        return;
                    }
                    if (!thisIsAGoodFuegoGame)
                    {
                        FuegoSingleton.Instance.CurrentGame = Controller;
                        thisIsAGoodFuegoGame = true;
                    }
                }
                player.Agent.GameInitialized();
            }
            GoToPhase(GamePhaseType.HandicapPlacement);
        }
Example #2
0
        public override async Task <bool> CanCloseViewModelAsync()
        {
            if (this.GetType() == typeof(LocalGameViewModel) && this.Game.Controller.Phase.Type != GamePhaseType.Finished)
            {
                if (await
                    DialogService.ShowConfirmationDialogAsync(Localizer.ExitLocal_Text, Localizer.ExitLocal_Caption,
                                                              Localizer.ExitLocal_Confirm, Localizer.Exit_ReturnToGame))
                {
                    UiConnector.AiLog -= Assistant_uiConnector_AiLog;
                    await base.CanCloseViewModelAsync();

                    Game.Controller.EndGame(GameEndInformation.CreateCancellation(Game.Controller.Players));
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                UiConnector.AiLog -= Assistant_uiConnector_AiLog;
                await base.CanCloseViewModelAsync();

                return(true);
            }
        }
        public override async Task <bool> CanCloseViewModelAsync()
        {
            await(Game.Controller as RemoteGameController).Server.Commands.UnobserveAsync(Game.Info as RemoteGameInfo);
            await base.CanCloseViewModelAsync();

            Game.Controller.EndGame(GameEndInformation.CreateCancellation(Game.Controller.Players));
            return(true);
        }
Example #4
0
        public override void Process(KgsConnection connection)
        {
            var game       = connection.Data.GetGame(ChannelId);
            var controller = game.Controller;
            var players    = game.Controller.Players;
            var black      = game.Controller.Players.Black;
            var white      = game.Controller.Players.White;
            GameEndInformation gameEndInfo = null;

            if (Score.IsFloat)
            {
                if (Score.Float == 0)
                {
                    gameEndInfo = GameEndInformation.CreateDraw(controller.Players, new Rules.Scores(0, 0));
                }
                else
                {
                    if (Score.Float > 0)
                    {
                        gameEndInfo = GameEndInformation.CreateScoredGame(controller.Players.Black,
                                                                          controller.Players.White, new Rules.Scores(Score.Float, 0));
                    }
                    else
                    {
                        gameEndInfo = GameEndInformation.CreateScoredGame(controller.Players.White,
                                                                          controller.Players.Black, new Rules.Scores(0, -Score.Float));
                    }
                }
            }
            else
            {
                switch (Score.String)
                {
                case "B+RESIGN":
                case "B+FORFEIT":
                    gameEndInfo = GameEndInformation.CreateResignation(white, players);
                    break;

                case "W+RESIGN":
                case "W+FORFEIT":
                    gameEndInfo = GameEndInformation.CreateResignation(black, players);
                    break;

                case "B+TIME":
                    gameEndInfo = GameEndInformation.CreateTimeout(white, players);
                    break;

                case "W+TIME":
                    gameEndInfo = GameEndInformation.CreateTimeout(black, players);
                    break;

                case "NO_RESULT":
                    gameEndInfo = GameEndInformation.CreateDraw(players, new Rules.Scores(0, 0));
                    break;

                case "UNKNOWN":
                case "UNFINISHED":
                default:
                    gameEndInfo = GameEndInformation.CreateCancellation(players);
                    break;
                }
            }
            controller.KgsConnector.EndTheGame(gameEndInfo);
        }