Skip to content
Merged

Stats #336

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions commands/search_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ async def stats(self, interaction: discord.Interaction, tourney_only:bool=False)
await interaction.followup.send("Here are your stats")
lowerLim = 100
higherLim = 999
gameSumString = ""
if tourney_only:
higherLim = 288
lowerLim = 254
Expand All @@ -295,6 +296,9 @@ async def stats(self, interaction: discord.Interaction, tourney_only:bool=False)
continue
else:
round_count["Round "+str(game.gamestate["roundNum"])] +=1
if game.gamestate["roundNum"] != 9:
continue
gameSumString += f"{gameName}: "
highestVP = 1
for player in game.gamestate["players"]:
if drawing.get_public_points(game.gamestate["players"][player], True) > highestVP:
Expand All @@ -304,6 +308,7 @@ async def stats(self, interaction: discord.Interaction, tourney_only:bool=False)
if "(" in username:
username = username.split("(")[0].replace(" ","")
vp_count[username] += round(float(100.0*drawing.get_public_points(game.gamestate["players"][player], True)/highestVP),2)
gameSumString += f"{username}: {drawing.get_public_points(game.gamestate["players"][player], True)} "
if game.gamestate["roundNum"] == 9:
finished_tourney_games[username] += 1
else:
Expand All @@ -320,6 +325,7 @@ async def stats(self, interaction: discord.Interaction, tourney_only:bool=False)
faction = "Terran"
faction_performance[faction] += int(100*factionVP/highestScore)
max_faction_performance[faction] +=100
gameSumString += "\n"
with open("data/factions.json", "r") as f:
faction_data = json.load(f)
# await interaction.followup.send("Total Faction Draft Counts:")
Expand All @@ -335,24 +341,24 @@ async def stats(self, interaction: discord.Interaction, tourney_only:bool=False)
# await interaction.channel.send(f"{faction_data[faction]['name']}: {count}")

if tourney_only:
summary = "Round Progression:\n"
for roundN, count in round_count.most_common():
summary += f"{roundN}: {count} games\n"
asyncio.create_task(interaction.channel.send(summary) )
summary = "Point Progression:\n"
rank = 1
for username, count in vp_count.most_common():
summary += f"{rank}. {username}: {round(count,2)}/300 VPs ({str(finished_tourney_games[username])} games)\n"
rank += 1
asyncio.create_task(interaction.channel.send(summary) )
summary = "Faction Wins:\n"
for faction, count in faction_victory_count.most_common():
summary += f"{faction}: {count} wins\n"
asyncio.create_task(interaction.channel.send(summary) )
summary = "Faction Performance:\n"
for faction, count in faction_performance.most_common():
relative_faction_performance[faction] += int(count/max_faction_performance[faction] * 100)
for faction, count in relative_faction_performance.most_common():
summary += f"{faction}: {count} out of 100 possible points (in {str(int(max_faction_performance[faction]/100))} games)\n"
asyncio.create_task(interaction.channel.send(summary) )
# summary = "Round Progression:\n"
# for roundN, count in round_count.most_common():
# summary += f"{roundN}: {count} games\n"
# asyncio.create_task(interaction.channel.send(summary) )
# summary = "Point Progression:\n"
# rank = 1
# for username, count in vp_count.most_common():
# summary += f"{rank}. {username}: {round(count,2)}/300 VPs ({str(finished_tourney_games[username])} games)\n"
# rank += 1
# asyncio.create_task(interaction.channel.send(summary) )
# summary = "Faction Wins:\n"
# for faction, count in faction_victory_count.most_common():
# summary += f"{faction}: {count} wins\n"
# asyncio.create_task(interaction.channel.send(summary) )
# summary = "Faction Performance:\n"
# for faction, count in faction_performance.most_common():
# relative_faction_performance[faction] += int(count/max_faction_performance[faction] * 100)
# for faction, count in relative_faction_performance.most_common():
# summary += f"{faction}: {count} out of 100 possible points (in {str(int(max_faction_performance[faction]/100))} games)\n"
asyncio.create_task(interaction.channel.send(gameSumString))

8 changes: 4 additions & 4 deletions helpers/CombatHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ def getShipToSelfHitWithRiftCannon(game: GamestateHelper, colorOrAI, player_ship
ship = option
return ship

# Not currently in use, will be built to improve AI targetting in future
@staticmethod
async def rollDiceAI(game: GamestateHelper, buttonID: str, interaction: discord.Interaction):
pos = buttonID.split("_")[1]
Expand All @@ -500,15 +499,16 @@ async def rollDiceAI(game: GamestateHelper, buttonID: str, interaction: discord.
ships = Combat.getCombatantShipsBySpeed(game, colorOrAI, player_ships, pos)
update = False
for ship in ships:
if ship[0] == speed or (speed == ship[0]+99):
if ship[0] == speed or int(ship[0]+99) == speed:
shipModel = AI_Ship(ship[1], game.gamestate["advanced_ai"], game.gamestate["wa_ai"])
name = "The AI"
dice = shipModel.dice
missiles = ""
nonMissiles = " on initiative " + str(speed)
if speed > 98 and speed < 1000:
dice = shipModel.missile
if len(shipModel.missile) <1 and speed > 98 and speed < 1000:
if len(shipModel.missile) < 1 and speed > 98 and speed < 1000:
await interaction.channel.send("Something went wrong and no missiles were found for this AI")
continue
missiles = "missiles on initiative " + str(speed-99)+" "
nonMissiles = ""
Expand Down Expand Up @@ -668,7 +668,7 @@ async def rollDice(game: GamestateHelper, buttonID: str, interaction: discord.In
update = False
popRiftProtector = True
for ship in ships:
if ship[0] == speed or (speed == ship[0]+99) or speed == 1000:
if ship[0] == speed or speed == (ship[0]+99) or speed == 1000:
name = interaction.user.mention
player = game.get_player_from_color(colorOrAI)
shipModel = PlayerShip(game.gamestate["players"][player], ship[1])
Expand Down
Loading