From c004a07a4267f3320d23f3d1d2cf483cd56f40b7 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 31 May 2011 01:50:56 +0200 Subject: Make highest value and number of stones dealt settable git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@337 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/model/GameSettings.java | 39 ++++++++++++++++++----------------- src/jrummikub/model/StoneHeap.java | 2 +- src/jrummikub/model/StoneSet.java | 12 +++++------ 3 files changed, 27 insertions(+), 26 deletions(-) (limited to 'src/jrummikub/model') diff --git a/src/jrummikub/model/GameSettings.java b/src/jrummikub/model/GameSettings.java index d571a93..f3cf69a 100644 --- a/src/jrummikub/model/GameSettings.java +++ b/src/jrummikub/model/GameSettings.java @@ -1,11 +1,12 @@ package jrummikub.model; +import static jrummikub.model.StoneColor.*; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; -import static jrummikub.model.StoneColor.*; /** * The overall game settings @@ -16,7 +17,7 @@ public class GameSettings { private int initialMeldThreshold; private int jokerPoints; private int jokerNumber; - private int highestCard; + private int highestValue; private int stoneSetNumber; private int numberOfStonesDealt; private boolean noLimits; @@ -29,12 +30,12 @@ public class GameSettings { initialMeldThreshold = 30; jokerPoints = 50; jokerNumber = 2; - highestCard = 13; + highestValue = 13; stoneSetNumber = 2; numberOfStonesDealt = 14; noLimits = false; - stoneColors = new HashSet(Arrays.asList(BLACK, BLUE, - ORANGE, RED)); + stoneColors = new HashSet(Arrays.asList(BLACK, BLUE, ORANGE, + RED)); } /** @@ -50,7 +51,7 @@ public class GameSettings { * Sets the initial meld threshold * * @param value - * the value to set + * the value to set */ public void setInitialMeldThreshold(int value) { initialMeldThreshold = value; @@ -69,7 +70,7 @@ public class GameSettings { * Sets the points counted for a joker * * @param value - * the value to set + * the value to set */ public void setJokerPoints(int value) { jokerPoints = value; @@ -103,22 +104,22 @@ public class GameSettings { } /** - * Return the highest card value in use + * Return the highest stone value in use * - * @return highest card value + * @return highest stone value */ - public int getHighestCard() { - return highestCard; + public int getHighestValue() { + return highestValue; } /** - * Set the highest card value in use + * Set the highest stone value in use * - * @param highestCard - * highest card value + * @param highestValue + * highest stone value */ - public void setHighestCard(int highestCard) { - this.highestCard = highestCard; + public void setHighestValue(int highestValue) { + this.highestValue = highestValue; } /** @@ -134,7 +135,7 @@ public class GameSettings { * Set the number of sets of stones in use * * @param stoneSets - * sets of stones in use + * sets of stones in use */ public void setStoneSetNumber(int stoneSets) { this.stoneSetNumber = stoneSets; @@ -153,7 +154,7 @@ public class GameSettings { * Set whether "No-Limits" rules are used * * @param noLimits - * use no limit rules + * use no limit rules */ public void setNoLimits(boolean noLimits) { this.noLimits = noLimits; @@ -172,7 +173,7 @@ public class GameSettings { * Set stone colors used * * @param stoneColors - * used stone colors + * used stone colors */ public void setStoneColors(Set stoneColors) { this.stoneColors = stoneColors; diff --git a/src/jrummikub/model/StoneHeap.java b/src/jrummikub/model/StoneHeap.java index 27c8d01..b3c5fbe 100644 --- a/src/jrummikub/model/StoneHeap.java +++ b/src/jrummikub/model/StoneHeap.java @@ -23,7 +23,7 @@ public class StoneHeap { * */ public StoneHeap(GameSettings gameSettings) { heap = new ArrayList(); - for (int i = 1; i <= gameSettings.getHighestCard(); i++) { + for (int i = 1; i <= gameSettings.getHighestValue(); i++) { for (int j = 0; j < gameSettings.getStoneSetNumber(); j++) { for (StoneColor c : gameSettings.getStoneColors()) { heap.add(new Stone(i, c)); diff --git a/src/jrummikub/model/StoneSet.java b/src/jrummikub/model/StoneSet.java index efe7a2e..3324565 100644 --- a/src/jrummikub/model/StoneSet.java +++ b/src/jrummikub/model/StoneSet.java @@ -75,19 +75,19 @@ public class StoneSet implements Iterable, Sizeable { } if (nonJoker == -1) { - if (stones.size() > settings.getHighestCard()) { + if (stones.size() > settings.getHighestValue()) { return new Pair(INVALID, 0); } else if (stones.size() > settings.getStoneColors().size()) { return new Pair( RUN, - (settings.getHighestCard() * (settings.getHighestCard() + 1)) + (settings.getHighestValue() * (settings.getHighestValue() + 1)) / 2 - - (stones.size() - settings.getHighestCard()) - * (stones.size() - settings.getHighestCard() - 1) + - (stones.size() - settings.getHighestValue()) + * (stones.size() - settings.getHighestValue() - 1) / 2); } else { return new Pair(GROUP, stones.size() - * settings.getHighestCard()); + * settings.getHighestValue()); } } @@ -115,7 +115,7 @@ public class StoneSet implements Iterable, Sizeable { int startValue = stones.get(referencePosition).getValue() - referencePosition; int endValue = startValue + stones.size() - 1; - if (startValue < 1 || endValue > settings.getHighestCard()) { + if (startValue < 1 || endValue > settings.getHighestValue()) { return 0; } for (int i = 0; i < stones.size(); i++) { -- cgit v1.2.3