From 944cbb37b1fedadea14a4ddddee1a92e4b63bf2d Mon Sep 17 00:00:00 2001 From: Fingon00 Date: Thu, 26 Dec 2024 18:34:49 -0500 Subject: [PATCH 1/2] Small fixes --- Buttons/Turn.py | 20 ++++++++++++-------- helpers/CombatHelper.py | 10 +++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Buttons/Turn.py b/Buttons/Turn.py index ef75a5d..3a8bbc8 100644 --- a/Buttons/Turn.py +++ b/Buttons/Turn.py @@ -126,6 +126,7 @@ async def passForRound(player, game: GamestateHelper, interaction: discord.Inter game.update_player(player_helper) nextPlayer = game.get_next_player(player) game.addToPassOrder(player["player_name"]) + sendPermaPassButton = False if nextPlayer is not None and not game.is_everyone_passed(): view = TurnButtons.getStartTurnButtons(game, nextPlayer, player["color"]) game.initilizeKey("activePlayerColor") @@ -134,12 +135,8 @@ async def passForRound(player, game: GamestateHelper, interaction: discord.Inter await interaction.channel.send("## " + game.getPlayerEmoji(nextPlayer) + " started their turn") await interaction.channel.send(nextPlayer["player_name"] + " use buttons to do your turn" + game.displayPlayerStats(nextPlayer), view=view) - - view2 = View() - view2.add_item(Button(label="Pass Unless Someone Attacks You", - style=discord.ButtonStyle.green, custom_id="permanentlyPass")) - await interaction.followup.send(interaction.user.mention + " you may use this button to pass on reactions" - " unless someone invades your systems.", view=view2, ephemeral=True) + sendPermaPassButton = True + else: view = View() role = discord.utils.get(interaction.guild.roles, name=game.game_id) @@ -167,6 +164,12 @@ async def passForRound(player, game: GamestateHelper, interaction: discord.Inter thread = discord.utils.get(interaction.channel.threads, name=thread_name) if thread is not None: asyncio.create_task(game.showGame(thread, msg2)) + if sendPermaPassButton: + view2 = View() + view2.add_item(Button(label="Pass Unless Someone Attacks You", + style=discord.ButtonStyle.green, custom_id="permanentlyPass")) + await interaction.followup.send(interaction.user.mention + " you may use this button to pass on reactions" + " unless someone invades your systems.", view=view2, ephemeral=True) @staticmethod async def permanentlyPass(player, game: GamestateHelper, interaction: @@ -462,7 +465,8 @@ async def checkTraitor(game: GamestateHelper, player, interaction: discord.Inter if player['color'] in ship: playerPresent = True if playerPresent: - for tile in player["reputation_track"]: + repTrack = player["reputation_track"][:] + for tile in repTrack: if isinstance(tile, str) and "-" in tile and "minor" not in tile: color = tile.split("-")[2] p2 = game.getPlayerObjectFromColor(color) @@ -481,7 +485,7 @@ async def checkTraitor(game: GamestateHelper, player, interaction: discord.Inter game.update_player(player_helper) await interaction.channel.send(f"{player['player_name']}, you broke relations with {color}" " and now are the Traitor.") - return + diff --git a/helpers/CombatHelper.py b/helpers/CombatHelper.py index ac0a318..823b0c6 100644 --- a/helpers/CombatHelper.py +++ b/helpers/CombatHelper.py @@ -675,9 +675,9 @@ async def rollDice(game: GamestateHelper, buttonID: str, interaction: discord.In dice = shipModel.dice missiles = "" nonMissiles = " on initiative " + str(speed) - if speed > 98 and speed < 1000: + if speed > 90 and speed < 1000: dice = shipModel.missile - if len(shipModel.missile) <1 and speed > 98 and speed < 1000: + if len(shipModel.missile) <1 and speed > 90 and speed < 1000: continue missiles = "missiles on initiative " + str(speed-99)+" " nonMissiles = "" @@ -1043,7 +1043,7 @@ async def promptNextSpeed(game: GamestateHelper, pos: str, channel, update: bool if nextSpeed == -20: await Combat.checkForMorphShield(game, pos, channel, ships, [attacker, defender]) for speed, owner in sortedSpeeds: - if speed < 99: + if speed < 90: nextSpeed = speed nextOwner = owner break @@ -1056,8 +1056,8 @@ async def promptNextSpeed(game: GamestateHelper, pos: str, channel, update: bool game.setCurrentRoller(nextOwner, pos) game.setCurrentSpeed(nextSpeed, pos) initiative = f"Initiative {nextSpeed}" - if nextSpeed > 98: - initiative = "Initiative" + str(nextSpeed-99)+" missiles" + if nextSpeed > 90: + initiative = "Initiative " + str(nextSpeed-99)+" missiles" if [nextSpeed, nextOwner] in game.getRetreatingUnits(pos): checker = "FCID" + nextOwner + "_" From 0a13d10d8d89b8455f025def5d92e264dd5de04d Mon Sep 17 00:00:00 2001 From: Fingon00 Date: Thu, 26 Dec 2024 18:41:08 -0500 Subject: [PATCH 2/2] Draft fix --- commands/search_commands.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands/search_commands.py b/commands/search_commands.py index c45b753..434613d 100644 --- a/commands/search_commands.py +++ b/commands/search_commands.py @@ -297,6 +297,8 @@ async def stats(self, interaction: discord.Interaction, tourney_only:bool=False) highestVP = drawing.get_public_points(game.gamestate["players"][player], True) for player in game.gamestate["players"]: username = game.gamestate["players"][player]["username"] + if "(" in username: + username = username.split("(")[0] vp_count[username] += int(100*drawing.get_public_points(game.gamestate["players"][player], True)/highestVP) if game.gamestate["roundNum"] == 9: finished_tourney_games[username] += 1