Ejemplo n.º 1
0
 public WindowsFormUI()
 {
     r_GameSettings  = new GameSettings();
     m_CheckersLogic = null;
     m_GameForm      = null;
     m_DataGameOver  = null;
 }
Ejemplo n.º 2
0
 public void LaunchGame()
 {
     r_UIEngine.DisplayMainScreen();
     getGameInitializeParameters(out GameMode.eGameMode gameMode, out int boardSize, out string[] playersNames);
     r_UIEngine.CreateBoardUI(boardSize);
     m_GameLogic = new CheckersLogic(gameMode);
     startNewGame(gameMode, boardSize, playersNames);
 }
Ejemplo n.º 3
0
        public static string TheMoveToDoForMultiEating(CheckersLogic i_TheGameNow, string i_LastMove)
        {
            string activeToContinueEat = null;
            Locat  forChech            = new Locat((byte)(i_LastMove[3] - 'A'), (byte)(i_LastMove[4] - 'a'));
            Locat  yaad = new Locat();

            i_TheGameNow.CanToMultiEat(forChech, out yaad);
            activeToContinueEat = makeStringOfActive(forChech, yaad);


            return(activeToContinueEat);
        }
Ejemplo n.º 4
0
        public static string TheBestMoveToDoForPlayer2(CheckersLogic i_TheGameNow)
        {
            bool   foundActiveToDo   = false;
            string activeTheBestMove = null;

            foundActiveToDo = Player2CanToEat(i_TheGameNow, out activeTheBestMove);

            if (!foundActiveToDo)
            {
                foundActiveToDo = Player2CanToMove(i_TheGameNow, out activeTheBestMove);
            }

            return(activeTheBestMove);
        }
Ejemplo n.º 5
0
        private static bool Player2CanToEat(CheckersLogic i_TheGameNow, out string o_ActiveToEat)
        {
            o_ActiveToEat = null;
            bool  playerCanToEat = false;
            Locat yaad           = new Locat();

            foreach (var makor in i_TheGameNow.m_VellsOfPlayer2)
            {
                if (i_TheGameNow.player2CanToEat(makor, out yaad))
                {
                    o_ActiveToEat  = makeStringOfActive(makor, yaad);
                    playerCanToEat = true;
                    break;
                }
            }

            return(playerCanToEat);
        }
Ejemplo n.º 6
0
        private void initializeGameLogic(bool i_NewGame = true)
        {
            if (i_NewGame)
            {
                string[]           playerNames = { r_GameSettings.Player1, r_GameSettings.Player2 };
                GameMode.eGameMode gameMode    = getGameMode();

                m_CheckersLogic                = new CheckersLogic();
                m_CheckersLogic.KingSet       += gameLogic_KingSet;
                m_CheckersLogic.PlayerMoveSet += checkersLogic_PlayerMoveSet;
                m_CheckersLogic.TurnChanged   += gameLogic_TurnChanged;
                m_CheckersLogic.GameOver      += checkersLogic_GameOver;
                m_CheckersLogic.InitNewGame(gameMode, r_GameSettings.BoardSize, playerNames);
            }
            else
            {
                m_CheckersLogic.InitNewGame();
            }
        }
Ejemplo n.º 7
0
		/// <summary>
		/// Show a name inquiry dialog and perform necessary initialization before starting. The starting game type is selected based on "currentGameType".
		/// </summary>
		private void Window_Loaded(object sender, RoutedEventArgs e) {
			boardSizes = new List<int>(2);
			boardSizes.Add(8);
			boardSizes.Add(16);

			_board.Size = boardSizes[0];

			StartDialog dialog = new StartDialog();
			dialog.ShowDialog();

			if (dialog.PlayerNames[0].Trim() != "") {
				player1 = dialog.PlayerNames[0];
			}
			if (dialog.PlayerNames[1].Trim() != "") {
				player2 = dialog.PlayerNames[1];
			}

			game = new BoardGame(_board);
			IGameLogic gameLogic;
			switch (currentGameType) {
				case GameType.breakthrough:
					gameLogic = new BreakthroughLogic();
					break;
				default:
					gameLogic = new CheckersLogic();
					break;
			}
			game.Logic = gameLogic;

			game.GameOver += new EventHandler(GameOverHandler);
			game.TurnOver += new EventHandler(TurnChangedHandler);

			SetupGameStyles();

			DrawGameStarter();

			game.Start();
		}
Ejemplo n.º 8
0
 public CheckersGame()
 {
     r_UIEngine  = new ConsoleUI();
     m_GameLogic = null;
 }
Ejemplo n.º 9
0
		void GameTypeChangedHandler(Object sender, EventArgs e) {
			var args = (GameTypeEventArgs)e;
			GameType gameType = args.GameType;

			currentGameType = gameType;

			IGameLogic gameLogic;
			switch (gameType) {
				case GameType.breakthrough:
					gameLogic = new BreakthroughLogic();
					break;
				default:
					gameLogic = new CheckersLogic();
					break;
			}
			game.Logic = gameLogic;
			game.Start();
		}