I am learning commons scxml. I am experimenting writing a poker game using activemq and scxml.
So, I have my config xml defined as follows: <?xml version="1.0"?> <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="waitingRound"> <datamodel> <data name="inputPlayer"> <!-- Note namespace declaration in line below --> <player xmlns="com.mgt.lottery.poker.domain"> <id/> <name/> <chips/> <sitin/> <winner/> <betOption/> <gainedChips/> <popocketCards/> <description/> <bestHand/> </player> </data> </datamodel> <state id="waitingRound"> <!-- shuffle deck and check players and empty pot --> <transition event="game.start" target="preflopRound"/> </state> <state id="preflopRound"> <!-- place small/big blinds in pot and deal each player two hole cards --> <transition target="firstBettingRound"/> </state> <state id="firstBettingRound"> <transition event="game.flop" target="flopRound"/> <transition event="game.showdown" target="showdownRound"/> </state> <state id="flopRound"> <!-- deal three cards in the community --> <transition target="secondBettingRound"/> </state> <state id="secondBettingRound"> <onentry> <var name="inputPlayer" expr="#{request$player}" /> </onentry> <transition event="game.turn" target="turnRound"/> <transition event="game.showdown" target="showdownRound"/> </state> <state id="turnRound"> <!-- deal a 4th card in the community --> <transition target="thirdBettingRound"/> </state> <state id="thirdBettingRound"> <!-- deal a 4th card in the community --> <onentry> <var name="inputPlayer" expr="#{request$player}" /> </onentry> <transition event="game.final" target="finalRound"/> <transition event="game.showdown" target="showdownRound"/> </state> <state id="finalRound"> <!-- deal a 5th card in the community --> <transition target="finalBettingRound"/> </state> <state id="finalBettingRound"> <!-- bet, check, call, raise, or fold --> <onentry> <var name="inputPlayer" expr="#{request$player}" /> </onentry> <transition event="game.showdown" target="showdownRound"/> </state> <state id="showdownRound"> <transition event="game.reset" target="waitingRound"/> </state> </scxml> My questions: How can I pass my pojo "Player" to the firstBettingRound, secondBettingRound and etc? This player object is coming from game client with betting information. After the activemq delivers it to the server end, how can I know which method to call? I think scxml handles the the state of game, so I have to say Set states = getEngine().getCurrentStatus().getStates(); return ((org.apache.commons.scxml.model.State) states.iterator(). next()).getId(); if the current state is firstBettingRound, I do game.firstBettingRound(player); Is it correct I seem unable to find the example to show me how to pass pojo to the state correcponded method. If I am completely wrong with my approach, Please advise. Thank you very much. QD --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
