Skip to content

Commit d7eb232

Browse files
committed
fixed environment, continued work on commands
1 parent 03ab7c2 commit d7eb232

File tree

4 files changed

+89
-39
lines changed

4 files changed

+89
-39
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,4 @@ env
359359
/simmadome/build
360360
/simmadome/.eslintcache
361361
/matteo_env/Lib/site-packages
362+
/new_matteo_env

games.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ def get_team_and_owner(name):
954954
update_team(team_json)
955955
return (team_json, owner_id)
956956
except:
957-
return None
957+
return (None, None)
958958

959959
def save_team(this_team, user_id):
960960
try:

the-prestige.pyproj

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<OutputPath>.</OutputPath>
1212
<Name>the-prestige</Name>
1313
<RootNamespace>the-prestige</RootNamespace>
14-
<InterpreterId>MSBuild|matteo_env|$(MSBuildProjectFullPath)</InterpreterId>
14+
<InterpreterId>MSBuild|new_matteo_env|$(MSBuildProjectFullPath)</InterpreterId>
1515
<IsWindowsApplication>False</IsWindowsApplication>
1616
<SuppressConfigureTestFrameworkPrompt>true</SuppressConfigureTestFrameworkPrompt>
1717
</PropertyGroup>
@@ -67,6 +67,15 @@
6767
<PathEnvironmentVariable>PYTHONPATH</PathEnvironmentVariable>
6868
<Architecture>X86</Architecture>
6969
</Interpreter>
70+
<Interpreter Include="new_matteo_env\">
71+
<Id>new_matteo_env</Id>
72+
<Version>3.8</Version>
73+
<Description>new_matteo_env (Python38-32)</Description>
74+
<InterpreterPath>Scripts\python.exe</InterpreterPath>
75+
<WindowsInterpreterPath>Scripts\pythonw.exe</WindowsInterpreterPath>
76+
<PathEnvironmentVariable>PYTHONPATH</PathEnvironmentVariable>
77+
<Architecture>X86</Architecture>
78+
</Interpreter>
7079
</ItemGroup>
7180
<ItemGroup>
7281
<Content Include="config.json" />
@@ -43336,6 +43345,9 @@
4333643345
<Folder Include="static\" />
4333743346
<Folder Include="templates\" />
4333843347
</ItemGroup>
43348+
<ItemGroup>
43349+
<InterpreterReference Include="Global|VisualStudio|Python38-32" />
43350+
</ItemGroup>
4333943351
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
4334043352
<!-- Uncomment the CoreCompile target to enable the Build command in
4334143353
Visual Studio and specify your pre- and post-build commands in

the_prestige.py

+74-37
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class ShowPlayerCommand(Command):
9696
@client.tree.command()
9797
@app_commands.rename(command="name")
9898
async def showplayer(interaction: discord.Interaction, command: str):
99+
"""Show a single player's stats."""
99100
player_name = json.loads(ono.get_stats(command))
100101
await interaction.response.send_message(embed=build_star_embed(player_name))
101102

@@ -112,6 +113,7 @@ class StartGameCommand(Command):
112113
@app_commands.rename(wthr="weather")
113114
@app_commands.choices(wthr=weather.weather_choices())
114115
async def startgame(interaction, away: str, home: str, innings: Optional[int]=9, wthr: Optional[app_commands.Choice[str]] = None, flags: Optional[str] = ""):
116+
"""Start a game with the given teams and, optionally, weather choice and custom inning number."""
115117
league = None
116118
day = None
117119
innings = None
@@ -180,6 +182,7 @@ class StartRandomGameCommand(Command):
180182

181183
@client.tree.command()
182184
async def randomgame(interaction):
185+
"""Start a game between two random teams."""
183186
if config()["game_freeze"]:
184187
raise CommandError("Patch incoming. We're not allowing new games right now.")
185188

@@ -194,11 +197,13 @@ async def randomgame(interaction):
194197

195198
class SaveTeamCommand(Command):
196199
name = "saveteam"
197-
template = """m;saveteam
200+
template = """m;saveteam [bot ping]
198201
[name]
199202
[slogan]
200203
[lineup]
201-
[rotation]"""
204+
[rotation]
205+
206+
"""
202207

203208
description = """Saves a team to the database allowing it to be used for games. Send this command at the top of a list, with entries separated by new lines (shift+enter in discord, or copy+paste from notepad).
204209
- the first line of the list is your team's name.
@@ -207,9 +212,7 @@ class SaveTeamCommand(Command):
207212
- the next lines are your batters' names in the order you want them to appear in your lineup, lineups can contain any number of batters between 1 and 12.
208213
- there must be another blank line between your batters and your pitchers.
209214
- the final lines are the names of the pitchers in your rotation, rotations can contain any number of pitchers between 1 and 8.
210-
If you did it correctly, you'll get a team embed with a prompt to confirm. hit the 👍 and your team will be saved!
211-
212-
***NOTE: This only functions in the bot's DMs. Do not use on a server."""
215+
If you did it correctly, you'll get a team embed with a prompt to confirm. hit the 👍 and your team will be saved!"""
213216

214217
async def execute(self, msg, command, flags):
215218
if db.get_team(command.split('\n',1)[1].split("\n")[0]) == None:
@@ -221,14 +224,20 @@ async def execute(self, msg, command, flags):
221224
name = command.split('\n',1)[1].split('\n')[0]
222225
raise CommandError(f"{name} already exists. Try a new name, maybe?")
223226

227+
@client.tree.command()
228+
async def newteam(interaction):
229+
"""Get new team instructions. Sent privately, don't worry!"""
230+
await interaction.response.send_message(SaveTeamCommand.template + SaveTeamCommand.description , ephemeral=True)
231+
224232
class AssignArchetypeCommand(Command):
225233
name = "archetype"
226234
template = "m;archetype [team name]\n[player name]\n[archetype name]"
227235
description = """Assigns an archetype to a player on your team. This can be changed at any time! For a description of a specific archetype, or a list of all archetypes, use m;archetypehelp."""
228236

229237
@client.tree.command()
230238
@app_commands.choices(archetype=archetypes.archetype_choices())
231-
async def archetype(interaction, team: str, player: str, archetype: app_commands.Choice[str]):
239+
async def setarchetype(interaction, team: str, player: str, archetype: app_commands.Choice[str]):
240+
"""Assigns an archetype to a player on an owned team. Reversible."""
232241
try:
233242
team = get_team_fuzzy_search(team)
234243
player_name = player
@@ -266,6 +275,7 @@ class ArchetypeHelpCommand(Command):
266275
@client.tree.command()
267276
@app_commands.choices(archetype=archetypes.archetype_choices())
268277
async def archetypehelp(interaction, archetype: app_commands.Choice[str]):
278+
"""Describes a specific archetype."""
269279
arch = archetypes.search_archetypes(archetype.value)
270280
if arch is None:
271281
raise CommandError("We don't know what that archetype is. If you're trying to break new ground, here isn't the time *or* the place.")
@@ -283,6 +293,7 @@ class ViewArchetypesCommand(Command):
283293
@client.tree.command()
284294
@app_commands.rename(team_name="team")
285295
async def teamarchetypes(interaction, team_name: str):
296+
"""Lists the current archetypes on a team."""
286297
team = get_team_fuzzy_search(team_name)
287298
if team is None:
288299
raise CommandError("We can't find that team, boss.")
@@ -321,6 +332,7 @@ class ShowTeamCommand(Command):
321332
@client.tree.command()
322333
@app_commands.rename(team_name="team")
323334
async def showteam(interaction, team_name: str):
335+
"""Display a team's roster and relevant ratings."""
324336
team = get_team_fuzzy_search(team_name)
325337
if team is not None:
326338
await interaction.response.send_message(embed=build_team_embed(team))
@@ -356,6 +368,11 @@ class CreditCommand(Command):
356368
async def execute(self, msg, command, flags):
357369
await msg.channel.send("Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter.")
358370

371+
@client.tree.command()
372+
async def credit(interaction):
373+
"""Show artist credit for the bot's avatar."""
374+
await interaction.response.send_message("Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter.")
375+
359376
class SwapPlayerCommand(Command):
360377
name = "swapsection"
361378
template = """m;swapsection
@@ -370,7 +387,7 @@ async def execute(self, msg, command, flags):
370387
team, owner_id = games.get_team_and_owner(team_name)
371388
if team is None:
372389
raise CommandError("Can't find that team, boss. Typo?")
373-
elif owner_id != msg.author.id and msg.author.id not in config()["owners"]:
390+
elif owner_id != interaction.user.id and interaction.user.id not in config()["owners"]:
374391
raise CommandError("You're not authorized to mess with this team. Sorry, boss.")
375392
elif not team.swap_player(player_name):
376393
raise CommandError("Either we can't find that player, you've got no space on the other side, or they're your last member of that side of the roster. Can't field an empty lineup, and we *do* have rules, chief.")
@@ -381,6 +398,22 @@ async def execute(self, msg, command, flags):
381398
except IndexError:
382399
raise CommandError("Three lines, remember? Command, then team, then name.")
383400

401+
@client.tree.command()
402+
@app_commands.rename(team_name="team", player_name="player")
403+
async def swapplayer(interaction, team_name: str, player_name: str):
404+
"""Swaps a player on an owned team between lineup and rotation."""
405+
team, owner_id = games.get_team_and_owner(team_name)
406+
if team is None:
407+
raise CommandError("Can't find that team, boss. Typo?")
408+
elif owner_id != interaction.user.id and interaction.user.id not in config()["owners"]:
409+
raise CommandError("You're not authorized to mess with this team. Sorry, boss.")
410+
elif not team.swap_player(player_name):
411+
raise CommandError("Either we can't find that player, you've got no space on the other side, or they're your last member of that side of the roster. Can't field an empty lineup, and we *do* have rules, chief.")
412+
else:
413+
await interaction.channel.send(embed=build_team_embed(team))
414+
games.update_team(team)
415+
await interaction.response.send_message("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
416+
384417
class MovePlayerCommand(Command):
385418
name = "moveplayer"
386419
template = """m;moveplayer
@@ -393,34 +426,38 @@ async def execute(self, msg, command, flags):
393426
try:
394427
team_name = command.split("\n")[1].strip()
395428
player_name = command.split("\n")[2].strip()
396-
team, owner_id = games.get_team_and_owner(team_name)
397-
try:
398-
new_pos = int(command.split("\n")[3].strip())
399-
except ValueError:
400-
raise CommandError("Hey, quit being cheeky. We're just trying to help. Third line has to be a natural number, boss.")
401-
if owner_id != msg.author.id and msg.author.id not in config()["owners"]:
402-
raise CommandError("You're not authorized to mess with this team. Sorry, boss.")
403-
else:
404-
if team.find_player(player_name)[2] is None or len(team.find_player(player_name)[2]) < new_pos:
405-
raise CommandError("You either gave us a number that was bigger than your current roster, or we couldn't find the player on the team. Try again.")
406-
407-
if "batter" in command.split("\n")[0].lower():
408-
roster = team.lineup
409-
elif "pitcher" in command.split("\n")[0].lower():
410-
roster = team.rotation
411-
else:
412-
roster = None
413-
414-
if (roster is not None and team.slide_player_spec(player_name, new_pos, roster)) or (roster is None and team.slide_player(player_name, new_pos)):
415-
await msg.channel.send(embed=build_team_embed(team))
416-
games.update_team(team)
417-
await msg.channel.send("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
418-
else:
419-
raise CommandError("You either gave us a number that was bigger than your current roster, or we couldn't find the player on the team. Try again.")
429+
420430

421431
except IndexError:
422432
raise CommandError("Four lines, remember? Command, then team, then name, and finally, new spot on the lineup or rotation.")
423433

434+
@client.tree.command()
435+
@app_commands.rename(team_name="team", player_name="player", is_pitcher="pitcher", new_pos="newposition")
436+
async def moveplayer(interaction, team_name: str, player_name: str, is_pitcher: bool, new_pos: int):
437+
team, owner_id = games.get_team_and_owner(team_name)
438+
if new_pos < 0:
439+
raise CommandError("Hey, quit being cheeky. We're just trying to help. New position has to be a natural number, boss.")
440+
elif owner_id != interaction.user.id and interaction.user.id not in config()["owners"]:
441+
raise CommandError("You're not authorized to mess with this team. Sorry, boss.")
442+
elif team is None:
443+
raise CommandError("We can't find that team, boss. Typo?")
444+
else:
445+
if team.find_player(player_name)[2] is None or len(team.find_player(player_name)[2]) < new_pos:
446+
raise CommandError("You either gave us a number that was bigger than your current roster, or we couldn't find the player on the team. Try again.")
447+
448+
if not is_pitcher:
449+
roster = team.lineup
450+
else:
451+
roster = team.rotation
452+
453+
if (roster is not None and team.slide_player_spec(player_name, new_pos, roster)) or (roster is None and team.slide_player(player_name, new_pos)):
454+
await msg.channel.send(embed=build_team_embed(team))
455+
games.update_team(team)
456+
await msg.channel.send("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
457+
else:
458+
raise CommandError("You either gave us a number that was bigger than your current roster, or we couldn't find the player on the team. Try again.")
459+
460+
424461
class AddPlayerCommand(Command):
425462
name = "addplayer"
426463
template = """m;addplayer pitcher (or m;addplayer batter)
@@ -1598,10 +1635,10 @@ async def execute(self, msg, command, flags):
15981635
await msg.channel.send(f"We've got {len(games.get_all_teams())} teams! Thanks for asking.")
15991636

16001637
commands = [
1601-
IntroduceCommand(),
1602-
CountActiveGamesCommand(),
1638+
IntroduceCommand(), #not needed
1639+
CountActiveGamesCommand(), #owner only
16031640
TeamsInfoCommand(),
1604-
AssignOwnerCommand(),
1641+
AssignOwnerCommand(), #owner only
16051642
ShowPlayerCommand(), #done
16061643
SaveTeamCommand(), #done
16071644
AssignArchetypeCommand(), #done
@@ -1615,7 +1652,7 @@ async def execute(self, msg, command, flags):
16151652
ReplacePlayerCommand(),
16161653
DeleteTeamCommand(),
16171654
ShowTeamCommand(), #done
1618-
SearchTeamsCommand(),
1655+
SearchTeamsCommand(), #not needed
16191656
StartGameCommand(), #done
16201657
StartRandomGameCommand(), #done
16211658
StartTournamentCommand(),
@@ -1642,8 +1679,8 @@ async def execute(self, msg, command, flags):
16421679
LeagueReplaceTeamCommand(),
16431680
LeagueRenameCommand(),
16441681
LeagueForceStopCommand(),
1645-
CreditCommand(),
1646-
RomanCommand(),
1682+
CreditCommand(), #done
1683+
RomanCommand(), #not needed
16471684
HelpCommand(),
16481685
StartDraftCommand(),
16491686
DraftFlagsCommand(),

0 commit comments

Comments
 (0)