K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
Jimmy Ho wrote:
Yeah, there's a State Pattern that manages states, but all the toy examples I can find are for states where the possible inputs are the same, regardless of the state. There are some semi-ugly modifications to the pattern when each state has different actions possible.
Example:
State1: Can mouse click in the drawing canvas
State2: Can mouse click, but results in different behavior
State3: Can mouse click, but results in different behavior
But in my game:
State1: Actions to recruit more players to the game via Facebook (or something)
State2: Repeating rounds of playing cards, and each player plays a card (or something)
State3: Game shutdown, with buttons to post results to Facebook (or something)
Each "state" has a different set of methods/actions associated with it, and the State pattern, as written, doesn't seem to accommodate it well.
Tushar Sharma (Twitter: @Sharma__Tushar)
http://www.tusharma.in
http://designsmells.com/
Jimmy Ho wrote:
Yeah, there's a State Pattern that manages states, but all the toy examples I can find are for states where the possible inputs are the same, regardless of the state. There are some semi-ugly modifications to the pattern when each state has different actions possible.
Example:
State1: Can mouse click in the drawing canvas
State2: Can mouse click, but results in different behavior
State3: Can mouse click, but results in different behavior
But in my game:
State1: Actions to recruit more players to the game via Facebook (or something)
State2: Repeating rounds of playing cards, and each player plays a card (or something)
State3: Game shutdown, with buttons to post results to Facebook (or something)
Each "state" has a different set of methods/actions associated with it, and the State pattern, as written, doesn't seem to accommodate it well.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |