Example #1
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)
 
Example #2
0
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):
            cg.setStatusText("Player " + str(i) + " thinking...")
            cg.delay(thinkingTime)
            if not simulateMove(i) or checkOver(
                    i):  #  talon empty or game over
                isGameOver = True
                break
        if not isGameOver:
            setMyMove()
    cg.delay(100)