1 7 8 package poker.presentation.main; 9 10 import com.lutris.appserver.server.httpPresentation.HttpPresentation; 12 import com.lutris.appserver.server.httpPresentation.HttpPresentationComms; 13 import com.lutris.appserver.server.httpPresentation.HttpPresentationException; 14 import com.lutris.util.KeywordValueException; 15 16 import poker.Poker; 17 import poker.spec.PokerGame; 18 import poker.spec.GameManager; 19 20 21 public class StatsPresentation implements HttpPresentation { 22 23 24 public void run(HttpPresentationComms comms) 25 throws HttpPresentationException, KeywordValueException { 26 27 StatsHTML stats; 28 stats = (StatsHTML)comms.xmlcFactory.create(StatsHTML.class); 29 30 Poker mainApp = (Poker)comms.session.getSessionData().get("app"); 31 GameManager gameManager = mainApp.getGameManager(); 32 PokerGame game = (PokerGame)comms.session.getSessionData().get("game"); 33 34 39 try{ 40 int rank = gameManager.getRank(game.getCash()); 41 int count = gameManager.getCount(); 42 String ranking = Integer.toString(rank) + " of " + Integer.toString(count); 43 44 stats.setTextName(game.getName()); 45 stats.setTextRank(ranking); 46 stats.setTextCash(Integer.toString(game.getCash())); 47 stats.setTextTotal(Integer.toString(game.getTotalPlayed())); 48 stats.setTextLargest(Integer.toString(game.getLargestBet())); 49 stats.setTextSmallest(Integer.toString(game.getSmallestBet())); 50 stats.setTextWon(Integer.toString(game.getTotalWon())); 51 stats.setTextLost(Integer.toString(game.getTotalPlayed() - game.getTotalWon())); 52 53 }catch (NullPointerException e){} 54 55 comms.response.writeDOM(stats); 56 } 57 58 } 59 | Popular Tags |