public static Move ToMove(this Models.Move move) { return(new Move() { Coordinate = new Coordinate() { X = move.Coordinate.X, Y = move.Coordinate.Y }, Player = move.Player.ToPlayer(), Spell = move.Spell.ToSpell() }); }
private void insCard(Card card, Models.Move move) { string zone = ""; switch (move.Position) { case 1: zone = "Goalkeeper"; break; case 2: zone = "Defense"; break; case 3: zone = "Midfield"; break; case 4: zone = "Forwards"; break; default: zone = "AmPlMare"; break; } zone += PlayerProfile.Instance.Id; card.CardObject = (GameObject)Instantiate(Resources.Load(@"Prefabs\Card1")); card.CardObject.transform.SetParent(GameObject.FindGameObjectWithTag(zone).transform); card.CardObject.transform.localPosition = Utils.EXILVEC; card.CardObject.transform.localScale = Vector3.one; card.CardObject.transform.GetChild(0).GetChild(0).GetComponent <UnityEngine.UI.Image>().sprite = (Sprite)AssetDatabase.LoadAssetAtPath("Assets/Pictures/Cards/" + Mathf.RoundToInt(UnityEngine.Random.Range(1, 25)) + ".jpg", typeof(Sprite));; card.CardObject.transform.GetChild(2).GetComponent <UnityEngine.UI.Text>().text = card.Name.Length > 12 ? card.Name.Substring(0, 12) : card.Name; card.CardObject.transform.GetChild(5).GetComponent <UnityEngine.UI.Text>().text = card.Attack.ToString(); card.CardObject.transform.GetChild(6).GetComponent <UnityEngine.UI.Text>().text = card.Defense.ToString(); card.CardObject.transform.GetChild(3).GetComponent <UnityEngine.UI.Text>().text = card.Country; }
public async Task <GameProgress> PlayMove(PlayDTO play, int id) { var game = context.Game.Include(game => game.Moves).Where(game => game.Id == id).First(); var chess = chessService.ReplayMoves(game.Moves.ToList()); var move = chess.Move(play.SAN); var boardState = CoordinateOutput.GameToState(chess); if (boardState.whiteWins || boardState.isDraw || boardState.blackWins) { var moveRow = new Models.Move() { SAN = play.SAN, Game = game, CreatedAt = DateTime.Now }; context.Move.Add(moveRow); context.SaveChanges(); return(new GameProgress() { GameId = id, State = boardState }); } var aiMove = await chessService.GetAiMove(game.AIDifficulty, chess); var aiMoveSan = chess.board.StandardAlgebraicNotation(aiMove); chess.Move(aiMove); if (MoveHelper.isValidMove(move.move)) { var moveRow = new Models.Move() { SAN = play.SAN, Game = game, CreatedAt = DateTime.Now }; var aiMoveRow = new Models.Move() { SAN = aiMoveSan, Game = game, CreatedAt = DateTime.Now }; context.Move.Add(moveRow); context.Move.Add(aiMoveRow); context.SaveChanges(); } return(new GameProgress() { GameId = id, State = CoordinateOutput.GameToState(chess) }); }