コード例 #1
0
        public Game(TypeOfGame kindOfGame)
        {
            IBoardFactory boardFactory = new BoardFactory();

            Chessboard   = (ChessboardModel)boardFactory.Create(kindOfGame);
            PlayerColour = ColourOfPiece.White;
        }
コード例 #2
0
 public GameOptions(TypeOfGame typeOfGame, Player player1, Player player2, PentagoNetwork networkUtil)
 {
     this._TypeOfGame = typeOfGame;
     this._Player1 = player1;
     this._Player2 = player2;
     this._NetworkUtil = networkUtil;
 }
コード例 #3
0
ファイル: GameOptions.cs プロジェクト: Bang-Bang-Studios/AI
 public GameOptions(TypeOfGame typeOfGame, string player1Name, Brush player1Color, computerAI.Difficulty difficulty)
 {
     this._TypeOfGame = typeOfGame;
     this._Player1Name = player1Name;
     this._Player1Color = player1Color;
     this._Difficulty = difficulty;
 }
コード例 #4
0
 public GameOptions(TypeOfGame typeOfGame, Player player1, Player player2, PentagoNetwork networkUtil)
 {
     this._TypeOfGame  = typeOfGame;
     this._Player1     = player1;
     this._Player2     = player2;
     this._NetworkUtil = networkUtil;
 }
コード例 #5
0
        public Game findOne(int id)
        {
            //log.InfoFormat("Entering findOne with value {0}", id);
            SQLiteConnection con = DBUtils.getConnection();

            using (var comm = new SQLiteCommand("SELECT * FROM Games WHERE id=@id", con)) {
                comm.Parameters.AddWithValue("@id", id);
                using (var dataR = comm.ExecuteReader()) {
                    if (dataR.Read())
                    {
                        int        idV        = dataR.GetInt32(0);
                        String     homeTeam   = dataR.GetString(1);
                        String     awayTeam   = dataR.GetString(2);
                        TypeOfGame type       = (TypeOfGame)Enum.Parse(typeof(TypeOfGame), dataR.GetString(3));
                        int        nrOfSeats  = dataR.GetInt32(4);
                        int        emptySeats = dataR.GetInt32(5);
                        float      price      = dataR.GetFloat(6);
                        Game       game       = new Game(idV, homeTeam, awayTeam, type, nrOfSeats, emptySeats, price);
                        //log.InfoFormat("Exiting findOne with value {0}", task);
                        return(game);
                    }
                }
            }
            //log.InfoFormat("Exiting findOne with value {0}", null);
            return(null);
        }
コード例 #6
0
ファイル: GameOptions.cs プロジェクト: Bang-Bang-Studios/AI
 public GameOptions(TypeOfGame typeOfGame, string player1Name, Brush player1Color, string player2Name, Brush player2Color)
 {
     this._TypeOfGame = typeOfGame;
     this._Player1Name = player1Name;
     this._Player1Color = player1Color;
     this._Player2Name = player2Name;
     this._Player2Color = player2Color;
 }
コード例 #7
0
 public Game(int id, string homeTeam, string awayTeam, TypeOfGame type, int totalNrOfSeats, int nrOfEmptySeats, float price)
 {
     Id             = id;
     HomeTeam       = homeTeam;
     AwayTeam       = awayTeam;
     Type           = type;
     TotalNrOfSeats = totalNrOfSeats;
     NrOfEmptySeats = nrOfEmptySeats;
     Price          = price;
 }
コード例 #8
0
        public IBoard Create(TypeOfGame kind)
        {
            IPieceFactory pieceFactory = new ChessPieceFactory();

            switch (kind)
            {
            case TypeOfGame.Chess:

                IBoard chessboard = new ChessboardModel(new ChessMovie());

                //a1 - h1
                chessboard.Fields[0, 0].Piece = pieceFactory.Create(ColourOfPiece.White, KindOfPiece.Rook);
                chessboard.Fields[1, 0].Piece = pieceFactory.Create(ColourOfPiece.White, KindOfPiece.Knight);
                chessboard.Fields[2, 0].Piece = pieceFactory.Create(ColourOfPiece.White, KindOfPiece.Bishop);
                chessboard.Fields[3, 0].Piece = pieceFactory.Create(ColourOfPiece.White, KindOfPiece.Queen);
                chessboard.Fields[4, 0].Piece = pieceFactory.Create(ColourOfPiece.White, KindOfPiece.King);
                chessboard.Fields[5, 0].Piece = pieceFactory.Create(ColourOfPiece.White, KindOfPiece.Bishop);
                chessboard.Fields[6, 0].Piece = pieceFactory.Create(ColourOfPiece.White, KindOfPiece.Knight);
                chessboard.Fields[7, 0].Piece = pieceFactory.Create(ColourOfPiece.White, KindOfPiece.Rook);
                //a2 - h2
                for (int i = 0; i < 8; i++)
                {
                    chessboard.Fields[i, 1].Piece = pieceFactory.Create(ColourOfPiece.White, KindOfPiece.Pawn);
                }
                //a7 - h7
                for (int i = 0; i < 8; i++)
                {
                    chessboard.Fields[i, 6].Piece = pieceFactory.Create(ColourOfPiece.Black, KindOfPiece.Pawn);
                }
                //a8 - h8
                chessboard.Fields[0, 6].Piece = pieceFactory.Create(ColourOfPiece.Black, KindOfPiece.Rook);
                chessboard.Fields[1, 6].Piece = pieceFactory.Create(ColourOfPiece.Black, KindOfPiece.Knight);
                chessboard.Fields[2, 6].Piece = pieceFactory.Create(ColourOfPiece.Black, KindOfPiece.Bishop);
                chessboard.Fields[3, 6].Piece = pieceFactory.Create(ColourOfPiece.Black, KindOfPiece.Queen);
                chessboard.Fields[4, 6].Piece = pieceFactory.Create(ColourOfPiece.Black, KindOfPiece.King);
                chessboard.Fields[5, 6].Piece = pieceFactory.Create(ColourOfPiece.Black, KindOfPiece.Bishop);
                chessboard.Fields[6, 6].Piece = pieceFactory.Create(ColourOfPiece.Black, KindOfPiece.Knight);
                chessboard.Fields[7, 6].Piece = pieceFactory.Create(ColourOfPiece.Black, KindOfPiece.Rook);

                return(chessboard);

            case TypeOfGame.Checkers:
                return(null);

            default:
                return(null);
            }
        }
コード例 #9
0
ファイル: Game.cs プロジェクト: NoamGaloz/TikTacToe
        public void Init()
        {
            int boardSize = m_Ui.GetBoardSizeFromUser();

            m_Board   = new Board(boardSize);
            m_Player1 = new Player(WhoIsPlaying.Player1, 'O');
            m_Ui.PrintMenu();
            TypeOfGame type = m_Ui.GetTypeOfGame();

            m_Type = type;
            if (m_Type == TypeOfGame.PlayerVsComputer)
            {
                m_Player2 = new Player(WhoIsPlaying.Computer, 'X');
            }
            else
            {
                m_Player2 = new Player(WhoIsPlaying.Player2, 'X');
            }
        }
コード例 #10
0
        public IEnumerable <Game> findAll()
        {
            SQLiteConnection con   = DBUtils.getConnection();
            IList <Game>     games = new List <Game>();

            using (var comm = new SQLiteCommand("SELECT * FROM Games", con)) {
                using (SQLiteDataReader dataR = comm.ExecuteReader()) {
                    while (dataR.Read())
                    {
                        int        idV        = dataR.GetInt32(0);
                        String     homeTeam   = dataR.GetString(1);
                        String     awayTeam   = dataR.GetString(2);
                        TypeOfGame type       = (TypeOfGame)Enum.Parse(typeof(TypeOfGame), dataR.GetString(3));
                        int        nrOfSeats  = dataR.GetInt32(4);
                        int        emptySeats = dataR.GetInt32(5);
                        float      price      = dataR.GetFloat(6);
                        Game       game       = new Game(idV, homeTeam, awayTeam, type, nrOfSeats, emptySeats, price);
                        games.Add(game);
                    }
                }
            }
            return(games);
        }
コード例 #11
0
 public GameOptions(TypeOfGame typeOfGame, Player player1, computerAI computerPlayer)
 {
     this._TypeOfGame     = typeOfGame;
     this._Player1        = player1;
     this._ComputerPlayer = computerPlayer;
 }
コード例 #12
0
 public GameOptions(TypeOfGame typeOfGame, Player player1, Player player2)
 {
     this._TypeOfGame = typeOfGame;
     this._Player1    = player1;
     this._Player2    = player2;
 }
コード例 #13
0
 public GameOptions(TypeOfGame typeOfGame, Player player1, computerAI computerPlayer)
 {
     this._TypeOfGame = typeOfGame;
     this._Player1 = player1;
     this._ComputerPlayer = computerPlayer;
 }
コード例 #14
0
ファイル: MainScript.cs プロジェクト: paulhare93/G5_Kwadraty
 void LoadSceneDownloadAB(string gN, TypeOfGame type)
 {
     gameType = type;
     Debug.Log(gameType);
     DownloadFile.gameCodeName = gN;
     Application.LoadLevel("downloadAB");
     
     
 }
コード例 #15
0
 public GameOptions(TypeOfGame typeOfGame, Player player1, Player player2)
 {
     this._TypeOfGame = typeOfGame;
     this._Player1 = player1;
     this._Player2 = player2;
 }
コード例 #16
0
 public GameOptions(TypeOfGame typeOfGame, Player player1, computerAI computerPlayer, int levelPlay)
 {
     this._TypeOfGame = typeOfGame;
     this._Player1 = player1;
     this._ComputerPlayer = computerPlayer;
     this._LevelPlay = levelPlay;
 }
コード例 #17
0
 /// <summary>
 /// Set le type de partie
 /// </summary>
 /// <param name="change"></param>
 public void SetToG(Dropdown change)
 {
     ToG = (TypeOfGame)(change.value + 2);
 }
コード例 #18
0
 public DartGame(List <Player> players, TypeOfGame GameType)
 {
     _players  = players;
     _gameType = GameType;
 }
コード例 #19
0
 public DartGame(TypeOfGame GameType)
 {
     _gameType = GameType;
 }
コード例 #20
0
ファイル: Darts.aspx.cs プロジェクト: RebekahColon/DartsGame
        private void PlayGame()
        {
            // Get the list of player names entered
            // If there is text, create a new player object and set its Name property
            List <Player>  players     = new List <Player>();
            List <TextBox> playerNames = new List <TextBox>()
            {
                txtPlayer1, txtPlayer2, txtPlayer3, txtPlayer4
            };

            playerNames.ForEach(pn => { if (!string.IsNullOrWhiteSpace(pn.Text))
                                        {
                                            players.Add(new Player(pn.Text));
                                        }
                                });

            // Throw an error if no players have been set
            if (players.Count == 0)
            {
                throw new Exception(MIN_PLAYER_ERROR);
            }

            // Get the gametype selected
            TypeOfGame gameType = ddlWinningThreshold.SelectedIndex == WINNING_ROUND_DDL_INDEX ? TypeOfGame.High_Score_At_End_Of_Fixed_Rounds : TypeOfGame.High_Score_Beats_Max_Score;

            // Create the game object now that we have players and gameType
            DartGame game = new DartGame(players, gameType);

            // Set max rounds or points if user entered valid data, else use the game's default
            int userMax;

            if (gameType == TypeOfGame.High_Score_At_End_Of_Fixed_Rounds)
            {
                if (!IsValueGreaterThanZero(txtMaxRounds.Text, out userMax))
                {
                    game.SetDefaultRounds();
                }
                else
                {
                    game.WinningRound = userMax;
                }
            }
            else
            {
                if (!IsValueGreaterThanZero(txtMaxPoints.Text, out userMax))
                {
                    game.SetDefaultScore();
                }
                else
                {
                    game.WinningScore = userMax;
                }
            }

            // Start the game
            game.Start();

            // Display the winner's name and handle if there is no winner or there was a tie
            List <Player> winners = game.Players.Where(p => p.IsWinner).ToList();
            StringBuilder sb      = new StringBuilder();

            lblWinnerName.Text = (winners.Count == 0) ? NoWinnerText
                : (winners.Count == 1) ? winners[0].Name
                : ConcatWinnerNames(winners);

            // Populate results viewmodel to display on UI
            foreach (Player p in game.Players)
            {
                ResultsViewModel resultsModel = new ResultsViewModel()
                {
                    Player = p
                };
                List <DartScoreViewModel> dartScoreModels = new List <DartScoreViewModel>();
                for (int i = 0; i < p.DartThrowScores.Count; i++)
                {
                    dartScoreModels.Add(new DartScoreViewModel()
                    {
                        Throw         = i + 1,
                        Points        = p.DartThrowScores[i].ThrowPoints,
                        BoardPosition = p.DartThrowScores[i].ToString()
                    });
                }
                resultsModel.DartScoreViewModels = dartScoreModels;
                Results.Add(resultsModel);
            }

            // Show Results
            divGameSetup.Visible   = false;
            divGameResults.Visible = true;
        }