Browse Source

Initial bet controller abstraction

Fixed wrong value for bigblind being passed to listeners
Tidied some logic in AbstractGame


git-svn-id: http://chris.smith.name/svn/japoker/trunk@3 b8598caf-53df-4c1b-98b8-507a84a220
tags/v12
Chris Smith 16 years ago
parent
commit
4e5f50cd3f

+ 6
- 13
src/com/md87/cardgame/games/AbstractGame.java View File

@@ -287,7 +287,7 @@ public abstract class AbstractGame implements Game, Runnable {
287 287
     protected void doBigBlind(final Player player) {
288 288
         player.forceBet(bigblind);
289 289
         
290
-        notifyPlaceBlind(player, bigblind / 2, "big blind");
290
+        notifyPlaceBlind(player, bigblind, "big blind");
291 291
     }
292 292
     
293 293
     @SuppressWarnings("fallthrough")
@@ -442,23 +442,16 @@ public abstract class AbstractGame implements Game, Runnable {
442 442
         // tempPlayers is a list of everyone involved in the round
443 443
         List<Player> tempPlayers = new ArrayList<Player>();
444 444
         Map<Player, Integer> playerBets = new HashMap<Player, Integer>();
445
+        int maxbet = 0;
445 446
         
446 447
         for (Player player : players) {
447 448
             if (!player.isOut()) {
448 449
                 tempPlayers.add(player);
449 450
                 
450
-                if (doHalf) {
451
-                    playerBets.put(player, player.getBet() / 2);
452
-                } else {
453
-                    playerBets.put(player, player.getBet());
454
-                }
455
-            }
456
-        }
457
-        
458
-        int maxbet = 0;
459
-        for (Integer bet : playerBets.values()) {
460
-            if (bet > maxbet) {
461
-                maxbet = bet;
451
+                final int bet = doHalf ? player.getBet() / 2 : player.getBet();
452
+                
453
+                playerBets.put(player, bet);
454
+                maxbet = Math.max(bet, maxbet);
462 455
             }
463 456
         }
464 457
         

+ 36
- 0
src/com/md87/cardgame/interfaces/BetController.java View File

@@ -0,0 +1,36 @@
1
+/*
2
+ * Copyright (c) Chris 'MD87' Smith, 2008. All rights reserved.
3
+ *
4
+ * This code may not be redistributed without prior permission from the
5
+ * aforementioned copyright holder(s).
6
+ */
7
+
8
+package com.md87.cardgame.interfaces;
9
+
10
+/**
11
+ *
12
+ * @author chris
13
+ */
14
+public interface BetController {
15
+    
16
+    /**
17
+     * Retrieves the maximum bet allowed in the specified circumstances.
18
+     * 
19
+     * @param total The total of the current pot
20
+     * @param lastBet The size of the last bet
21
+     * @param lastRaise The size of the last raise
22
+     * @return The maximum bet that may be played
23
+     */
24
+    int getMaxBet(int total, int lastBet, int lastRaise);
25
+    
26
+    /**
27
+     * Retrieves the minimum bet allowed in the specified circumstances.
28
+     * 
29
+     * @param total The total of the current pot
30
+     * @param lastBet The size of the last bet
31
+     * @param lastRaise The size of the last raise
32
+     * @return The minimum bet that may be played
33
+     */
34
+    int getMinBet(int total, int lastBet, int lastRaise);    
35
+
36
+}

Loading…
Cancel
Save