コード例 #1
0
        public void WriteInDB(int numberButton)
        {
            using (GamingPlatformDB_v4Entities writeMove = new GamingPlatformDB_v4Entities())
            {
                List <TicTacMatch> list   = writeMove.TicTacMatches.ToList();
                TicTacMatch        result = new TicTacMatch();
                result = list.Find(item => item.IDTable == position.IDTable);
                try
                {
                    writeMove.SaveChanges();
                }
                catch (DbEntityValidationException d)
                {
                    MessageBox.Show(d.Message);
                }

                char[]        str           = result.FEN.ToCharArray();
                StringBuilder stringBuilder = new StringBuilder(result.FEN);

                if (stringBuilder[0] == 'K')
                {
                    stringBuilder[0]            = 'N';
                    stringBuilder[numberButton] = '1';
                }
                else if (stringBuilder[0] == 'N')
                {
                    stringBuilder[0]            = 'K';
                    stringBuilder[numberButton] = '2';
                }

                result.FEN = stringBuilder.ToString();
                writeMove.SaveChanges();
            }
        }
コード例 #2
0
        public void Play()
        {
            int IDEmptyUser = 6;

            while (true)
            {
                using (GamingPlatformDB_v4Entities d = new GamingPlatformDB_v4Entities())
                {
                    List <TicTacMatch> list   = d.TicTacMatches.ToList();
                    List <Player>      listP  = d.Players.ToList();
                    TicTacMatch        result = new TicTacMatch();
                    Player             player = new Player();
                    player = listP.Find(item => item.IDPlayer == ActiveUser.UserId);
                    if (position.IDTable == 0)
                    {
                        result           = list.Find(item => item.StatusMatch == 0); //0-wait, 1-play 2-
                        position.IDTable = result.IDTable;
                        if (result.Player.IDPlayer == IDEmptyUser)                   //left user
                        {
                            position.yourMove = true;
                            result.Player     = player;
                            position.User1    = result.Player.LoginUser;
                        }
                        else if (result.Player1.IDPlayer == IDEmptyUser)
                        {
                            position.yourMove  = false;
                            position.User2     = result.Player1.LoginUser;
                            result.Player1     = player;
                            result.StatusMatch = 1;
                        }
                    }
                    else
                    {
                        result         = list.Find(item => item.IDTable == position.IDTable);
                        position.FEN   = result.FEN;
                        position.User1 = result.Player.LoginUser;
                        position.User2 = result.Player1.LoginUser;
                        if (position.CheckWinLose() == 1)
                        {
                            MessageBox.Show(position.User1 + " победил");
                            break;
                        }
                        else if (position.CheckWinLose() == 2)
                        {
                            MessageBox.Show(position.User2 + " победил");
                            break;
                        }
                        else if (position.CheckWinLose() == 3)
                        {
                            MessageBox.Show("ничья");
                            break;
                        }
                    }

                    d.SaveChanges();
                }
            }
        }
コード例 #3
0
        //private GamesStats game;
        public ShowStats(GamesStats game)
        {
            InitializeComponent();
            using (GamingPlatformDB_v4Entities entities = new GamingPlatformDB_v4Entities())
            {
                List <GameBall>        gameBall;
                List <GameSwitch>      gameSwitch;
                List <GameMine>        gameMine;
                List <GameTetri>       gameTetris;
                List <SnakeGame>       gameSnake;
                List <MemoryCardsGame> gameMemoryCards;
                switch (game)
                {
                case GamesStats.Ball:
                    gameBall      = entities.GameBalls.OrderByDescending(s => s.BestScore).ToList();
                    nameGame.Text = "Ball";
                    place1.Text   = "1. " + gameBall[0].Player.LoginUser + "(" + gameBall[0].BestScore + ")";
                    place2.Text   = "2. " + gameBall[1].Player.LoginUser + "(" + gameBall[1].BestScore + ")";
                    place3.Text   = "3. " + gameBall[2].Player.LoginUser + "(" + gameBall[2].BestScore + ")";
                    place4.Text   = "4. " + gameBall[3].Player.LoginUser + "(" + gameBall[3].BestScore + ")";
                    break;

                case GamesStats.Mines:
                    gameMine      = entities.GameMines.OrderBy(s => s.BestScore).ToList();
                    nameGame.Text = "Switch";
                    place1.Text   = "1. " + gameMine[0].Player.LoginUser + "(" + gameMine[0].BestScore + ")";
                    place2.Text   = "2. " + gameMine[1].Player.LoginUser + "(" + gameMine[1].BestScore + ")";
                    place3.Text   = "3. " + gameMine[2].Player.LoginUser + "(" + gameMine[2].BestScore + ")";
                    place4.Text   = "4. " + gameMine[3].Player.LoginUser + "(" + gameMine[3].BestScore + ")";
                    break;

                case GamesStats.Tetris:
                    gameTetris    = entities.GameTetris.OrderByDescending(s => s.BestScore).ToList();
                    nameGame.Text = "Tetris";
                    place1.Text   = "1. " + gameTetris[0].Player.LoginUser + "(" + gameTetris[0].BestScore + ")";
                    place2.Text   = "2. " + gameTetris[1].Player.LoginUser + "(" + gameTetris[1].BestScore + ")";
                    place3.Text   = "3. " + gameTetris[2].Player.LoginUser + "(" + gameTetris[2].BestScore + ")";
                    place4.Text   = "4. " + gameTetris[3].Player.LoginUser + "(" + gameTetris[3].BestScore + ")";
                    break;

                case GamesStats.Switch:
                    gameSwitch    = entities.GameSwitches.OrderBy(s => s.BestScore).ToList();
                    nameGame.Text = "Minesweapper";
                    place1.Text   = "1. " + gameSwitch[0].Player.LoginUser + "(" + gameSwitch[0].BestScore + ")";
                    place2.Text   = "2. " + gameSwitch[1].Player.LoginUser + "(" + gameSwitch[1].BestScore + ")";
                    place3.Text   = "3. " + gameSwitch[2].Player.LoginUser + "(" + gameSwitch[2].BestScore + ")";
                    place4.Text   = "4. " + gameSwitch[3].Player.LoginUser + "(" + gameSwitch[3].BestScore + ")";
                    break;

                case GamesStats.Snake:
                    gameSnake     = entities.SnakeGames.OrderByDescending(s => s.BestScore).ToList();
                    nameGame.Text = "Snake";
                    place1.Text   = "1. " + gameSnake[0].Player.LoginUser + "(" + gameSnake[0].BestScore + ")";
                    place2.Text   = "2. " + gameSnake[1].Player.LoginUser + "(" + gameSnake[1].BestScore + ")";
                    place3.Text   = "3. " + gameSnake[2].Player.LoginUser + "(" + gameSnake[2].BestScore + ")";
                    place4.Text   = "4. " + gameSnake[3].Player.LoginUser + "(" + gameSnake[3].BestScore + ")";
                    break;

                case GamesStats.MemoryCards:
                    gameMemoryCards = entities.MemoryCardsGames.OrderByDescending(s => s.BestScore).ToList();
                    nameGame.Text   = "MemoryCards";
                    place1.Text     = "1. " + gameMemoryCards[0].Player.LoginUser + "(" + gameMemoryCards[0].BestScore + ")";
                    place2.Text     = "2. " + gameMemoryCards[1].Player.LoginUser + "(" + gameMemoryCards[1].BestScore + ")";
                    place3.Text     = "3. " + gameMemoryCards[2].Player.LoginUser + "(" + gameMemoryCards[2].BestScore + ")";
                    place4.Text     = "4. " + gameMemoryCards[3].Player.LoginUser + "(" + gameMemoryCards[3].BestScore + ")";
                    break;
                }
            }
        }
コード例 #4
0
 public MineRepository()
 {
     this.db = new GamingPlatformDB_v4Entities();
 }
コード例 #5
0
 public MemoryCardsRepository()
 {
     this.db = new GamingPlatformDB_v4Entities();
 }
コード例 #6
0
 public SnakeRepositoty()
 {
     this.db = new GamingPlatformDB_v4Entities();
 }