Exemple #1
0
# ------------------ class MyMouseListener ---------------------------------
class MyMouseListener(GGMouseListener):
   def mouseEvent(self, mouse):
      Monitor.wakeUp()
      return True
   
# ------------------------ main --------------------------------------------
Suit = enum("SPADES", "HEARTS", "DIAMONDS", "CLUBS")
Rank = enum("ACE", "KING", "QUEEN", "JACK", "TEN", "NINE", "EIGHT", "SEVEN", "SIX")
deck = Deck(Suit.values(), Rank.values(), "cover")

cg = CardGame(900, 615, 30)
cg.addMouseListener(MyMouseListener(), GGMouse.lPress)
while True:
   hand = deck.dealingOut(1, 25)[0]

   hand.setView(cg, RowLayout(Location(450, 80), 890))
   hand.sort(SortType.RANKPRIORITY, True)

   sequence3 = hand.extractSequences(Suit.HEARTS, 3)
   for i in range(len(sequence3)):
      sequence3[i].setView(cg, RowLayout(Location(70 + 150 * i, 230), 120))
      sequence3[i].draw()
 
   sequence4 = hand.extractSequences(Suit.HEARTS, 4)
   for i in range(len(sequence4)):
      sequence4[i].setView(cg, RowLayout(Location(70 + 150 * i, 380), 120))
      sequence4[i].draw()

   sequence5 = hand.extractSequences(Suit.HEARTS, 5)
Exemple #2
0

# ------------------ global functions --------------------------------------
def initToolBar():
    global cutBtn
    global numbers
    numbers = ToolBarStack("sprites/number30.gif", 10)
    separator = ToolBarSeparator(2, 30, X11Color("black"))
    cutBtn = ToolBarItem("sprites/cutBtn.gif", 3)
    toolBar = ToolBar(cg)
    toolBar.addItem(numbers, separator, cutBtn)
    toolBar.show(Location(7, 160))
    toolBar.addToolBarListener(MyToolBarListener())


# ------------------------ main --------------------------------------------
Suit = enum("SPADES", "HEARTS", "DIAMONDS", "CLUBS")
Rank = enum("ACE", "KING", "QUEEN", "JACK", "TEN", "NINE", "EIGHT", "SEVEN",
            "SIX")

deck = Deck(Suit.values(), Rank.values(), "cover")
hand = deck.dealingOut(1, 5, True)[0]

cutBtn = None
numbers = None

cg = CardGame(300, 200)
hand.setView(cg, RowLayout(Location(150, 80), 290))
hand.draw()
initToolBar()
Exemple #3
0
# Ex02.py

from ch.aplu.jgamegrid import Location
from ch.aplu.jcardgame import Deck, CardGame, RowLayout, StackLayout, CardListener
from ch.aplu.jcardgame.Hand import SortType

# ------------------ class MyCardListener ----------------------------------
class MyCardListener(CardListener):
   def leftDoubleClicked(self, card):
      card.transfer(stock, True)

# ------------------------ main --------------------------------------------
Suit = enum("SPADES", "HEARTS", "DIAMONDS", "CLUBS")
Rank = enum("ACE", "KING", "QUEEN", "JACK", "TEN", "NINE", "EIGHT", "SEVEN", "SIX")
deck = Deck(Suit.values(), Rank.values(), "cover");

cg = CardGame(600, 600)
hands = deck.dealingOut(1, 9)
stock = hands[1]
stock.setView(cg, StackLayout(Location(300, 150)))
stock.draw()

hands[0].setView(cg, RowLayout(Location(300, 400), 500))
hands[0].sort(SortType.SUITPRIORITY, False)
hands[0].draw()
hands[0].addCardListener(MyCardListener())
hands[0].setTouchEnabled(True)
cg.setDoubleClickDelay(300)
Exemple #4
0
def insertInHand(actor):
    actor.removeSelf()
    card = actor.getCard()
    hand.insert(card, False)
    hand.sort(SortType.RANKPRIORITY, True)
    takeFromTalon()


def addActor(cardActor):
    cg.addActor(cardActor, Location(talonLocation))
    cardActor.addMouseTouchListener(
        MyMouseTouchListener(),
        GGMouse.lPress | GGMouse.lDrag | GGMouse.lRelease, True)


# ------------------------ main --------------------------------------------
handLocation = Location(250, 100)
talonLocation = Location(250, 300)
hotSpot = Point(0, 0)

cg = CardGame(500, 400, 30)
hands = deck.dealingOut(1, 2)  # only two cards in hand
hand = hands[0]
hand.setView(cg, RowLayout(handLocation, 400))
talon = hands[1]
talon.setView(cg, StackLayout(talonLocation))
hand.draw()
talon.draw()
takeFromTalon()
cg.setStatusText("Drag cards from card talon to the hand")
Exemple #5
0
    toolBar = ToolBar(cg)
    toolBar.addItem(upBtn, numbers, downBtn)
    toolBar.show(Location(160, 185))
    numbers.show(3)  # Default start number
    toolBar.addToolBarListener(MyToolBarListener())


def sortAndDrawHands():
    upperHand.sort(SortType.RANKPRIORITY, True)
    lowerHand.sort(SortType.RANKPRIORITY, True)


# ------------------------ main --------------------------------------------
Suit = enum("SPADES", "HEARTS", "DIAMONDS", "CLUBS")
Rank = enum("ACE", "KING", "QUEEN", "JACK", "TEN", "NINE", "EIGHT", "SEVEN",
            "SIX")
deck = Deck(Suit.values(), Rank.values(), "cover")

upBtn = None
downBtn = None
numbers = None

cg = CardGame(460, 400)
hands = deck.dealingOut(2, 5, True)
upperHand = hands[0]
upperHand.setView(cg, RowLayout(Location(230, 100), 400))
lowerHand = hands[1]
lowerHand.setView(cg, RowLayout(Location(230, 300), 400))
sortAndDrawHands()
initToolBar()
Exemple #6
0
# Ex01.py

from ch.aplu.jgamegrid import Location
from ch.aplu.jcardgame import Deck, CardGame, RowLayout, ColumnLayout, FanLayout

# ------------------------ main --------------------------------------------
Suit = enum("SPADES", "HEARTS", "DIAMONDS", "CLUBS")
Rank = enum("ACE", "KING", "QUEEN", "JACK", "TEN", "NINE", "EIGHT", "SEVEN",
            "SIX")
deck = Deck(Suit.values(), Rank.values(), "cover")

cg = CardGame(600, 600)
hands = deck.dealingOut(4, 5)

rowLayout0 = RowLayout(Location(150, 520), 300)
hands[0].setView(cg, rowLayout0)
hands[0].draw()

rowLayout1 = RowLayout(Location(150, 370), 300)
rowLayout1.setStepDelay(10)
hands[1].setView(cg, rowLayout1)
hands[1].draw()

columnLayout0 = ColumnLayout(Location(370, 390), 400)
hands[2].setView(cg, columnLayout0)
hands[2].draw()

columnLayout1 = ColumnLayout(Location(470, 390), 400)
columnLayout1.setScaleFactor(0.7)
columnLayout1.setStepDelay(10)
hands[3].setView(cg, columnLayout1)