- Jun 19, 2020
- 57
- 30
Hi again!
I'm working in a card game inside my story in Ren'py, most of it is done, but I'm struggling with some complex imabuttons. I'll put the full code for a better explanation:
There is a 'deck' var holding a list with cards (a list of names like ace_of_spades, two_of_hearts, etc). This is the button to buy one card to hand (max of 5 cards). So it first checks if one of the "hand slots" is empty (with a 'deckback' value) to be active/sensitive, and if so, it puts a card in that "slot". Else, checks the next, and so on.
The problem is that cards are being repeated, so suddenly I can get two aces of spades at same time. I'm trying to implement a "deck.del()" to remove from deck the card that was just bought (so, the value of the "hand1" var, or "hand2", etc).
Any idea? Maybe I'm trying a wrong approach?
I'm working in a card game inside my story in Ren'py, most of it is done, but I'm struggling with some complex imabuttons. I'll put the full code for a better explanation:
Python:
imagebutton idle "images/cards/deckback.png" hover "images/cards/deckback_h.png" xpos 0.70 ypos 0.45 focus_mask True action [SensitiveIf(hand1 == 'deckback' or hand2 == 'deckback' or hand3 == 'deckback' or hand4 == 'deckback' or hand5 == 'deckback'), If(hand1=='deckback', SetVariable('hand1',renpy.random.sample(deck,1)[0]),If(hand2=='deckback',SetVariable('hand2',renpy.random.sample(deck,1)[0]),If(hand3=='deckback',SetVariable('hand3',renpy.random.sample(deck,1)[0]),If(hand4=='deckback',SetVariable('hand4',renpy.random.sample(deck,1)[0]),If(hand5=='deckback',SetVariable('hand5',renpy.random.sample(deck,1)[0]))))))]
The problem is that cards are being repeated, so suddenly I can get two aces of spades at same time. I'm trying to implement a "deck.del()" to remove from deck the card that was just bought (so, the value of the "hand1" var, or "hand2", etc).
Any idea? Maybe I'm trying a wrong approach?