Modelklassen angelegt, verschiedenen Stadien von fertig, StoneHeap fertig, getestet und kommentiert
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@19 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
a601d484a2
commit
f7f10a50af
7 changed files with 108 additions and 2 deletions
17
src/jrummikub/model/GameState.java
Normal file
17
src/jrummikub/model/GameState.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package jrummikub.model;
|
||||
|
||||
public class GameState {
|
||||
private Table table;
|
||||
private Player[] players;
|
||||
private int activePlayer;
|
||||
private StoneHeap gameHeap;
|
||||
|
||||
public void nextPlayer() {
|
||||
|
||||
}
|
||||
|
||||
public Player activePlayer() {
|
||||
|
||||
}
|
||||
|
||||
}
|
15
src/jrummikub/model/Hand.java
Normal file
15
src/jrummikub/model/Hand.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package jrummikub.model;
|
||||
|
||||
public class Hand {
|
||||
private Stone[] stones;
|
||||
private Position[] position;
|
||||
|
||||
public Stone pickUp(Position position) {
|
||||
|
||||
}
|
||||
|
||||
public void drop(Stone stone, Position position) {
|
||||
|
||||
}
|
||||
|
||||
}
|
12
src/jrummikub/model/Player.java
Normal file
12
src/jrummikub/model/Player.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package jrummikub.model;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class Player {
|
||||
private Hand hand;
|
||||
// Könnten wir einfach die Steinfarben vergeben?
|
||||
private Color color;
|
||||
|
||||
// private String name;
|
||||
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package jrummikub.model;
|
||||
/** */
|
||||
|
||||
public class Stone {
|
||||
private int value;
|
||||
private StoneColor color;
|
||||
private final boolean joker;
|
||||
|
||||
|
||||
public Stone(int value, StoneColor color, boolean joker) {
|
||||
this.value = value;
|
||||
this.color = color;
|
||||
|
|
|
@ -5,10 +5,16 @@ import java.util.EnumSet;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* StoneHeap creates all {@link Stone}s for a game, manages them and allows
|
||||
* players to draw one or more random Stones.
|
||||
*/
|
||||
|
||||
public class StoneHeap {
|
||||
List<Stone> heap;
|
||||
Random generator = new Random();
|
||||
|
||||
/** Creates 106 Stones according to standard rules */
|
||||
public StoneHeap() {
|
||||
heap = new ArrayList<Stone>();
|
||||
for (int i = 1; i <= 13; i++) {
|
||||
|
@ -23,10 +29,17 @@ public class StoneHeap {
|
|||
heap.add(new Stone(0, StoneColor.ORANGE, true));
|
||||
}
|
||||
|
||||
/** Removes random {@link Stone} from the heap and returns it */
|
||||
public Stone drawStone() {
|
||||
return heap.remove(generator.nextInt(heap.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes several {@link Stone}s from the heap and returns them
|
||||
*
|
||||
* @param number
|
||||
* number of requested Stones
|
||||
*/
|
||||
public List<Stone> drawStones(int number) {
|
||||
List<Stone> drawnStones = new ArrayList<Stone>();
|
||||
for (int i = 0; i < number; i++) {
|
||||
|
|
18
src/jrummikub/model/StoneSet.java
Normal file
18
src/jrummikub/model/StoneSet.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package jrummikub.model;
|
||||
|
||||
public class StoneSet {
|
||||
private Stone[] stones;
|
||||
|
||||
public boolean isValid() {
|
||||
|
||||
}
|
||||
|
||||
public StoneSet[] splitAt(int position) {
|
||||
|
||||
}
|
||||
|
||||
public StoneSet join(StoneSet other) {
|
||||
|
||||
}
|
||||
|
||||
}
|
29
src/jrummikub/model/Table.java
Normal file
29
src/jrummikub/model/Table.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package jrummikub.model;
|
||||
|
||||
public class Table {
|
||||
private StoneSet[] sets;
|
||||
private Position[] positions;
|
||||
|
||||
// Constructor
|
||||
public Table gameTable = new Table();
|
||||
|
||||
public Stone pickUp(Position position) {
|
||||
|
||||
}
|
||||
|
||||
public StoneSet pickUpSet(Position position) {
|
||||
|
||||
}
|
||||
|
||||
public StoneSet pickUpRange(Position from, Position to) {
|
||||
|
||||
}
|
||||
|
||||
public void drop(Position position, StoneSet stones) {
|
||||
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
|
||||
}
|
||||
}
|
Reference in a new issue