diff --git a/Calculator.py b/Calculator.py index 8e27c9d..6a874cc 100644 --- a/Calculator.py +++ b/Calculator.py @@ -23,6 +23,7 @@ class Calculator(discord.ui.View): self.division: "/", self.exponent: "^" } + self.clearRequirement = 0 def numDigits(self, integer): numDigits = 0 @@ -31,6 +32,11 @@ class Calculator(discord.ui.View): integer = integer // 10 return numDigits + def clear(self): + self.inputOne = 0 + self.inputTwo = None + self.output = None + def display(self): inputOneLength = self.numDigits(self.inputOne) inputTwoLength = self.numDigits(self.inputTwo) @@ -47,6 +53,9 @@ class Calculator(discord.ui.View): return displayOutput async def number(self, interaction: discord.Interaction, number): + if self.output is not None: + self.inputOne = 0 + self.output = None self.inputOne = self.inputOne * 10 + number self.numDigs = self.numDigs + 1 await interaction.response.edit_message( @@ -54,6 +63,7 @@ class Calculator(discord.ui.View): view=self) async def operator(self, interaction: discord.Interaction, operation): + self.output = None self.inputTwo = self.inputOne self.inputOne = 0 self.expression = operation @@ -119,12 +129,19 @@ class Calculator(discord.ui.View): @discord.ui.button(label="=", style=discord.ButtonStyle.green, row=4) async def equals(self, interaction: discord.Interaction, button: discord.ui.Button): + if self.clearRequirement: + self.clear() + else: + self.clearRequirement += 1 self.output = self.expression(self.inputTwo, self.inputOne) if (self.inputTwo == 9) and (self.inputOne == 10): self.output = 21 await interaction.response.edit_message( content=self.display(), view=self) + + self.inputOne = self.output + self.inputTwo = None @discord.ui.button(label="/", style=discord.ButtonStyle.red, row=4) async def divide(self, interaction: discord.Interaction, button: discord.ui.Button): diff --git a/Gamepicker.py b/Gamepicker.py index ba0102a..508d395 100644 --- a/Gamepicker.py +++ b/Gamepicker.py @@ -15,13 +15,17 @@ games = ["Left 4 Dead 2", "Magicka 2", ] +def add_game(game: str): + games.append(game) + + def pick_game(): randomIndex = random.randrange(0, len(games)) coinFlip = random.randrange(0, 2) if coinFlip: - return "Valorant" + return f"Valorant ({games[randomIndex]})" else: return games[randomIndex] diff --git a/ledger.db-journal b/ledger.db-journal deleted file mode 100644 index 9200c0d..0000000 Binary files a/ledger.db-journal and /dev/null differ