de.htwdd.rosenkoenig.gui.genuts
Class GUICard

java.lang.Object
  extended by com.genuts.gameui.Sprite
      extended by com.genuts.gameui.SpriteWrapper
          extended by de.htwdd.rosenkoenig.gui.genuts.GUICard
All Implemented Interfaces:
Tickable, Clickable, java.lang.Cloneable

public class GUICard
extends SpriteWrapper
implements Clickable

This class represents a card belonging to a player's card deck. The card consists of a blue/white background and a sword. The sword can point to 8 different directions and can have between one and three rings around it's blade. If the player intends to play a card, he has to click it.
In state SELECTED the rings rotate around the blade.


Field Summary
private  ImageSequenceSprite background
           
private  Card card
           
private  Sprite flower
           
private static int FLOWER_OFFSET
           
private  Game game
           
private  java.util.EnumMap<ImageState,java.awt.Image> imgBacks
           
private  java.util.EnumMap<ImageState,java.awt.Image> imgSwords
           
private  PlayField playfield
           
private  ImageState state
           
private  AnimatedSprite sword
           
private static int VARIATION
           
 
Constructor Summary
GUICard(Card card, Game game, PlayField playfield, Color color)
          Creates and initializes a GUICard
 
Method Summary
 void click(java.awt.event.MouseEvent event)
          select a card
 boolean isSpriteAt(int x, int y)
          both sword and background shall be clickable
 void remove()
          removes all sprites from the playfield
 void setCardState(ImageState state)
          sets the card's state
 void setKnightable(boolean knightable)
          Puts a small flower to the upper right or left edge of the card to indicate that this card is only playable by using a knight.
 boolean setPosition(int x, int y)
          Positions the card on the playfield, adds a random offset to the specified position.
 
Methods inherited from class com.genuts.gameui.SpriteWrapper
checkCollision, cloneSprite, collisionWith, getActionSprite, getBackground, getBottomCollisionOffset, getBounds, getFinalActionSprite, getHeight, getId, getImage, getLeftCollisionOffset, getParent, getPosition, getRightCollisionOffset, getRotation, getSize, getTopCollisionOffset, getWidth, getX, getY, invalidate, isBackgroundSprite, isPremode, isValidate, isVisible, paint, preCollisionWith, repaint, setActionSprite, setBackground, setBackgroundSprite, setBottomCollisionOffset, setBounds, setBounds, setId, setImage, setLeftCollisionOffset, setParent, setPremode, setRightCollisionOffset, setRotation, setSize, setTopCollisionOffset, setVisible, tick, validate
 
Methods inherited from class com.genuts.gameui.Sprite
getFinalWrapper, getWrapper, setWrapper, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VARIATION

private static final int VARIATION
See Also:
Constant Field Values

FLOWER_OFFSET

private static final int FLOWER_OFFSET
See Also:
Constant Field Values

imgBacks

private java.util.EnumMap<ImageState,java.awt.Image> imgBacks

imgSwords

private java.util.EnumMap<ImageState,java.awt.Image> imgSwords

playfield

private PlayField playfield

background

private ImageSequenceSprite background

sword

private AnimatedSprite sword

flower

private Sprite flower

state

private ImageState state

game

private Game game

card

private Card card
Constructor Detail

GUICard

public GUICard(Card card,
               Game game,
               PlayField playfield,
               Color color)
Creates and initializes a GUICard

Parameters:
card - the logical representation of this card
game - the game this card belongs to
playfield - the playfield this card belongs to
color - the card's color (red or white)
Method Detail

setCardState

public void setCardState(ImageState state)
sets the card's state

Parameters:
state - disabled, enabled or selected

setKnightable

public void setKnightable(boolean knightable)
Puts a small flower to the upper right or left edge of the card to indicate that this card is only playable by using a knight.

Parameters:
knightable -

setPosition

public boolean setPosition(int x,
                           int y)
Positions the card on the playfield, adds a random offset to the specified position.

Overrides:
setPosition in class SpriteWrapper
Parameters:
x - x position
y - y position

isSpriteAt

public boolean isSpriteAt(int x,
                          int y)
both sword and background shall be clickable

Overrides:
isSpriteAt in class SpriteWrapper

remove

public void remove()
removes all sprites from the playfield


click

public void click(java.awt.event.MouseEvent event)
select a card

Specified by:
click in interface Clickable