Ejemplo n.º 1
0
            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()
Ejemplo n.º 2
0
   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)
   for i in range(len(sequence5)):
      sequence5[i].setView(cg, RowLayout(Location(100 + 200 * i, 530), 150))
      sequence5[i].draw()
 
   cg.setStatusText("Click to generate the next card set.");
   Monitor.putSleep()
   if cg.isDisposed():
      break
 
   # Cleanup all hands
   hand.removeAll(False)
   for h in sequence3:
      h.removeAll(False)
   for h in sequence4:
      h.removeAll(False)
   for h in sequence5:
      h.removeAll(False)
 
Ejemplo n.º 3
0
# ------------------------ 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]
    rowLayout = RowLayout(Location(450, 80), 890)
    hand.setView(cg, rowLayout)
    hand.sort(SortType.RANKPRIORITY, True)
    hand.draw()
    cg.setStatusText("Click to get pairs, trips and quads")
    Monitor.putSleep()
    if cg.isDisposed():
        break
    pairs = hand.extractPairs()
    for i in range(len(pairs)):
        pairs[i].setView(cg, RowLayout(Location(70 + 150 * i, 230), 120))
        pairs[i].draw()

    trips = hand.extractTrips()
    for i in range(len(trips)):
        trips[i].setView(cg, RowLayout(Location(70 + 150 * i, 380), 120))
        trips[i].draw()

    quads = hand.extractQuads()
    for i in range(len(quads)):
Ejemplo n.º 4
0
talon = None
thinkingTime = 1200  # ms
pile = Hand(deck)
isPartnerMoves = False
okBtn = GGButton("sprites/done30.gif", True)
toolBarTextActor = Actor("sprites/text_item.png")
spadeItem = ToolBarItem("sprites/spades_item.png", 2)
heartItem = ToolBarItem("sprites/hearts_item.png", 2)
diamondItem = ToolBarItem("sprites/diamonds_item.png", 2)
clubItem = ToolBarItem("sprites/clubs_item.png", 2)
Item = ToolBarItem("sprites/clubs_item.png", 2)

cg = CardGame(600, 600, 30)
cg.setTitle("Mau-Mau (V" + version +
            ") constructed with JGameGrid (www.aplu.ch)")
cg.setStatusText("Initializing...")
initHands()
cg.addActor(okBtn, hideLocation)
okBtn.addButtonListener(MyButtonListener())
toolBarTextActor.hide()
cg.addActor(toolBarTextActor, toolBarTextLocation)
toolBar = ToolBar(cg)
toolBar.addItem(spadeItem, heartItem, diamondItem, clubItem)
toolBar.show(hideLocation)
toolBar.addToolBarListener(MyToolBarListener())

while not cg.isDisposed():
    isGameOver = False
    if isPartnerMoves:
        isPartnerMoves = False
        for i in range(1, nbPlayers):
Ejemplo n.º 5
0
    Location(525, 300),
    Location(300, 300)
]
bidLocations = [
    Location(300, 350),
    Location(250, 300),
    Location(300, 250),
    Location(350, 300)
]
stockLocations = [
    Location(400, 500),
    Location(100, 400),
    Location(200, 100),
    Location(500, 200)
]

hands = None
bids = [0] * nbPlayers
stocks = [0] * nbPlayers
talon = None
currentPlayer = 0
nbMovesInRound = 0
targetCount = 0

cg = CardGame(600, 600, 30)
dealingOut()
cg.setStatusText("Dealing out...done. Double click to play.")
initBids()
initStocks()
hands[0].setTouchEnabled(True)
Ejemplo n.º 6
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")
Ejemplo n.º 7
0
                hands[i].sort(SortType.RANKPRIORITY, False)
            else:
                hands[i].setVerso(True)
            hands[i].draw()

    talonCover.removeSelf()
    hands[0].setTouchEnabled(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")

hands = None
talon = None
nbPlayers = 4
handLocations = [
    Location(300, 525),
    Location(75, 300),
    Location(300, 75),
    Location(525, 300)
]
talonLocation = Location(300, 300)
packetSize = 3

cg = CardGame(600, 600, 30)
dealingOut()
cg.setStatusText("Dealing Out...done")