Deal the correct number of jokers aka funny joker action
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@303 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
bf8aa23758
commit
699a0b0a29
4 changed files with 22 additions and 7 deletions
|
@ -38,8 +38,8 @@ public class MockRoundState implements IRoundState {
|
||||||
players.add(new MockPlayer(new PlayerSettings("Player 4", Color.BLACK),
|
players.add(new MockPlayer(new PlayerSettings("Player 4", Color.BLACK),
|
||||||
gameSettings));
|
gameSettings));
|
||||||
activePlayer = 0;
|
activePlayer = 0;
|
||||||
gameHeap = new StoneHeap();
|
|
||||||
gameSettings = new GameSettings();
|
gameSettings = new GameSettings();
|
||||||
|
gameHeap = new StoneHeap(gameSettings);
|
||||||
gameSettings.setInitialMeldThreshold(30);
|
gameSettings.setInitialMeldThreshold(30);
|
||||||
turnNumber = -3;
|
turnNumber = -3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class RoundState implements IRoundState {
|
||||||
turnNumber = 1-gameSettings.getPlayerList().size();
|
turnNumber = 1-gameSettings.getPlayerList().size();
|
||||||
|
|
||||||
activePlayer = 0;
|
activePlayer = 0;
|
||||||
gameHeap = new StoneHeap();
|
gameHeap = new StoneHeap(gameSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package jrummikub.model;
|
package jrummikub.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -14,9 +15,9 @@ import java.util.Random;
|
||||||
public class StoneHeap {
|
public class StoneHeap {
|
||||||
List<Stone> heap;
|
List<Stone> heap;
|
||||||
private Random generator = new Random();
|
private Random generator = new Random();
|
||||||
|
|
||||||
/** Creates 106 Stones according to standard rules */
|
/** Creates 106 Stones according to standard rules */
|
||||||
public StoneHeap() {
|
public StoneHeap(GameSettings gameSettings) {
|
||||||
heap = new ArrayList<Stone>();
|
heap = new ArrayList<Stone>();
|
||||||
for (int i = 1; i <= 13; i++) {
|
for (int i = 1; i <= 13; i++) {
|
||||||
for (int j = 0; j < 2; j++) {
|
for (int j = 0; j < 2; j++) {
|
||||||
|
@ -26,8 +27,22 @@ public class StoneHeap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Joker
|
// Joker
|
||||||
heap.add(new Stone(StoneColor.BLACK));
|
|
||||||
heap.add(new Stone(StoneColor.RED));
|
ArrayList<StoneColor> jokerColors = new ArrayList<StoneColor>(Arrays.asList(StoneColor.values()));
|
||||||
|
|
||||||
|
StoneColor temp = jokerColors.get(0);
|
||||||
|
jokerColors.set(0, jokerColors.get(2));
|
||||||
|
jokerColors.set(2, temp);
|
||||||
|
|
||||||
|
int jokersLeft = gameSettings.getJokerNumber();
|
||||||
|
done : while(true) {
|
||||||
|
for (StoneColor c : jokerColors) {
|
||||||
|
if (jokersLeft == 0)
|
||||||
|
break done;
|
||||||
|
heap.add(new Stone(c));
|
||||||
|
jokersLeft--;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class StoneHeapTest {
|
||||||
/** */
|
/** */
|
||||||
@Before
|
@Before
|
||||||
public void createHeap() {
|
public void createHeap() {
|
||||||
testHeap = new StoneHeap();
|
testHeap = new StoneHeap(new GameSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in a new issue