public static bool PlayActionCard(int gameId, ETurn turn, int actionCardId) { var game = Load(gameId); if (game == null) { return(false); } if (!CanPlayActionCard(game)) { return(false); } if (game.Turn != turn) { //not your turn return(false); } var gamePlayer = game.GetPlayer(game.Turn); var card = gamePlayer.ActionCards.FirstOrDefault(x => x.Id == actionCardId && !x.Played); if (card == null) { //you don't have this card return(false); } gamePlayer.CurrentCard = card.Id; Save(game); return(true); }
public GamePlayer GetPlayer(ETurn turn) { if (turn == ETurn.First) { return(First); } return(Second); }
public bool Turn(string sPlayer, ETurn enTurn) { var pG = GetGame(sPlayer); if (pG == null) { throw new Exception(); } pG.LastDateTime = DateTime.Now; return(pG.Turn(sPlayer, enTurn)); }
public static bool AddPlayer(int gameId, ETurn turn, int actionCardId, int playerId) { var game = Load(gameId); if (game == null) { return(false); } if (!CanPlayActionCard(game)) { return(false); } var card = GetCurrentActionCard(game); if (card == null || card.Id != actionCardId) { //wrong card return(false); } //get attackers or defenders, depending on the turn. If game turn is identical to turn, then attackers, otherwise defenders var cardPlayers = turn == game.Turn ? card.Attackers : card.Defenders; if (cardPlayers.Count == card.PlayerLimit) { //player limit reach return(false); } if (cardPlayers.Any(x => x.Id == playerId)) { //player already selected on the card return(false); } //check against remaining players in team if there's one with the id and left stamina var firstOrSecond = turn == ETurn.First ? game.First : game.Second; var playerSelected = firstOrSecond.Players.FirstOrDefault(x => x.Id == playerId && x.Skills.Stamina > 0); if (playerSelected == null) { //inexistent or too tired return(false); } cardPlayers.Add(playerSelected); Save(game); return(true); }
private static bool CanChooseCaptain(Game game, ETurn turn) { var player = game.GetPlayer(turn); if (player.Confirmed) { //already confirmed for the current phase return(false); } return(new[] { EGameStatus.NotStarted, EGameStatus.HalfTime }.Contains(game.GameStatus)); }
public void GoalScored(ETurn turn) { switch (turn) { case ETurn.First: First += 1; break; case ETurn.Second: Second += 1; break; default: throw new ArgumentException("Invalid player turn"); } }
public bool Turn(string sPlayer, ETurn enTurn) { CPlayer pPl = PlayerList.First(p => p.Guid == sPlayer); if (State == EGameState.GameProcess) { pPl.Turn(enTurn); if (pPl.X == ExitX && pPl.Y == ExitY) { CurrentPlayer = sPlayer; State = EGameState.GameOver; } return(true); } return(false); }
// 턴 관리 void SetTurnState(ETurn NewTurnState) { if (TurnState == NewTurnState) { return; } Debug.Log("SetTurnState : " + TurnState + " -> " + NewTurnState); TurnState = NewTurnState; switch (NewTurnState) { case ETurn.Action: StartPlayerAction(); break; case ETurn.Wait: EndPlayerAction(); break; case ETurn.Calc: CalcResult(); break; } // 모든 공에 알림 foreach (GameObject Ball in Balls) { if (Ball == null) { continue; } BallController BC = Ball.GetComponent <BallController>(); if (BC == null) { continue; } BC.OnTurnStateChanged(NewTurnState); } }
public static bool Confirm(int gameId, ETurn turn) { var game = Load(gameId); if (game == null) { return(false); } if (game.GetPlayer(1 - turn).Confirmed) { EvaluateRound(game); } else { game.GetPlayer(turn).Confirmed = true; } Save(game); return(true); }
public void Turn(ETurn enTurn) { Count++; switch (enTurn) { case ETurn.Left: X--; break; case ETurn.Right: X++; break; case ETurn.Top: Y--; break; case ETurn.Bottom: Y++; break; } }
public static bool RemovePlayer(int gameId, ETurn turn, int actionCardId, int playerId) { var game = Load(gameId); if (game == null) { return(false); } if (!CanPlayActionCard(game)) { return(false); } var card = GetCurrentActionCard(game); if (card == null || card.Id != actionCardId) { //wrong card return(false); } //get attackers or defenders, depending on the turn. If game turn is identical to turn, then attackers, otherwise defenders var cardPlayers = turn == game.Turn ? card.Attackers : card.Defenders; var player = cardPlayers.FirstOrDefault(x => x.Id == playerId); if (player == null) { //player not found on the card return(false); } cardPlayers.Remove(player); Save(game); return(true); }
public static bool SetCaptain(int gameId, ETurn turn, int playerId) { var game = Load(gameId); if (game == null || !CanChooseCaptain(game, turn)) { return(false); } var players = game.GetPlayer(turn).Players; var player = players.FirstOrDefault(x => x.Id == playerId); if (player == null || player.Skills.Stamina <= 0) { //dead player can't be captain return(false); } players.ForEach(x => x.IsCaptain = false); player.IsCaptain = true; Save(game); return(true); }
public bool Turn(string sPlayer, ETurn enTurn) { return(m_pGame.Turn(sPlayer, enTurn)); }
public HttpResponseMessage SetCaptain(int gameId, ETurn turn, int playerId) { return(this.Response(() => GameManager.SetCaptain(gameId, turn, playerId))); }
public HttpResponseMessage Confirm(int gameId, ETurn turn) { return(this.Response(() => GameManager.Confirm(gameId, turn))); }
public HttpResponseMessage PlayActionCard(int gameId, ETurn turn, int actionCardId) { return(this.Response(() => GameManager.PlayActionCard(gameId, turn, actionCardId))); }
public HttpResponseMessage RemovePlayer(int gameId, ETurn turn, int actionCardId, int playerId) { return(this.Response(() => GameManager.RemovePlayer(gameId, turn, actionCardId, playerId))); }
public bool Turn(string sPlayer, ETurn enTurn) { return(base.Channel.Turn(sPlayer, enTurn)); }