// A game can be constructed with the default board, or a specified // board. public OwariLogic() { // Create a new default board. GameBoard board = new OwariBoard(); // Create the game state using the board we generated. this.state = new OwariGameState(board); }
// Return a full copy of the current game state. public override GameState Copy() { OwariGameState state = new OwariGameState((OwariBoard)this.Board.Copy()); state.totalMoveCount = this.totalMoveCount; state.gameIsOver = this.gameIsOver; state.gameOverCondition = GameOverCondition.None; state.winningPlayerNumber = this.winningPlayerNumber; state.history = new Stack<string>(this.history); return state; }
private void DrawBucket(Graphics g, OwariGameState state, int pos) { int pieceCount = state.Board.Buckets[pos]; if (pieceCount == 0) return; PointF pieceLocation = BoardPositionToPictureBoxCoords(pos); PointF piecePos = ApplyRectangleCornerOffset(pieceLocation); g.DrawImage(Properties.Resources.OwariPiece, new RectangleF(piecePos.X, piecePos.Y, CurrentImageInfo.PieceSize.Width, CurrentImageInfo.PieceSize.Height)); // Draw the pieceCount on the piece. using (StringFormat stringFormat = new StringFormat()) { stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; PointF textPos = ApplyBucketTextOffset(pieceLocation); GraphicsPath gPath = new GraphicsPath(); gPath.AddString(pieceCount.ToString(), new FontFamily("Arial"), (int)FontStyle.Bold, 18.0f, new PointF(textPos.X, textPos.Y), stringFormat); // Fill in the outline. g.FillPath(Brushes.Orange, gPath); // Draw the outline. g.DrawPath(new Pen(Color.DarkRed, 1.5f), gPath); } }
public OwariLogic(GameState aState) { this.state = (OwariGameState)aState; }