예제 #1
0
        public IEnumerable <User> GetGameInvit()
        {
            var credentials = ControllerUtility.GetCredentials(Request.Headers);

            var sqlCommand = new SimpleSqlCommand <User>()
            {
                SqlCommand = "SELECT sender, c.id_cred, nickname from games_invitations join players p on (sender =  id_player) join credentials c on (c.id_cred = p.id_cred) WHERE reciever = (SELECT id_player FROM credentials c join players p on(c.id_cred =  p.id_cred) WHERE nickname = @nick)",
                Parameters = new SqlParameter[]
                {
                    new SqlParameter("@nick", SqlDbType.VarChar)
                    {
                        Value = credentials.login
                    }
                },
                ModelExtractor = reader => new User
                {
                    Id       = (int)reader[0],
                    Id_cred  = (int)reader[1],
                    nickname = (string)reader[2]
                }
            };

            return(sqlCommand.Execute());
        }
예제 #2
0
        public async Task Sets_NoSeason_NotFound()
        {
            var result = await testObj.Sets(0);

            ControllerUtility.AssertStatusCode(result, HttpStatusCode.NotFound);
        }
예제 #3
0
        public async Task ListForLeague_NoLeague_NotFound()
        {
            var result = await testObj.ListForLeague(0);

            ControllerUtility.AssertStatusCode(result, HttpStatusCode.NotFound);
        }
예제 #4
0
    public void RefreshImage()
    {
        if (ButtonType == EControllerBtns.None)
        {
            gameObject.SetActiveSafe(false);
            return;
        }
        if (_activeState)
        {
            gameObject.SetActiveSafe(true);
        }


        var style = InputDeviceStyle.Unknown;

        if (InputManager.Devices.Count > 0)
        {
            style = InputManager.Devices[InputManager.Devices.Count - 1].DeviceStyle;
        }

        _image     = GetComponentInChildren <UiImage>();
        _text      = GetComponentInChildren <UiText>();
        _text.text = "";
        switch (style)
        {
        case InputDeviceStyle.Unknown:
            //Pc显示方案
            var mouse = ControllerUtility.GetMouseType(ButtonType);
            if (mouse != Mouse.None)
            {
                var mouseImg = ControllerUtility.GetImageMouse(mouse);
                _image.SetSprite(EImagePath.Public, mouseImg);
            }
            else
            {
                var    key  = ControllerUtility.GetKeyBoardType(ButtonType);
                string text = "";
                var    img  = ControllerUtility.GetImageKeyboard(key, out text);
                _image.SetSprite(EImagePath.Public, img);
                _text.text = text;
            }
            break;

        case InputDeviceStyle.Ouya:
        case InputDeviceStyle.AppleMFi:
        case InputDeviceStyle.AmazonFireTV:
        case InputDeviceStyle.NVIDIAShield:
        case InputDeviceStyle.Steam:
        case InputDeviceStyle.Xbox360:
        case InputDeviceStyle.XboxOne:
        case InputDeviceStyle.Vive:
        case InputDeviceStyle.Oculus:
            //xbox 显示方案
            var imgStr = ControllerUtility.GetImageXBox(ControllerUtility.GetControlType(ButtonType));
            _image.SetSprite(EImagePath.Public, imgStr);
            break;

        case InputDeviceStyle.PlayStation2:
        case InputDeviceStyle.PlayStation3:
        case InputDeviceStyle.PlayStation4:
        case InputDeviceStyle.PlayStationVita:
        case InputDeviceStyle.PlayStationMove:
            //ps 显示方案
            var psImageStr = ControllerUtility.GetImagePlayStation(ControllerUtility.GetControlType(ButtonType));
            _image.SetSprite(EImagePath.Public, psImageStr);
            break;

        case InputDeviceStyle.NintendoNES:
        case InputDeviceStyle.NintendoSNES:
        case InputDeviceStyle.Nintendo64:
        case InputDeviceStyle.NintendoGameCube:
        case InputDeviceStyle.NintendoWii:
        case InputDeviceStyle.NintendoWiiU:
        case InputDeviceStyle.NintendoSwitch:
            //switch 显示方案
            var nintendoImageStr = ControllerUtility.GetImageNintendo(ControllerUtility.GetControlType(ButtonType));
            _image.SetSprite(EImagePath.Public, nintendoImageStr);
            break;
        }
    }
예제 #5
0
        public void Post([FromBody] Move value)
        {
            var credentials = ControllerUtility.GetCredentials(Request.Headers);

            var sqlCommand = new SimpleSqlCommand <User>()
            {
                SqlCommand = "EXECUTE addMove @mNick = @nick, @mX_coord = @xcoord, @mY_coord = @ycoord, @mId_game = @idgame",
                Parameters = new SqlParameter[]
                {
                    new SqlParameter("@idgame", SqlDbType.Int)
                    {
                        Value = value.IdGame
                    },
                    new SqlParameter("@xcoord", SqlDbType.Int)
                    {
                        Value = value.XCoord
                    },
                    new SqlParameter("@ycoord", SqlDbType.Int)
                    {
                        Value = value.YCoord
                    },
                    new SqlParameter("@nick", SqlDbType.VarChar)
                    {
                        Value = credentials.login
                    }
                }
            };

            sqlCommand.Execute();

            var sqlCommand1 = new SimpleSqlCommand <Move>()
            {
                SqlCommand = "EXECUTE returnMoves @vIdGame = @id",
                Parameters = new SqlParameter[]
                {
                    new SqlParameter("@id", SqlDbType.Int)
                    {
                        Value = value.IdGame
                    }
                },
                ModelExtractor = reader => new Move
                {
                    XCoord    = (int)reader[0],
                    YCoord    = (int)reader[1],
                    id_player = (int)reader[2],
                    IdGame    = value.IdGame
                }
            };

            var movesList = sqlCommand1.Execute();

            if (movesList.Count == 400)
            {
                var sqlCommandR = new SimpleSqlCommand <User>()
                {
                    SqlCommand = "EXECUTE addResult @vId_game = @idgame, @vId_Score = 0",
                    Parameters = new SqlParameter[]
                    {
                        new SqlParameter("@idgame", SqlDbType.Int)
                        {
                            Value = value.IdGame
                        }
                    }
                };

                sqlCommandR.Execute();
                return;
            }

            int[,] board = new int[20, 20];
            for (int y = 0; y < 20; y++)
            {
                for (int x = 0; x < 20; x++)
                {
                    board[x, y] = -1;
                }
            }
            foreach (var move in movesList)
            {
                board[move.XCoord, move.YCoord] = move.id_player;
            }

            int winner = 0;

            for (int y = 2; y < 18 && winner == 0; y++)
            {
                for (int x = 2; x < 18 && winner == 0; x++)
                {
                    if (board[x, y] == -1)
                    {
                        continue;
                    }
                    if (CheckVictory(board, x, y, 1, 0) ||
                        CheckVictory(board, x, y, 1, 1) ||
                        CheckVictory(board, x, y, 0, 1) ||
                        CheckVictory(board, x, y, -1, 1))
                    {
                        winner = board[x, y];
                    }
                }
            }

            if (winner != 0)
            {
                var sqlCommandW = new SimpleSqlCommand <User>()
                {
                    SqlCommand = "EXECUTE addResult @vId_game = @idgame, @vId_Score = @idwinner",
                    Parameters = new SqlParameter[]
                    {
                        new SqlParameter("@idgame", SqlDbType.Int)
                        {
                            Value = value.IdGame
                        },
                        new SqlParameter("@idwinner", SqlDbType.Int)
                        {
                            Value = winner
                        }
                    }
                };
                sqlCommandW.Execute();
            }
        }
예제 #6
0
        public async Task Get_NoUser_NotFound()
        {
            var result = await testObj.Get("");

            ControllerUtility.AssertStatusCode(result, HttpStatusCode.NotFound);
        }
예제 #7
0
 public ActionResult <List <EmployeeVm> > GetAllEmployees()
 {
     return(ControllerUtility.GetEmployee());
 }
        public IActionResult Edit(int id)
        {
            var emp = ControllerUtility.GetEmployee().FirstOrDefault(e => e.Id == id);

            return(View(emp));
        }
예제 #9
0
        public async Task GetSeasons_NoLeague_NotFound()
        {
            var result = await testObj.GetSeasons(0);

            ControllerUtility.AssertStatusCode(result, HttpStatusCode.NotFound);
        }