Cripple mr onion card game
The Table object represents the game view and acts as the content pane for the main window. It provides various public methods for changing the appearance of the board and for enabling and disabling certain components. The Animation Pane is the glass pane of the main window and is where all the animations are drawn.
Rendering animations using Swing components can be tricky since drawing only occurs when a paint event is dispatched by the EDT, a method known as passive rendering. The Animation objects in this game use threads that repeatedly update before calling the repaint method on the component to which they are attached.
When an animation event occurs, an Animation object is constructed using position data collected from the Table. The Animation is then fitted with its own personal listener object whose methods are called whenever the animation is started, paused, stopped or reaches its end. The only one of these methods that is truly important is the OnComplete method because it notifies the core thread when the animation is finished.
The Animation object is then attached to the Animation Pane and finally started on a new thread. Note that the animation thread does not need to be invoked on the EDT since it does not make any direct changes to the GUI. It merely calls the repaint method of the component to which it is attached. Repaint merely schedules a paint event to be executed later, thus making our Animations thread safe.
In addition to having Animations for moving objects, this game also supports sprite based animations. Each time a card flips over or a modifier effect is activated, a sprite based Animation Clip object determines which frame to use based on the total elapsed time. To see my blog posting on sprite animation click here. The various Animation subclasses each utilize an Animation Data object which stores the position, rotation, and image data for each of the cards and provides helper methods for stepping forward the position, rotation and animation.
Then using Hash Maps the animation objects map the Card objects to the Animation Data objects allowing the animation to simply cycle through the list of cards to update their positions and paint them. This way the order of the list determines what order to draw the cards in. Additional these data objects also store a rotated version of the image so that the program does not need to call the image rotation function, which is rather time consuming, within the paint method.
To prevent the clipping of images as a result of rotation each image is resized to a square whose sides are equal to the diameter of the circle that completely encloses the image. The images are then rotated about their center and position data is altered to take into account the change in size.
Player hands are evaluated through the use of two Objects: the Grouping, and the Hand Evaluator. Grouping merely looks at a set of cards and determines if it forms a valid card grouping and stores its overall ranking. Hands are not played quickly, one can spend "ages" building a good hand, and five minutes appears to be considered longer than average.
How many cards are dealt is not revealed, but a reference is made to having nine cards at the most, and five at the least more could possibly be in the hand if only some were of significant value, ignoring the others as irrelevant.
An ante is paid before the hand starts, and there seem to be two ways to put more money into the pot : buying new cards and raising. It is not clear if cards are discarded when new ones are purchased or if the player just accumulates cards into a growing hand.
A player can fold if he has a poor hand. The only hand that is explicitly described is the Triple Onion two kings and three aces , which is apparently a mid-range value. A three-card Onion a different hand, apparently, from the Triple Onion beats a double Bagel. A five-card Onion beats a Flush. A Broken Flush beats a two-card Onion both of these are low-value hands. The best hand in the game is apparently a "natural Great Onion", which implies the existence of wild cards , and they're so rare that it's notable to get two in one day.
A Great Onion can be beaten if another player can "cripple" it, but this is so rare that it would only happen once or twice in a player's life. This is done with a "perfect ninecard run", which appears to be akin to a straight flush. Based loosely on these tidbits of information, Discworld fans have pieced together complete rules for a game of Cripple Mr. Onion that can be played in real life using an 8-suit deck 8 being a number of mystical significance on the Disc of cards.
Rules are available in numerous places on-line and the game can be played with two to seven players. Terry Tao as the basis for an actual card game. It contains elements of blackjack and poker.
The most notable aspect of the game is that it requires an eight-suited card deck. The game divides the eight suits into pairs: spades and axes, clubs and tridents, hearts and roses, diamonds and doves. Two "normal" decks may be used, providing there is some way of distinguishing the "modifier" cards. These represent the eight Minor Arcana suits of a Discworld "Caroc" deck: staves, swords, cups, coins, octagrams, elephants, terrapins and crowns. Each player receives a hand of ten cards: five cards are dealt face-down to each player, and the player may then discard up to four of them, receiving new cards to replace them.
Then a further five cards are dealt face-up to each player except the dealer, who receives his face-down. The first player begins by assembling his or her cards into one of the winning groupings described below, and displaying them.
0コメント