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 org.w3c.dom.html.HTMLTextAreaElement; 14 import org.w3c.dom.html.HTMLInputElement; 15 import org.w3c.dom.html.HTMLImageElement; 16 17 import poker.Poker; 18 import poker.spec.PokerGame; 19 import poker.spec.GameManager; 20 21 import java.util.Vector ; 22 23 public class PlaceBetPresentation implements HttpPresentation { 24 25 public void run(HttpPresentationComms comms) 26 throws Exception { 27 28 PlaceBetHTML placeBet; 29 placeBet = (PlaceBetHTML)comms.xmlcFactory.create(PlaceBetHTML.class); 30 35 try{ 36 this.initGame(comms, placeBet); 37 }catch (NullPointerException e){ 38 placeBet.setTextMessage("This is a default HTML page"); 39 } 40 41 comms.response.writeDOM(placeBet); 42 43 } 44 45 static public void initGame(HttpPresentationComms comms0, PlaceBetHTML placeBet0) 46 throws Exception { 47 PokerGame game = (PokerGame)comms0.session.getSessionData().get("game"); 48 Poker mainApp = (Poker)comms0.session.getSessionData().get("app"); 49 GameManager gameManager = mainApp.getGameManager(); 50 51 game.setPlayRound(1); 52 53 Vector freshDrops = new Vector (0); 54 for (int i = 0; i < 5; i++) { 55 freshDrops.addElement("DROP"); 56 } 57 game.setDropCards(freshDrops); 58 59 placeBet0.setTextCash(Integer.toString(game.getCash())); 60 placeBet0.setTextName(game.getName()); 61 placeBet0.setTextRank(Integer.toString(gameManager.getRank(game.getCash()))); 62 placeBet0.setTextWon(Integer.toString(game.getTotalWon())); 63 placeBet0.setTextHandsPlayed(Integer.toString(game.getTotalPlayed())); 64 65 HTMLImageElement image = null; 66 image = placeBet0.getElementDeck1(); 67 image.setSrc("../media/" + game.getDeck() + ".jpg"); 68 image = placeBet0.getElementDeck2(); 69 image.setSrc("../media/" + game.getDeck() + ".jpg"); 70 image = placeBet0.getElementDeck3(); 71 image.setSrc("../media/" + game.getDeck() + ".jpg"); 72 image = placeBet0.getElementDeck4(); 73 image.setSrc("../media/" + game.getDeck() + ".jpg"); 74 image = placeBet0.getElementDeck5(); 75 image.setSrc("../media/" + game.getDeck() + ".jpg"); 76 77 HTMLInputElement input = null; 78 input = placeBet0.getElementBetInput(); 79 input.setValue( Integer.toString(game.getDefaultBet()) ); 80 81 if (game.getDefaultBet() > 0) { 82 input = placeBet0.getElementCheckInput(); 83 input.setChecked(true); 84 input.setValue("on"); 85 } 86 else { 87 input = placeBet0.getElementCheckInput(); 88 input.setChecked(false); 89 input.setValue("off"); 90 } 91 92 if (game.getLastError() != "") { 93 placeBet0.setTextMessage(game.getLastError()); 94 game.setLastError(""); 95 } 96 else { 97 placeBet0.setTextMessage(""); 98 } 99 } 100 101 102 } 103 | Popular Tags |