public static TacticCard GetCard() { var nodes = new List<Node> { new Node {X = 0, Y = 0}, new Node {X = 0, Y = 1}, new Node {X = 0, Y = 2}, new Node {X = 0, Y = 3}, new Node {X = 1, Y = 0}, new Node {X = 1, Y = 1}, new Node {X = 1, Y = 2}, new Node {X = 1, Y = 3} }; var card = new TacticCard { Id = 5, Name = "Nailed", Difficulty = 3, Nodes = new List<Node>() { nodes.Where(x => x.X == 0 && x.Y == 2).First() }, StartNode = nodes.Where(x => x.X == 0 && x.Y == 2).First(), Movements = new List<Movement>(), Passes = new List<Movement>(), Shot = nodes.Where(x => x.X == 0 && x.Y == 2).First() }; return card; }
public List<BattleResult> ExecuteTactic(TacticCard tacticCard, bool homePlayerAttacks) { if (!homePlayerAttacks) { //Reverse tactic tacticCard = tacticCard.Reverse(); } var battles = new List<BattleResult>(); var area = Areas.Single(x => x.X == tacticCard.StartNode.X && x.Y == tacticCard.StartNode.Y); var result = new BattleResult(area.HomePlayers, area.AwayPlayers, BattleType.Scramble, area, homePlayerAttacks); if(result.Success) Movement(tacticCard, homePlayerAttacks, area, tacticCard.StartNode); battles.Add(result); if (!result.Success) return battles; foreach (var pass in tacticCard.Passes) { var node = pass.End; area = Areas.Single(x => x.X == node.X && x.Y == node.Y); var homePlayers = new List<Player>(area.HomePlayers); var awayPlayers = new List<Player>(area.AwayPlayers); result = new BattleResult(homePlayers, awayPlayers, BattleType.Scramble, area, homePlayerAttacks) { Area = area }; if (result.Success) { // Is there any player movin to that area? Movement(tacticCard, homePlayerAttacks, area, node); } battles.Add(result); if (!result.Success) return battles; } //Shot area = Areas.Single(x => x.X == tacticCard.Shot.X && x.Y == tacticCard.Shot.Y); if (homePlayerAttacks) { var shooter = area.HomePlayers.First(); var goalie = AwayGoalie; var battleResult = new BattleResult(new List<Player> {shooter}, new List<Player> {goalie}, BattleType.Shot, area, true); battles.Add(battleResult); } else { var shooter = area.AwayPlayers.First(); var goalie = HomeGoalie; var battleResult = new BattleResult(new List<Player> { goalie }, new List<Player> { shooter }, BattleType.Shot, area, false); battles.Add(battleResult); } return battles; }
public void AddTactic(TacticCard card) { CurrentCards.Add(card); }
public bool UseTactic(TacticCard tactic) { if (tactic == null) return false; CurrentCards.Remove(tactic); UsedCards.Add(tactic); return true; }
private void Movement(TacticCard tacticCard, bool homePlayerAttacks, GameArea area, Node node) { var movement = tacticCard.Movements.SingleOrDefault(x => x.Start.X == node.X && x.Start.Y == node.Y); if (movement != null) { var nextArea = Areas.Single(x => x.X == movement.End.X && x.Y == movement.End.Y); if (homePlayerAttacks) { var player = area.HomePlayers.First(); area.HomePlayers.Remove(player); nextArea.AddHomePlayer(player); } else { var player = area.AwayPlayers.First(); area.AwayPlayers.Remove(player); nextArea.AddAwayPlayer(player); } } }