Skip to content

Instantly share code, notes, and snippets.

@panmari
Created August 14, 2012 13:05
Show Gist options
  • Save panmari/3349094 to your computer and use it in GitHub Desktop.
Save panmari/3349094 to your computer and use it in GitHub Desktop.
Constructor for Hands with CardLayout as parameter is buggy
package ch.aplu.cardex12;
import android.graphics.Color;
import ch.aplu.jcardgame.*;
import ch.aplu.android.*;
public class CardEx12 extends CardGame
{
public enum Suit {
KREUZ, HERZ, KARO, PIK
}
public enum Rank {
ASS, KOENIG, DAME, BAUER, ZEHN, NEUN, ACHT, SIEBEN, SECHS
}
private Deck deck;
private Hand talon;
private Hand pile;
public CardEx12()
{
super(Color.rgb(20, 80, 0), Color.WHITE, BoardType.HORZ_SPLIT,
windowZoom(600));
}
public void main()
{
deck = new Deck(Suit.values(), Rank.values(), "cover");
talon = deck.dealingOut(1, 9)[0];
StackLayout talonLayout = new StackLayout(new Location(200, 300));
talon.setView(this, talonLayout);
talon.draw();
// Bug1: Buggy Constructor
// This doesn't set the TargetArea correctly.
// When trying to transfer a card to a hand declared with this constructor,
// it fails with "Error when calling transfer, target area not defined"
// (Or something along these lines...)
pile = new Hand(deck, new RowLayout(new Location(400, 300), 300, 50));
pile.draw();
talon.addCardListener(new CardAdapter() {
public void pressed(Card card) {
card.transferNonBlocking(pile); }
});
talon.setTouchEnabled(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment