コード例 #1
0
ファイル: Ex11.py プロジェクト: ssramitsharma/Hackathon
from ch.aplu.jcardgame import Deck, CardGame, RowLayout, Hand
from ch.aplu.jcardgame.Hand import SortType
from ch.aplu.util import Monitor

# ------------------ 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))
コード例 #2
0
ファイル: Ex07.py プロジェクト: ssramitsharma/Hackathon
            deck.getRank(id)
            card = Card(deck, deck.getSuit(i), deck.getRank(id))
            break
    return card


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

nbRanks = len(Rank.values())
deck = Deck(Suit.values(), Rank.values(), "cover")
hand = Hand(deck)
sortBtn = None

textItem = ToolBarText("Select Card:", 30)
separator0 = ToolBarSeparator(2, 30, X11Color("black"))
spades = ToolBarStack("sprites/spades.gif", nbRanks)
hearts = ToolBarStack("sprites/hearts.gif", nbRanks)
diamonds = ToolBarStack("sprites/diamonds.gif", nbRanks)
clubs = ToolBarStack("sprites/clubs.gif", nbRanks)
separator1 = ToolBarSeparator(2, 30, X11Color("black"))
okBtn = ToolBarItem("sprites/ok30.gif", 2)

cg = CardGame(300, 250, 30)
cg.setStatusText("Select a card by clicking on the card stacks and press OK.")
hand.setView(cg, RowLayout(Location(150, 125), 290))
hand.draw()
initToolBar()
コード例 #3
0
ファイル: Ex08.py プロジェクト: ssramitsharma/Hackathon

# ------------------ 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()
コード例 #4
0
ファイル: Ex02.py プロジェクト: ssramitsharma/Hackathon
# 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)
コード例 #5
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")
コード例 #6
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()