From 4a98975b0da4baa4158140ba85f39ffa669ba7a8 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Tue, 24 May 2011 01:51:56 +0200 Subject: Calculate points on hand git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@264 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/model/Hand.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/jrummikub/model/Hand.java') diff --git a/src/jrummikub/model/Hand.java b/src/jrummikub/model/Hand.java index ab5eb19..35ea49f 100644 --- a/src/jrummikub/model/Hand.java +++ b/src/jrummikub/model/Hand.java @@ -10,6 +10,12 @@ public class Hand extends StoneTray implements IHand { * The width of the hand */ public final static int WIDTH = 14; + + private GameSettings settings; + + public Hand(GameSettings settings) { + this.settings = settings; + } @Override public int getFreeRowSpace(int row) { @@ -54,4 +60,18 @@ public class Hand extends StoneTray implements IHand { } } } + + public int getStonePoints() { + int points = 0; + + for (Pair entry : this) { + if (entry.getFirst().isJoker()) { + points += settings.getJokerPoints(); + } else { + points += entry.getFirst().getValue(); + } + } + + return points; + } } -- cgit v1.2.3