示例#1
0
        static void Main(string[] args)
        {
            var boardModel = new BoardModel();

            while (true)
            {
                BoardView.Show(boardModel);
                Console.WriteLine("Write shit yo");
                var validInput = true;
                do
                {
                    if (!validInput)
                    {
                        Console.WriteLine("Skriv igjen");
                    }
                    var pos = Console.ReadLine();

                    validInput = boardModel.setCross(pos);
                } while (!validInput);

                BoardView.Show(boardModel);
                Thread.Sleep(500);
                boardModel.setCircle();
            }
        }
示例#2
0
        static void Main()
        {
            //BoardView.Show();
            //BoardModel boardLogic = new BoardModel();
            //boardLogic.ModelLogic();
            var boardModel = new BoardModel();

            while (true)
            {
                GameLogic test = new GameLogic();
                BoardView.Show(boardModel);
                test.CheckVictoryCondition(boardModel);

                Console.Write("Type where you want to place X (e.g \"a2\"): ");
                var position = Console.ReadLine();
                boardModel.SetCross(position);

                if (CheckWinner(boardModel))
                {
                    break;
                }
                Thread.Sleep(2000);

                boardModel.SetRandomCircle();
                if (CheckWinner(boardModel))
                {
                    break;
                }
            }
            RestartProgram();
        }
示例#3
0
        static void Main(string[] args)
        {
            var    Spillerbrett = new BoardModel();
            string brukerinput;
            var    PlayAgain = true;

            while (PlayAgain == true)
            {
                while (Spillerbrett.Vunnet() == false)
                {
                    Console.Clear();
                    BoardView.ShowBoardModel(Spillerbrett);

                    System.Console.WriteLine("Spiller \"{0}\": Skriv inn koordinat (eks: \"a2\")", Spillerbrett.Spiller());
                    //System.Console.WriteLine($"Spiller \"{Spillerbrett.Spiller()}\": Skriv inn koordinat (eks: \"a2\")");
                    brukerinput = Console.ReadLine();
                    Spillerbrett.Board(brukerinput, Spillerbrett.Spiller());
                }
                BoardView.ShowBoardModel(Spillerbrett);

                System.Console.WriteLine($"Spiller {Spillerbrett.Spiller("Forrigespiller")} har vunnet!");
                var tekst = System.Console.ReadLine() == "y" ? PlayAgain = true : PlayAgain = false;
                Spillerbrett.SpillPaaNytt();
            }
        }
示例#4
0
        static bool CheckWinner(BoardModel bm)
        {
            GameLogic checkWinz = new GameLogic();
            var       checkWin  = checkWinz.CheckVictoryCondition(bm);

            if (!checkWin)
            {
                return(false);
            }
            BoardView.Show(bm);
            Console.WriteLine("");
            Console.WriteLine($"{GameLogic.Winner} won!");
            return(true);
        }
示例#5
0
        static void Main(string[] args)
        {
            var boardModel = new BoardModel();

            while (true)
            {
                BoardView.Show(boardModel);
                Console.Write("Skriv inn hvor du vil sette kryss (f.eks. \"a2\"): ");
                var position = Console.ReadLine();
                boardModel.SetCross(position);
                BoardView.Show(boardModel);

                Thread.Sleep(2000);
                boardModel.SetRandomCircle();
            }
        }
示例#6
0
文件: Program.cs 项目: Joranstr/C-
        static void Main(string[] args)
        {
            var boardModel = new BoardModel();

            while (true)
            {
                BoardView.Show(boardModel);
                Console.Write("Skriv inn hvor du vil sette kryss (f.eks. \"a2\"): ");
                var position = Console.ReadLine();
                var col      = position[0] - 'a';
                var row      = position[1] - '1';
                var index    = row * 3 + col;
                boardModel.SetPlayer1(index);
                BoardView.Show(boardModel);
                Thread.Sleep(700);
                var success = boardModel.SetRandomPlayer2();
                if (!success)
                {
                    return;
                }
            }
        }