public void RenderMove(PossibleMove M) { var mep = Sim.Board.GetMeepleAt(M.ToX, M.ToY); var col = mep == null ? Pens.Green : new Pen(mep.Player.Color); g.DrawEllipse(col, Rect(M.FromX + .5 - .1, M.FromY + .5 - .1, .2, .2)); g.DrawLine(col, Point(M.FromX + .5 - .1, M.FromY + .5), Point(M.ToX + .5, M.ToY + .5)); g.DrawLine(col, Point(M.FromX + .5 + .1, M.FromY + .5), Point(M.ToX + .5, M.ToY + .5)); g.DrawLine(col, Point(M.FromX + .5, M.FromY + .5 + .1), Point(M.ToX + .5, M.ToY + .5)); g.DrawLine(col, Point(M.FromX + .5, M.FromY + .5 - .1), Point(M.ToX + .5, M.ToY + .5)); }
private PossibleMove CheckPath(int x, int y, int xoff, int yoff, BoardClass Board) { int xcur = x, ycur = y; PossibleMove LastGood = null; for (int steps = 0; steps < 100; steps++) { xcur += xoff; ycur += yoff; if (!Board.IsWalkable(xcur, ycur)) { break; } LastGood = new PossibleMove() { FromX = x, FromY = y, ToX = xcur, ToY = ycur, ScoreValue = Board.Tiles[xcur, ycur].ScoreValue, Card = this, Destination = Board.Tiles[xcur, ycur] }; } return(LastGood); }
private void RenderBox_MouseDown(object sender, MouseEventArgs e) { int TileX = (int)Math.Floor(e.X / Sim.Vis.CWid); int TileY = (int)Math.Floor(e.Y / Sim.Vis.CHit); if (e.Button == MouseButtons.Right) { StealthX = TileX; StealthY = TileY; lblInstruction.Text = "OK! Now Click destination again"; } if (e.Button == MouseButtons.Left) { if (SelectedMeeple == null) { SelectedMeeple = Sim.Board.GetMeepleAt(TileX, TileY); if (SelectedMeeple == null) { return; } if (SelectedMeeple.Player.ID != Sim.CurrentPlayer) { SelectedMeeple = null; lblInstruction.Text = "Thats not yours!"; return; } StealthX = -1; StealthY = -1; lblInstruction.Text = "OK! Now pick a destination!"; if (SelectedCard != null) { var Moves = SelectedCard.PossibleMoves(TileX, TileY, Sim.Board, Sim.CurrentPlayer); foreach (var m in Moves) { Sim.Vis.MarkCard(m.ToX, m.ToY, .1, null, false); } Sim.Vis.Refresh(); } } else { if (SelectedCard == null) { lblInstruction.Text = "No card selected!"; return; } if (SelectedCard.Type == CardType.Stealth && StealthY < 0) { lblInstruction.Text = "Right click a tile to Stealth over! Then Click destination again"; return; } var PossibleMoves = Sim.AllPossibleMoves(Sim.Board.Players[Sim.CurrentPlayer], Sim.Board); var MoveType = SelectedCard; var Score = Sim.Board.Tiles[TileX, TileY].ScoreValue; if (SelectedCard.Type == CardType.Shadow) { MoveType = Sim.Board.ShadowLastPlayedCard; } if (SelectedCard.Type == CardType.Stealth) { Score += Sim.Board.Tiles[StealthX, StealthY].ScoreValue; } var ProposedMove = new PossibleMove() { FromX = SelectedMeeple.X, FromY = SelectedMeeple.Y, ToX = TileX, ToY = TileY, Card = MoveType, Destination = Sim.Board.Tiles[TileX, TileY], isShadow = SelectedCard.Type == CardType.Shadow, FirstX = StealthX, FirstY = StealthY, ScoreValue = Score }; if (PossibleMoves.Contains(ProposedMove)) { Sim.Board.PlayMove(ProposedMove, Sim.Board.Players[Sim.CurrentPlayer]); Sim.WaitForPlayer = false; } else { lblInstruction.Text = "Invalid move!"; return; } } } }
public void PlayMove(PossibleMove Move, Player p, bool VirtualMove = false) { Meeple TargetMeeple; if (Move.Card.Type == CardType.PlaceMeeple) { TargetMeeple = Meeples.Where(o => o.Player.ID == p.ID && o.X < 0).First(); } else { TargetMeeple = GetMeepleAt(Move.FromX, Move.FromY); } // checks if (TargetMeeple.Player.ID != p.ID) { throw new Exception("Thats not yours!"); } PickupCard(p, Move.FromX, Move.FromY); if (Move.Card.Type == CardType.Stealth) { PickupCard(p, Move.FirstX, Move.FirstY); } if (Move.isShadow) { DiscardCard(p, CardType.Shadow); } else { DiscardCard(p, Move.Card.Type); } if (Move.Card.Type == CardType.Ambush) { var Victim = GetMeepleAt(Move.ToX, Move.ToY); if (Victim == null) { throw new Exception("Ambush has invalid target!"); } int pushx = Math.Sign(Move.ToX - Move.FromX), pushy = Math.Sign(Move.ToY - Move.FromY); Victim.Place(Victim.X + pushx, Victim.Y + pushy); if (!IsWalkable(Victim.X, Victim.Y, false)) { throw new Exception("Ambush pushed to invalid tile!"); } } if (!Move.isShadow) { ShadowLastPlayedCard = Move.Card; } TargetMeeple.Place(Move.ToX, Move.ToY); if (Log.Enabled) { Sim.LastMove = Move; p.UpdateHand(); } }
public void SimSetup() { Deck = new List <Card>(); var DeckCards = new List <Card> { new EvadeCard(), new ShadowCard(), new LeapCard(), new DodgeCard(), new StealthCard(), new AmbushCard(), new SprintCard(), new WallCard(), new TrapCard() }; foreach (var c in DeckCards) { for (int i = 0; i < c.NumInDeck; i++) { Deck.Add(Helpers.CardFactory(c.Type)); } } if (Board.TilesX * Board.TilesY > Deck.Count) { Deck.AddRange(Deck); } Deck.Shuffle(RNG); for (int x = 0; x < Board.TilesX; x++) { for (int y = 0; y < Board.TilesY; y++) { Board.Tiles[x, y] = Deck.Pop(); } } Board.Players = new List <Player>(); Board.Meeples = new List <Meeple>(); if (NumPlayers > 0) { Board.Players.Add(new Player() { AI = true, Color = Color.Red, ID = 0, Name = "Red", Strategy = "hybrid", LookAhead = 2 }); } if (NumPlayers > 1) { Board.Players.Add(new Player() { AI = true, Color = Color.Blue, ID = 1, Name = "Blue", Strategy = "hybrid", LookAhead = 2 }); } if (NumPlayers > 2) { Board.Players.Add(new Player() { AI = true, Color = Color.Purple, ID = 2, Name = "Purple", Strategy = "hybrid", LookAhead = 0 }); } if (NumPlayers > 3) { Board.Players.Add(new Player() { AI = true, Color = Color.Black, ID = 3, Name = "Black", Strategy = "hybrid", LookAhead = 0 }); } foreach (var p in Board.Players) { for (var i = 0; i < 3; i++) { Board.Meeples.Add(new Meeple() { Player = p }); p.Hand.Add(new PlaceMeepleCard()); } p.Hand.Add(new EvadeWoodCard()); p.Hand.Add(new SprintWoodCard()); p.UpdateHand(); } LastMove = null; }