Use the class MacaoCard to create cards for a card game.
Use the constructor MacaoCard to create a card. Then you need to call createFrontLookGeneric() or createFrontLookImage() to create the front look for the card. You also need to call createRearLookGeneric() or createRearLookImage() to create the rear look.
Then you should add the card to a MacaoCardStack object to handle it.
Field Summary | |
---|---|
boolean | IS_CARD This constant marks a card as card. It is always true. |
String | LOOK_NAME_FRONT This constant defines the name of the front look. |
String | LOOK_NAME_REAR This constant defines the name of the rear look. |
String | SUIT_CLUBS This constant defines the suit Clubs. |
String | SUIT_DIAMONDS This constant defines the suit Diamonds. |
String | SUIT_HEARTS This constant defines the suit Hearts. |
String | SUIT_SPADES This constant defines the suit Spades. |
Inherited Fields |
---|
BUNCH_TYPE_SAY, BUNCH_TYPE_STAND, BUNCH_TYPE_WALK |
Constructor Summary |
---|
MacaoCard(String name, String title, number left, number top, optional String cardType, optional boolean exposed, optional integer cardValue, optional String suit)
Use this constructor to create a new card. |
Method Summary | |
---|---|
void | adjustStack(optional boolean startWithCard)
Call this method to adjust the cards of the stack to which this card is currently added. |
integer | compareTo(MacaoCard otherCard)
This method is called to compare two cards for sorting a stack. |
void | createFrontLookGeneric(optional String cardTitle, optional String color, optional String suitImageUrl, optional String centerImageUrl, optional String cardDescription, optional boolean bigDescription, optional boolean descriptionTop)
Call this method to create the front look of the card composed by attributes. |
void | createFrontLookImage(String frontImageUrl, number baseWidth, number baseHeight)
Call this method to create the front look of the card by a single image. |
void | createRearLookGeneric(optional String rearColor, optional String rearImageUrl, optional boolean tile)
Call this method to create the rear look of the card composed by attributes. |
void | createRearLookImage(String rearImageUrl, number baseWidth, number baseHeight)
Call this method to create the rear look of the card by a single image. |
Element | createTable()
Call this method to create a DOM table element in the front look. |
String | getCardType()
Call this method to get the card type. |
integer | getCardValue()
Call this method to get the card value. |
String | getColor()
Call this method to geht the color definition of the text of a generic front side. |
String | getDescription()
Call this method to get the description text, which is displayed in the center of a generic card. |
Element | getFrontElement()
Call this method to get the DOM element of the front look. |
Element | getFrontElementCenter()
Call this method to get the DOM element of the center area of the generic front look. |
Element | getFrontElementDescription()
Call this method to get the DOM element of the description of the generic front look. |
Element | getFrontElementEast()
Call this method to get the DOM element of the right area of the generic front look. |
Element | getFrontElementNorth()
Call this method to get the DOM element of the top area of the generic front look. |
Element | getFrontElementSouth()
Call this method to get the DOM element of the bottom area of the generic front look. |
Element | getFrontElementWest()
Call this method to get the DOM element of the left area of the generic front look. |
Element | getFrontImageCenter()
Call this method to get the DOM element of the center image of the generic front look. |
Element | getFrontImageEast()
Call this method to get the DOM element of the right bottom image of the generic front look. |
Element | getFrontImageWest()
Call this method to get the DOM element of the left top image of the generic front look. |
String | getRearColor()
Call this method to get the background color of the generic rear look. |
Element | getRearElement()
Call this method to get the DOM element of the front look. |
MacaoCardStack | getStack()
Call this method to get the stack to which this card is added. |
String | getSuit()
Call this method to get the suit of the card. |
void | initCard(String name, String title, number left, number top, optional String cardType, optional boolean exposed, optional integer cardValue, optional String suit)
This method is called by the constructor to initialize the card. |
boolean | isExposed()
Call this method to check, if currently the front side of the card is shown. |
boolean | isPulling()
Call this method to check, if the card is currently walking or dragged by the user. |
boolean | isRedSuit()
Call this method to check, if the suit of the card is a red suit |
void | moveTo(number left, number top, optional boolean dontAdjust)
Call this method to move the card to a new position. |
void | objectOnClick(Event event, number mouseX, number mouseY)
This is the inherited method onClick() from MacaoObject. |
void | onClickCard(Event event, number mouseX, number mouseY)
This event handler is called when the user clicks on the card. |
void | onDblClickCard(Event event, number mouseX, number mouseY)
This event handler is called when the user double clicks on the card. |
void | onDrop(Event event, number mouseX, number mouseY, MacaoObject toObject)
This implementation of the event handler forwards the event onDrop to the event handers onDropToCard or onDropToStack. |
void | onDropToCard(MacaoCard card)
This event handler is called, when this card or substack is dropped to another card. |
void | onDropToStack(MacaoCardStack stack)
This event handler is called, when this card or substack is dropped to a stack object. |
void | setCardType(String cardType)
Call this method to set the card type. |
void | setCardValue(integer cardValue)
Call this method to set the card value. |
void | setColor(String color)
Call this method to set the color for the text of the generic front look. |
void | setDescription(String description)
Call this method to set the description text, which is displayed in the center of a generic card. |
void | setExposed(boolean exposed, optional boolean dontAdjustStack)
Call this method to make the card show its front side or rear side. |
void | setRearColor(String rearColor)
Call this method to set the background color for the generic rear look. |
void | setToolTip(optional String toolTip)
Call this method to set the tool tip of the front look of the card. |
void | walkToStack(MacaoCardStack stack, optional number velocity, optional String eventType, optional Array params)
Call this method to make the card or substack walk to the top of another stack. |
Field Details |
---|
This constant marks a card as card. It is always true.
Use this constant to check if an object like a dropped object is a card. Use the following code for example:
if (object.IS_CARD) { //... }
This constant defines the name of the front look.
You can use the following code to access the constant:
MacaoCard.prototype.LOOK_NAME_FRONT
This constant defines the name of the rear look.
You can use the following code to access the constant:
MacaoCard.prototype.LOOK_NAME_REAR
This constant defines the suit Clubs.
You can use the following code to access the constant:
MacaoCard.prototype.SUIT_CLUBS
This constant defines the suit Diamonds.
You can use the following code to access the constant:
MacaoCard.prototype.SUIT_DIAMONDS
This constant defines the suit Hearts.
You can use the following code to access the constant:
MacaoCard.prototype.SUIT_HEARTS
This constant defines the suit Spades.
You can use the following code to access the constant:
MacaoCard.prototype.SUIT_SPADES
Constructor Details |
---|
Use this constructor to create a new card.
Afterwards you need to call createFrontLookGeneric() or createFrontLookImage() to create the front look. You also need to call createRearLookGeneric() or createRearLookImage() to create the rear look.
Method Details |
---|
Call this method to adjust the cards of the stack to which this card is currently added.
This method is called to compare two cards for sorting a stack.
You can override this method to change the sort order.
The default implementation of this method first compres the cards by suit. The suits are ordered by Clubs, Spades, Hearts and Diamonds. If both cards have the same suit, they are ordered by their value.
Call this method to create the front look of the card composed by attributes.
Call this method to create the front look of the card by a single image.
Call this method to create the rear look of the card composed by attributes.
Call this method to create the rear look of the card by a single image.
Call this method to create a DOM table element in the front look.
Call this method to get the card type.
Call this method to get the card value.
The value can be used to calculate a score.
Call this method to geht the color definition of the text of a generic front side.
Call this method to get the description text, which is displayed in the center of a generic card.
Call this method to get the DOM element of the front look.
You can use this reference to manipulate the DOM element.
Call this method to get the DOM element of the center area of the generic front look.
You can use this reference to manipulate the DOM element.
Call this method to get the DOM element of the description of the generic front look.
You can use this reference to manipulate the DOM element.
Call this method to get the DOM element of the right area of the generic front look.
You can use this reference to manipulate the DOM element.
Call this method to get the DOM element of the top area of the generic front look.
You can use this reference to manipulate the DOM element.
Call this method to get the DOM element of the bottom area of the generic front look.
You can use this reference to manipulate the DOM element.
Call this method to get the DOM element of the left area of the generic front look.
You can use this reference to manipulate the DOM element.
Call this method to get the DOM element of the center image of the generic front look.
You can use this reference to manipulate the DOM element.
Call this method to get the DOM element of the right bottom image of the generic front look.
You can use this reference to manipulate the DOM element.
Call this method to get the DOM element of the left top image of the generic front look.
You can use this reference to manipulate the DOM element.
Call this method to get the background color of the generic rear look.
Call this method to get the DOM element of the front look.
You can use this reference to manipulate the DOM element.
Call this method to get the stack to which this card is added.
Call this method to get the suit of the card.
The suit is a keyword, which was provided with the constructor.
This method is called by the constructor to initialize the card.
Call this method, if you inherit your own class from MacaoCard.
Call this method to check, if currently the front side of the card is shown.
Call this method to check, if the card is currently walking or dragged by the user.
Call this method to check, if the suit of the card is a red suit
Call this method to move the card to a new position.
This is the inherited method onClick() from MacaoObject.
This event handler is called when the user clicks on the card.
Implement this event handler to react to a mouse click at the card. There is no standard implementation for this event handler.
This event handler is called when the user double clicks on the card.
Implement this event handler to react to a double click on the card. There is no standard implementation for this event handler.
This implementation of the event handler forwards the event onDrop to the event handers onDropToCard or onDropToStack.
The event handler is called, when the card is dropped to an object.
This event handler is called, when this card or substack is dropped to another card.
If the target card is on a stack, the standard implementation of this method inserts the dropped card or substack on top of the target card in the stack. You may override this method, if you need another behavior.
This event handler is called, when this card or substack is dropped to a stack object.
The default implementation inserts the card or substack to the bottom of the target stack. You may override this method to implement another behavior.
Call this method to set the card type.
You can use the card type for the logic of your game. For example give all queens the card type "Queen".
Call this method to set the card value.
The value can be used to calculate a score.
Call this method to set the color for the text of the generic front look.
Call this method to set the description text, which is displayed in the center of a generic card.
Call this method to make the card show its front side or rear side.
Call this method to set the background color for the generic rear look.
The background color is only visible, if you use no background image.
Call this method to set the tool tip of the front look of the card.
Call this method to make the card or substack walk to the top of another stack.
Logically the card or substack is moved immediately to the target stack. Only the position is not already there.
If a card or a substack is walking depends on the drag schema of the stack, to which this card is added.