Merge remote-tracking branch 'upstream/indev' into indev
This commit is contained in:
commit
f91de92ed2
8
games.py
8
games.py
|
@ -108,6 +108,14 @@ class team(object):
|
|||
else:
|
||||
return (None, None, None)
|
||||
|
||||
def average_stars(self):
|
||||
total_stars = 0
|
||||
for _player in self.lineup:
|
||||
total_stars += _player.stlats["batting_stars"]
|
||||
for _player in self.rotation:
|
||||
total_stars += _player.stlats["pitching_stars"]
|
||||
return total_stars/(len(self.lineup) + len(self.rotation))
|
||||
|
||||
def swap_player(self, name):
|
||||
this_player, index, roster = self.find_player(name)
|
||||
if this_player is not None and len(roster) > 1:
|
||||
|
|
19
leagues.py
19
leagues.py
|
@ -1,19 +0,0 @@
|
|||
import time, asyncio, jsonpickle
|
||||
import database as db
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class league(object):
|
||||
def __init__(self, name, subleagues_dic):
|
||||
self.subleagues = {} #key: name, value: [divisions]
|
||||
self.max_days
|
||||
self.day = 1
|
||||
self.name = name
|
||||
self.subleagues = subleagues_dic
|
||||
|
||||
class division(object):
|
||||
def __init__(self):
|
||||
self.teams = {} #key: team name, value: {wins; losses; run diff}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import asyncio, time, datetime, games, json, threading, jinja2, leagues
|
||||
import asyncio, time, datetime, games, json, threading, jinja2
|
||||
from flask import Flask, url_for, Response, render_template, request, jsonify
|
||||
from flask_socketio import SocketIO, emit
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@import url('https://fonts.googleapis.com/css2?family=Alegreya&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Goldman:wght@700&display=swap');
|
||||
body {
|
||||
background-image: url("prism.png");
|
||||
background-image: url("naturalblack.png");
|
||||
}
|
||||
/* Background pattern from Toptal Subtle Patterns */
|
||||
|
||||
|
|
BIN
static/css/naturalblack.png
Normal file
BIN
static/css/naturalblack.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 256 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB |
|
@ -29,9 +29,6 @@
|
|||
<Compile Include="debug storage.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="leagues.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="main_controller.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
@ -60,16 +57,28 @@
|
|||
<Content Include="games_config.json" />
|
||||
<Content Include="ids" />
|
||||
<Content Include="matteo.db" />
|
||||
<Content Include="static\css\common.css" />
|
||||
<Content Include="static\css\game.css" />
|
||||
<Content Include="static\css\games_page.css" />
|
||||
<Content Include="static\css\game_page.css" />
|
||||
<Content Include="static\css\prism.png" />
|
||||
<Content Include="static\discord.png" />
|
||||
<Content Include="static\game.html" />
|
||||
<Content Include="static\games_page.css" />
|
||||
<Content Include="static\loader.js" />
|
||||
<Content Include="static\prism.png" />
|
||||
<Content Include="static\img\base_empty.png" />
|
||||
<Content Include="static\img\base_filled.png" />
|
||||
<Content Include="static\img\out_in.png" />
|
||||
<Content Include="static\img\out_out.png" />
|
||||
<Content Include="static\js\game_loader.js" />
|
||||
<Content Include="static\js\grid_loader.js" />
|
||||
<Content Include="templates\base.html" />
|
||||
<Content Include="templates\game.html" />
|
||||
<Content Include="templates\game_box.html" />
|
||||
<Content Include="templates\index.html" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="static\" />
|
||||
<Folder Include="static\css\" />
|
||||
<Folder Include="static\img\" />
|
||||
<Folder Include="static\js\" />
|
||||
<Folder Include="templates\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||
|
|
144
the_prestige.py
144
the_prestige.py
|
@ -1,4 +1,4 @@
|
|||
import discord, json, math, os, roman, games, asyncio, random, main_controller, threading, time, leagues, urllib
|
||||
import discord, json, math, os, roman, games, asyncio, random, main_controller, threading, time, urllib
|
||||
import database as db
|
||||
import onomancer as ono
|
||||
from flask import Flask
|
||||
|
@ -302,22 +302,25 @@ class SwapPlayerCommand(Command):
|
|||
description = "Swaps a player from lineup to rotation, or from rotation to lineup. Requires team ownership."
|
||||
|
||||
async def execute(self, msg, command):
|
||||
team_name = command.split("\n")[1].strip()
|
||||
player_name = command.split("\n")[2].strip()
|
||||
team, owner_id = games.get_team_and_owner(team_name)
|
||||
if team is None:
|
||||
await msg.channel.send("Can't find that team, boss. Typo?")
|
||||
return
|
||||
elif owner_id != msg.author.id and msg.author.id not in config()["owners"]:
|
||||
await msg.channel.send("You're not authorized to mess with this team. Sorry, boss.")
|
||||
return
|
||||
elif not team.swap_player(player_name):
|
||||
await msg.channel.send("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.")
|
||||
return
|
||||
else:
|
||||
await msg.channel.send(embed=build_team_embed(team))
|
||||
games.update_team(team)
|
||||
await msg.channel.send("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
|
||||
try:
|
||||
team_name = command.split("\n")[1].strip()
|
||||
player_name = command.split("\n")[2].strip()
|
||||
team, owner_id = games.get_team_and_owner(team_name)
|
||||
if team is None:
|
||||
await msg.channel.send("Can't find that team, boss. Typo?")
|
||||
return
|
||||
elif owner_id != msg.author.id and msg.author.id not in config()["owners"]:
|
||||
await msg.channel.send("You're not authorized to mess with this team. Sorry, boss.")
|
||||
return
|
||||
elif not team.swap_player(player_name):
|
||||
await msg.channel.send("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.")
|
||||
return
|
||||
else:
|
||||
await msg.channel.send(embed=build_team_embed(team))
|
||||
games.update_team(team)
|
||||
await msg.channel.send("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
|
||||
except IndexError:
|
||||
await msg.channel.send("Three lines, remember? Command, then team, then name.")
|
||||
|
||||
class MovePlayerCommand(Command):
|
||||
name = "move"
|
||||
|
@ -328,24 +331,27 @@ class MovePlayerCommand(Command):
|
|||
description = "Moves a player in your lineup or rotation. Requires team ownership."
|
||||
|
||||
async def execute(self, msg, command):
|
||||
team_name = command.split("\n")[1].strip()
|
||||
player_name = command.split("\n")[2].strip()
|
||||
team, owner_id = games.get_team_and_owner(team_name)
|
||||
try:
|
||||
new_pos = int(command.split("\n")[3].strip())
|
||||
except ValueError:
|
||||
await msg.channel.send("Hey, quit being cheeky. We're just trying to help. Third line has to be a natural number, boss.")
|
||||
return
|
||||
if owner_id != msg.author.id and msg.author.id not in config()["owners"]:
|
||||
await msg.channel.send("You're not authorized to mess with this team. Sorry, boss.")
|
||||
return
|
||||
elif not team.slide_player(player_name, new_pos):
|
||||
await msg.channel.send("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.")
|
||||
return
|
||||
else:
|
||||
await msg.channel.send(embed=build_team_embed(team))
|
||||
games.update_team(team)
|
||||
await msg.channel.send("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
|
||||
team_name = command.split("\n")[1].strip()
|
||||
player_name = command.split("\n")[2].strip()
|
||||
team, owner_id = games.get_team_and_owner(team_name)
|
||||
try:
|
||||
new_pos = int(command.split("\n")[3].strip())
|
||||
except ValueError:
|
||||
await msg.channel.send("Hey, quit being cheeky. We're just trying to help. Third line has to be a natural number, boss.")
|
||||
return
|
||||
if owner_id != msg.author.id and msg.author.id not in config()["owners"]:
|
||||
await msg.channel.send("You're not authorized to mess with this team. Sorry, boss.")
|
||||
return
|
||||
elif not team.slide_player(player_name, new_pos):
|
||||
await msg.channel.send("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.")
|
||||
return
|
||||
else:
|
||||
await msg.channel.send(embed=build_team_embed(team))
|
||||
games.update_team(team)
|
||||
await msg.channel.send("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
|
||||
except IndexError:
|
||||
await msg.channel.send("Four lines, remember? Command, then team, then name, and finally, new spot on the lineup or rotation.")
|
||||
|
||||
class AddPlayerCommand(Command):
|
||||
name = "addplayer"
|
||||
|
@ -355,27 +361,30 @@ class AddPlayerCommand(Command):
|
|||
description = "Recruits a new player to your team, as either a pitcher or a batter. Requires team ownership."
|
||||
|
||||
async def execute(self, msg, command):
|
||||
team_name = command.split("\n")[1].strip()
|
||||
player_name = command.split("\n")[2].strip()
|
||||
team, owner_id = games.get_team_and_owner(team_name)
|
||||
if owner_id != msg.author.id and msg.author.id not in config()["owners"]:
|
||||
await msg.channel.send("You're not authorized to mess with this team. Sorry, boss.")
|
||||
return
|
||||
|
||||
new_player = games.player(ono.get_stats(player_name))
|
||||
|
||||
if "batter" in command.split("\n")[0]:
|
||||
if not team.add_lineup(new_player)[0]:
|
||||
await msg.channel.send("Too many batters 🎶")
|
||||
return
|
||||
elif "pitcher" in command.split("\n")[0]:
|
||||
if not team.add_pitcher(new_player):
|
||||
await msg.channel.send("8 pitchers is quite enough, we think.")
|
||||
try:
|
||||
team_name = command.split("\n")[1].strip()
|
||||
player_name = command.split("\n")[2].strip()
|
||||
team, owner_id = games.get_team_and_owner(team_name)
|
||||
if owner_id != msg.author.id and msg.author.id not in config()["owners"]:
|
||||
await msg.channel.send("You're not authorized to mess with this team. Sorry, boss.")
|
||||
return
|
||||
|
||||
await msg.channel.send(embed=build_team_embed(team))
|
||||
games.update_team(team)
|
||||
await msg.channel.send("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
|
||||
new_player = games.player(ono.get_stats(player_name))
|
||||
|
||||
if "batter" in command.split("\n")[0]:
|
||||
if not team.add_lineup(new_player)[0]:
|
||||
await msg.channel.send("Too many batters 🎶")
|
||||
return
|
||||
elif "pitcher" in command.split("\n")[0]:
|
||||
if not team.add_pitcher(new_player):
|
||||
await msg.channel.send("8 pitchers is quite enough, we think.")
|
||||
return
|
||||
|
||||
await msg.channel.send(embed=build_team_embed(team))
|
||||
games.update_team(team)
|
||||
await msg.channel.send("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
|
||||
except IndexError:
|
||||
await msg.channel.send("Three lines, remember? Command, then team, then name.")
|
||||
|
||||
class DeletePlayerCommand(Command):
|
||||
name = "removeplayer"
|
||||
|
@ -384,21 +393,24 @@ class DeletePlayerCommand(Command):
|
|||
[player name]"""
|
||||
|
||||
async def execute(self, msg, command):
|
||||
team_name = command.split("\n")[1].strip()
|
||||
player_name = command.split("\n")[2].strip()
|
||||
team, owner_id = games.get_team_and_owner(team_name)
|
||||
if owner_id != msg.author.id and msg.author.id not in config()["owners"]:
|
||||
await msg.channel.send("You're not authorized to mess with this team. Sorry, boss.")
|
||||
return
|
||||
try:
|
||||
team_name = command.split("\n")[1].strip()
|
||||
player_name = command.split("\n")[2].strip()
|
||||
team, owner_id = games.get_team_and_owner(team_name)
|
||||
if owner_id != msg.author.id and msg.author.id not in config()["owners"]:
|
||||
await msg.channel.send("You're not authorized to mess with this team. Sorry, boss.")
|
||||
return
|
||||
|
||||
if not team.delete_player(player_name):
|
||||
await msg.channel.send("We've got bad news: that player isn't on your team. The good news is that... that player isn't on your team?")
|
||||
return
|
||||
if not team.delete_player(player_name):
|
||||
await msg.channel.send("We've got bad news: that player isn't on your team. The good news is that... that player isn't on your team?")
|
||||
return
|
||||
|
||||
else:
|
||||
await msg.channel.send(embed=build_team_embed(team))
|
||||
games.update_team(team)
|
||||
await msg.channel.send("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
|
||||
else:
|
||||
await msg.channel.send(embed=build_team_embed(team))
|
||||
games.update_team(team)
|
||||
await msg.channel.send("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
|
||||
except IndexError:
|
||||
await msg.channel.send("Three lines, remember? Command, then team, then name.")
|
||||
|
||||
|
||||
class HelpCommand(Command):
|
||||
|
|
Loading…
Reference in New Issue
Block a user