Pawns Game

1 player 2 players

How to play

This board game is a variant of Reversi and Tic Tac Toe. Each one of the two players sets a pawn on an empty cell of the board.

Pawns

Different themes are supported. Theme is configured through a Cascading Style Sheet (CSS) that determines how the HTML content is rendered by the SWT Browser widget.

How to win

The game ends when all cells are filled. The winner is the one with most pawns of their colour.

Java and HTML integrated through the SWT Browser widget

Rendering is based on HTML and CSS techniques. Computer moves are programmed in regular Java code in the Eclipse plug-in. The SWT Browser widget is used for rendering and reacting to user input.

Implementation

The board is a table filled with hyperlinks. Cascading Style Sheets provide various themes and control the table aesthetic appearance.
The API org.eclipse.swt.browser.Browser.setText(java.lang.String) draws the board game from HTML generated in memory.
Player moves are captured by implementing the interface org.eclipse.swt.browser.LocationListener. e.g the player clicks on a cell that may generate a hyperlink with a URL similar to http://www.org.eclipse.swt.examples.browser.demos/xx1yy2. That hyperlink identifies the position of the cell selected by the player (column 1, row 2). The move is completed by generating new HTML content and invoking Browser.setText to update the board game.