// Return true if the specified color is able to make a capture using // any one of their stacks. private bool FooCanCapture(TzaarColor playerColor) { // The opponent's piece color. TzaarColor targetColor = (playerColor == TzaarColor.BLACK) ? TzaarColor.WHITE : TzaarColor.BLACK; // Check each spot on the board, looking for our pieces. If we find // one, we check to see if we can use it to capture any of the other // player's pieces. for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { Stack<TzaarPiece> S = this.state.Board.Query(i, j); if (S == null) // The columns have varying length. Switch to the next // column as soon as we reach the top of the current // one. break; if (S.Count == 0) // There are no pieces on this position, keep going. continue; if (S.Peek().Color != playerColor) // These are the other player's pieces, keep going. continue; // We have found some of our pieces! Ok, now we check each // position on the board to see if we can move there. // Brute force, FTW! for (int k = 0; k < 9; k++) { for (int l = 0; l < 9; l++) { Stack<TzaarPiece> SS = this.state.Board.Query(k, l); if (SS == null) break; if (SS.Count == 0) continue; if (SS.Peek().Color != targetColor) continue; // Found a potential target; is it wimpy? if (SS.Count > S.Count) continue; // Can we reach the potential target? if (this.boardMap.IsValidPath(this.state.Board, i, j, k, l)) return true; } } } } return false; }
public Tzarra(TzaarColor c) : base(c) { }
private void DrawPiece(Graphics g, Image pieceImage, PointF p, string pieceCount, TzaarColor c) { // Find the position for the piece. PointF piecePos = ApplyRectangleCornerOffset(p); g.DrawImage(pieceImage, new RectangleF(piecePos.X, piecePos.Y, CurrentImageInfo.PieceWidth, CurrentImageInfo.PieceWidth)); // Draw the pieceCount on the piece. using (StringFormat stringFormat = new StringFormat()) { stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; PointF countPos = ApplyPieceTextOffset(p); GraphicsPath path = new GraphicsPath(); path.AddString(pieceCount, new FontFamily("Arial"), (int)FontStyle.Bold, 18.0f, new PointF(countPos.X, countPos.Y), stringFormat); if (c == TzaarColor.BLACK) { // Fill in the outline. g.FillPath(Brushes.Orange, path); // Draw the outline. g.DrawPath(new Pen(Color.DarkRed, 1.5f), path); } else { // Fill in the outline. g.FillPath(Brushes.LightGreen, path); // Draw the outline. g.DrawPath(new Pen(Color.Black, 1.5f), path); } } }
public Tzaar(TzaarColor c) : base(c) { }
public Tott(TzaarColor c) : base(c) { }
public TzaarPiece(TzaarColor c) { this.color = c; }
public static GamePlayer GetPlayerFromColor(TzaarColor c) { return (c == TzaarColor.WHITE) ? GamePlayer.One : GamePlayer.Two; }
public void SetLocalPlayerColor(TzaarColor aColor) { this.myColor = aColor; this.enableColorLogo = true; }