#🔒 Struggling with keyboard module i guess.
7 messages · Page 1 of 1 (latest)
@oblique meadow
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
Hey @oblique meadow!
Please edit your message to use a code block
Make sure there are no spaces between the back ticks and python.
Here is an example of how it should look:
```python
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
import random
import keyboard
class Booster:
def __init__(self,cards_number:int):
self.cards_number = cards_number
def create_booster(self,pool:list) -> list:
nb_booster = []
booster = []
while len(booster) <= self.cards_number - 1:
random_card = random.choice(pool)
if random_card in booster:
pass
else:
booster.append(random_card)
return booster
def open_booster(self,booster:list):
counter = 0
key = keyboard.read_key()
while counter >= len(booster):
card = (booster[counter].get("nom"))
if key == 'u':
print(card)
counter += 1
else:
print("You clicked on the wrong key")
pool = [
{"nom": "Dragon de Feu", "rarete": "légendaire", "valeur": 500},
{"nom": "Chevalier Émeraude", "rarete": "épique", "valeur": 300},
{"nom": "Mage Sombre", "rarete": "rare", "valeur": 150},
{"nom": "Garde de Cristal", "rarete": "rare", "valeur": 140},
{"nom": "Éclaireur des Plaines", "rarete": "commun", "valeur": 50},
{"nom": "Sorcier de Givre", "rarete": "rare", "valeur": 160},
{"nom": "Golem de Pierre", "rarete": "commun", "valeur": 60},
{"nom": "Loup Fantôme", "rarete": "épique", "valeur": 280},
{"nom": "Phoenix", "rarete": "légendaire", "valeur": 520},
{"nom": "Archer Sylvestre", "rarete": "commun", "valeur": 40}
]
booster = Booster(cards_number=5)
booster_1 = booster.create_booster(pool)
booster_2 = booster.create_booster(pool)
booster_3 = booster.create_booster(pool)
print(booster.open_booster(booster_1))
!close
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.