CS 2 |
Igel Ärgern |
Winter 2012 |
Design, implement, and test the game engine for a Java application to play the board game Igel Ärgern (commonly translated as "Hedgehogs in a Hurry").
Rules are very easy to find on the web (begin by reading this document as well as others at boardgamegeek.com); and we will demonstrate the game in class. Therefore, we provide only a very brief overview here:
The standard game is played on a grid with 6 rows and 9 columns. Each player has four tokens (representing hedgehogs) that he or she must move from the left column to the right column. Hedgehogs sharing a square stack on top of each other. Only the hedgehog on the top of a stack may move.
On his turn a player:
The game is interesting because:
This document contains a long list of variants. You will be required to implement some of them.
This jar file contains an example completed project. Use it to learn how to play
the game. To run the demo, download the jar file,
then run java -jar igelArgern.jar
from the command line.
IIgelGame
interface. In addition, your model must implement this constructor
public MyIgelGame(IgelGameParameters)
IgelGameParameters.obstacleType
specifies the
the type for all obstacles for this game. Please make sure your model recognizes the strings
"ConcreteBlock" and "DeepPit". You may also have it recognize other strings if you prefer.
igelArgern.jar
and import it into your project.model
.model
package that implements both
IIgelGame
and
IGameState
.
model
package that implements
ICellState
.
main
method in MyIgelArgern
,
you should see a configuration dialog box appear. If you press the start button, the program will crash. This is
because many methods in your model are returning null
. When you implement enough of your model to have
removed all the default return null;
statements, you should be able to see the GUI.
If you look at the
IIgelGame
documentation,
you will see it contains a
GameEventListener
. This interface allows the model to report events back to the presenter.
Your model must support a GameEventListener
. The presenter (which we provide) is
responsible for implementing a
GameEventListener
object and passing it to the model using the method
addGameEventListener
. Your model is responsible for calling methods on the
GameEventListener
object at the apporpriate times. For example,
your model must call the GameEventListener
's roll
method whenever the die value changes.
Because the model uses a listener, the presenter does not have to "poll" the model for events. For example,
if there was no GameEventListener
, then the presenter would have to call currentDieValue
after every method call.
IgelViewKurmas
uses objects called Artists to draw each cell. The provided GUI comes
with Artist
s to draw Deep Pits and Concrete Blocks. In some cases,
you may be able to re-use or subclass these artists for your own obstacles. Read these instructions if you decide
you want your new obstacles to have a different
look.
An Artist
is simply an object that
implements a
draw
method. The
type()
method in ICellState
tells the view which artist to use. The IIgelViewKurmas
constructor
takes an optional Map<String, Artist>
parameter maps the strings returned
by ICellState.type()
to the Artist
object used to render the cell. Notice that all cells
of a given type share the same Artist
object. This means that the Artist
shouldn't store
any state. The view of any given cell should be determined solely by it's state (i.e.,
the ICellState
object).
To add another obstacle type, do the following:
Artist
. This step is optional
because one of the existing Artists may work for the new obstacle type. For example,
if the new obstacle doesn't allow hedgehogs inside, then you can simply use the existing
ConcreteBlockArtist
.
IgelViewKurmas.defaultArtistMap()
to obtain the default map.IgelViewKurmas
constructor.Map<String, Artist> artistMap = IgelViewKurmas.defaultArtistMap(); artistMap.put("FinishCell", new SmileyArtist()); // Create a view configured for the specified game. final IIgelView view = new IgelViewKurmas(model.getState(), artistMap);
IgelViewKurmas
comes with the following artists: "Cell Type" is the string that is mapped to that
artist.
Name | Cell Type | Description |
---|---|---|
CellPanelArtist |
"Cell" | Draws a "regular" cell: A cell containing a stack of hedgehogs. |
FinishCellArtist |
"FinishCell" | Draws the cells in the rightmost column (i.e., the "finish" column). Works just like a
CellPanelArtist ,
except it draws the finish line on the left side of the cell.
|
DeepPitArtist |
"DeepPit" | Draws "deep pit" obstacles. These cells can contain a stack of hedgehogs. The artist draws a "regular" cell with a black background and a red border. |
ConcreteBlockArtist |
"ConcreteBlock" | Simply draws a solid black rectangle. |
ICellState
object correctly implements the
type()
method. Unless you have
added
your own Artist
s or artist map, the type
method should return only those values
listed in the "Cell Type" column of this table.
You must demonstrate your program. It is your responsibility to find a time for the demonstration. Programs that are not personally demonstrated may not be graded.
Electronically submit:
igelArgern.jar
: All necessary demo and support code.Artist
s or do other,
optional fancy stuff.