Remove outdate image links
Add S3 image links Pull all fielding ratings at game start
This commit is contained in:
parent
a4adf50ca1
commit
65abc8ed55
@ -395,11 +395,18 @@ class Gameplay(commands.Cog):
|
||||
session.commit()
|
||||
|
||||
await final_message.edit(content=f'The {ai_team.sname} lineup is in, pulling in scouting data...')
|
||||
for batter in batter_lineups:
|
||||
await get_all_positions(
|
||||
for batter in batter_lineups:
|
||||
|
||||
pos_count = await get_all_positions(
|
||||
session=session,
|
||||
this_card=batter.card
|
||||
)
|
||||
if pos_count != 0:
|
||||
logger.info(f'logged position ratings for {batter.player.name_with_desc}')
|
||||
else:
|
||||
logger.warning(f'received no positions for {batter.player.name_with_desc}')
|
||||
if batter.position not in ['P', 'DH']:
|
||||
log_exception(PositionNotFoundException, f'{batter.player.name_with_desc} is listed at {batter.position} but no ratings were found.')
|
||||
|
||||
logger.info(f'Pulling team roles')
|
||||
away_role = await team_role(interaction, this_game.away_team)
|
||||
|
||||
4
dice.py
4
dice.py
@ -2729,8 +2729,8 @@ def sa_fielding_roll(this_team: Team, this_play: Play, pos_code: str, def_rating
|
||||
name='Help Commands',
|
||||
value=f'Run `!<result>` for full chart readout (e.g. `!g1` or `!do3`)'
|
||||
)
|
||||
reference_string = f'[Range Chart]({x_chart}) / [Error Chart]({error_chart}) / [Result Reference]({symbol_link})'
|
||||
chart_embed.add_field(name='References', value=reference_string, inline=False)
|
||||
# reference_string = f'[Range Chart]({x_chart}) / [Error Chart]({error_chart}) / [Result Reference]({symbol_link})'
|
||||
# chart_embed.add_field(name='References', value=reference_string, inline=False)
|
||||
|
||||
this_roll.embeds = [roll_embed, chart_embed]
|
||||
|
||||
|
||||
@ -1891,6 +1891,11 @@ async def post_result(run_id: int, is_win: bool, this_team: Team, bot, channel,
|
||||
team_id = None
|
||||
if x['reward']['pack_type']['id'] == 9:
|
||||
cardset_id = 21
|
||||
elif this_event['id'] == 8:
|
||||
cardset_id = 24
|
||||
team_id = None
|
||||
if x['reward']['pack_type']['id'] == 9:
|
||||
cardset_id = 25
|
||||
await db_post(
|
||||
'packs', payload={'packs': [{
|
||||
'team_id': main_team['id'],
|
||||
|
||||
86
helpers.py
86
helpers.py
@ -82,7 +82,7 @@ SBA_COLOR = 'a6ce39'
|
||||
PD_PLAYERS = 'Paper Dynasty Players'
|
||||
SBA_PLAYERS_ROLE_NAME = f'Season {SBA_SEASON} Players'
|
||||
PD_PLAYERS_ROLE_NAME = f'Paper Dynasty Players'
|
||||
PD_CARD_URL = 'https://sombaseball.ddns.net/cards/pd'
|
||||
PD_IMAGE_BUCKET = 'https://paper-dynasty.s3.us-east-1.amazonaws.com/static-images'
|
||||
PKMN_REF_URL = 'https://pkmncards.com/card/'
|
||||
RATINGS_BATTER_FORMULA = '=IMPORTRANGE("1zDmlOw94gTzOAjqOpNdDZsg0O6rxNWkL4-XT6-iL2IE","guide_Batters!A1:CD")'
|
||||
RATINGS_PITCHER_FORMULA = '=IMPORTRANGE("1zDmlOw94gTzOAjqOpNdDZsg0O6rxNWkL4-XT6-iL2IE","guide_Pitchers!A1:BQ")'
|
||||
@ -120,50 +120,50 @@ ALL_MLB_TEAMS = {
|
||||
'Washington Nationals': ['WSN', 'WAS', 'Nationals'],
|
||||
}
|
||||
IMAGES = {
|
||||
'logo': 'https://sombaseball.ddns.net/static/images/sba-logo.png',
|
||||
'mvp-hype': f'{PD_CARD_URL}/mvp.png',
|
||||
'pack-sta': f'{PD_CARD_URL}/pack-standard.png',
|
||||
'pack-pre': f'{PD_CARD_URL}/pack-premium.png',
|
||||
'pack-mar': f'{PD_CARD_URL}/sluggers/mario-gauntlet.png',
|
||||
'pack-pkmnbs': f'https://i.postimg.cc/635M4X52/pokemon-brilliantstars.jpg',
|
||||
'logo': f'{PD_IMAGE_BUCKET}/sba-logo.png',
|
||||
'mvp-hype': f'{PD_IMAGE_BUCKET}/mvp.png',
|
||||
'pack-sta': f'{PD_IMAGE_BUCKET}/pack-standard.png',
|
||||
'pack-pre': f'{PD_IMAGE_BUCKET}/pack-premium.png',
|
||||
'pack-mar': f'{PD_IMAGE_BUCKET}/mario-gauntlet.png',
|
||||
'pack-pkmnbs': f'{PD_IMAGE_BUCKET}/pokemon-brilliantstars.jpg',
|
||||
'mvp': {
|
||||
'Arizona Diamondbacks': f'{PD_CARD_URL}/mvp/arizona-diamondbacks.gif',
|
||||
'Atlanta Braves': f'{PD_CARD_URL}/mvp/atlanta-braves.gif',
|
||||
'Baltimore Orioles': f'{PD_CARD_URL}/mvp/baltimore-orioles.gif',
|
||||
'Boston Red Sox': f'{PD_CARD_URL}/mvp/boston-red-sox.gif',
|
||||
'Chicago Cubs': f'{PD_CARD_URL}/mvp/chicago-cubs.gif',
|
||||
'Chicago White Sox': f'{PD_CARD_URL}/mvp/chicago-white-sox.gif',
|
||||
'Cincinnati Reds': f'{PD_CARD_URL}/mvp/cincinnati-reds.gif',
|
||||
'Cleveland Indians': f'{PD_CARD_URL}/mvp/cleveland-guardians.gif',
|
||||
'Cleveland Guardians': f'{PD_CARD_URL}/mvp/cleveland-guardians.gif',
|
||||
'Colorado Rockies': f'{PD_CARD_URL}/mvp/colorado-rockies.gif',
|
||||
'Detroit Tigers': f'{PD_CARD_URL}/mvp/detroit-tigers.gif',
|
||||
'Houston Astros': f'{PD_CARD_URL}/mvp/houston-astros.gif',
|
||||
'Kansas City Royals': f'{PD_CARD_URL}/mvp/kansas-city-royals.gif',
|
||||
'Los Angeles Angels': f'{PD_CARD_URL}/mvp/los-angeles-angels.gif',
|
||||
'Los Angeles Dodgers': f'{PD_CARD_URL}/mvp/los-angeles-dodgers.gif',
|
||||
'Miami Marlins': f'{PD_CARD_URL}/mvp/miami-marlins.gif',
|
||||
'Milwaukee Brewers': f'{PD_CARD_URL}/mvp/milwaukee-brewers.gif',
|
||||
'Minnesota Twins': f'{PD_CARD_URL}/mvp/minnesota-twins.gif',
|
||||
'New York Mets': f'{PD_CARD_URL}/mvp/new-york-mets.gif',
|
||||
'New York Yankees': f'{PD_CARD_URL}/mvp/new-york-yankees.gif',
|
||||
'Oakland Athletics': f'{PD_CARD_URL}/mvp/oakland-athletics.gif',
|
||||
'Philadelphia Phillies': f'{PD_CARD_URL}/mvp/philadelphia-phillies.gif',
|
||||
'Pittsburgh Pirates': f'{PD_CARD_URL}/mvp/pittsburgh-pirates.gif',
|
||||
'San Diego Padres': f'{PD_CARD_URL}/mvp/san-diego-padres.gif',
|
||||
'Seattle Mariners': f'{PD_CARD_URL}/mvp/seattle-mariners.gif',
|
||||
'San Francisco Giants': f'{PD_CARD_URL}/mvp/san-francisco-giants.gif',
|
||||
'St Louis Cardinals': f'{PD_CARD_URL}/mvp/st-louis-cardinals.gif',
|
||||
'St. Louis Cardinals': f'{PD_CARD_URL}/mvp/st-louis-cardinals.gif',
|
||||
'Tampa Bay Rays': f'{PD_CARD_URL}/mvp/tampa-bay-rays.gif',
|
||||
'Texas Rangers': f'{PD_CARD_URL}/mvp/texas-rangers.gif',
|
||||
'Toronto Blue Jays': f'{PD_CARD_URL}/mvp/toronto-blue-jays.gif',
|
||||
'Washington Nationals': f'{PD_CARD_URL}/mvp/washington-nationals.gif',
|
||||
'Junior All Stars': f'{PD_CARD_URL}/mvp.png',
|
||||
'Mario Super Sluggers': f'{PD_CARD_URL}/mvp.png',
|
||||
'Pokemon League': 'https://i.postimg.cc/ydzYB7BR/masterball.jpg'
|
||||
'Arizona Diamondbacks': f'{PD_IMAGE_BUCKET}/mvp/arizona-diamondbacks.gif',
|
||||
'Atlanta Braves': f'{PD_IMAGE_BUCKET}/mvp/atlanta-braves.gif',
|
||||
'Baltimore Orioles': f'{PD_IMAGE_BUCKET}/mvp/baltimore-orioles.gif',
|
||||
'Boston Red Sox': f'{PD_IMAGE_BUCKET}/mvp/boston-red-sox.gif',
|
||||
'Chicago Cubs': f'{PD_IMAGE_BUCKET}/mvp/chicago-cubs.gif',
|
||||
'Chicago White Sox': f'{PD_IMAGE_BUCKET}/mvp/chicago-white-sox.gif',
|
||||
'Cincinnati Reds': f'{PD_IMAGE_BUCKET}/mvp/cincinnati-reds.gif',
|
||||
'Cleveland Indians': f'{PD_IMAGE_BUCKET}/mvp/cleveland-guardians.gif',
|
||||
'Cleveland Guardians': f'{PD_IMAGE_BUCKET}/mvp/cleveland-guardians.gif',
|
||||
'Colorado Rockies': f'{PD_IMAGE_BUCKET}/mvp/colorado-rockies.gif',
|
||||
'Detroit Tigers': f'{PD_IMAGE_BUCKET}/mvp/detroit-tigers.gif',
|
||||
'Houston Astros': f'{PD_IMAGE_BUCKET}/mvp/houston-astros.gif',
|
||||
'Kansas City Royals': f'{PD_IMAGE_BUCKET}/mvp/kansas-city-royals.gif',
|
||||
'Los Angeles Angels': f'{PD_IMAGE_BUCKET}/mvp/los-angeles-angels.gif',
|
||||
'Los Angeles Dodgers': f'{PD_IMAGE_BUCKET}/mvp/los-angeles-dodgers.gif',
|
||||
'Miami Marlins': f'{PD_IMAGE_BUCKET}/mvp/miami-marlins.gif',
|
||||
'Milwaukee Brewers': f'{PD_IMAGE_BUCKET}/mvp/milwaukee-brewers.gif',
|
||||
'Minnesota Twins': f'{PD_IMAGE_BUCKET}/mvp/minnesota-twins.gif',
|
||||
'New York Mets': f'{PD_IMAGE_BUCKET}/mvp/new-york-mets.gif',
|
||||
'New York Yankees': f'{PD_IMAGE_BUCKET}/mvp/new-york-yankees.gif',
|
||||
'Oakland Athletics': f'{PD_IMAGE_BUCKET}/mvp/oakland-athletics.gif',
|
||||
'Philadelphia Phillies': f'{PD_IMAGE_BUCKET}/mvp/philadelphia-phillies.gif',
|
||||
'Pittsburgh Pirates': f'{PD_IMAGE_BUCKET}/mvp/pittsburgh-pirates.gif',
|
||||
'San Diego Padres': f'{PD_IMAGE_BUCKET}/mvp/san-diego-padres.gif',
|
||||
'Seattle Mariners': f'{PD_IMAGE_BUCKET}/mvp/seattle-mariners.gif',
|
||||
'San Francisco Giants': f'{PD_IMAGE_BUCKET}/mvp/san-francisco-giants.gif',
|
||||
'St Louis Cardinals': f'{PD_IMAGE_BUCKET}/mvp/st-louis-cardinals.gif',
|
||||
'St. Louis Cardinals': f'{PD_IMAGE_BUCKET}/mvp/st-louis-cardinals.gif',
|
||||
'Tampa Bay Rays': f'{PD_IMAGE_BUCKET}/mvp/tampa-bay-rays.gif',
|
||||
'Texas Rangers': f'{PD_IMAGE_BUCKET}/mvp/texas-rangers.gif',
|
||||
'Toronto Blue Jays': f'{PD_IMAGE_BUCKET}/mvp/toronto-blue-jays.gif',
|
||||
'Washington Nationals': f'{PD_IMAGE_BUCKET}/mvp/washington-nationals.gif',
|
||||
'Junior All Stars': f'{PD_IMAGE_BUCKET}/mvp.png',
|
||||
'Mario Super Sluggers': f'{PD_IMAGE_BUCKET}/mvp.png',
|
||||
'Pokemon League': f'{PD_IMAGE_BUCKET}/masterball.jpg'
|
||||
},
|
||||
'gauntlets': f'{PD_CARD_URL}/gauntlets.png'
|
||||
'gauntlets': f'{PD_IMAGE_BUCKET}/gauntlets.png'
|
||||
}
|
||||
INFIELD_X_CHART = {
|
||||
'si1': {
|
||||
|
||||
@ -23,7 +23,7 @@ postgres_url = f'postgresql://{os.getenv('DB_USERNAME')}:{os.getenv('DB_PASSWORD
|
||||
engine = create_engine(postgres_url, pool_size=10, max_overflow=30)
|
||||
CACHE_LIMIT = 259200 # 1209600 # in seconds
|
||||
SBA_COLOR = 'a6ce39'
|
||||
SBA_LOGO = 'https://sombaseball.ddns.net/static/images/sba-logo.png'
|
||||
SBA_LOGO = 'https://paper-dynasty.s3.us-east-1.amazonaws.com/static-images/sba-logo.png'
|
||||
|
||||
|
||||
class ManagerAiBase(SQLModel):
|
||||
@ -581,11 +581,13 @@ class ManagerAi(ManagerAiBase, table=True):
|
||||
return this_resp
|
||||
|
||||
def defense_alignment(self, session: Session, this_game: Game) -> DefenseResponse:
|
||||
logger.info(f'checking defensive alignment in game {this_game.id}')
|
||||
this_resp = DefenseResponse()
|
||||
this_play = this_game.current_play_or_none(session)
|
||||
if this_play is None:
|
||||
raise GameException(f'No game found while checking uncapped_advance_lead')
|
||||
raise GameException(f'No game found while checking defense_alignment')
|
||||
|
||||
logger.info(f'defense_alignment - this_play: {this_play}')
|
||||
ai_rd = this_play.ai_run_diff
|
||||
aggression = self.ahead_aggression - 5 if ai_rd > 0 else self.behind_aggression - 5
|
||||
pitcher_hold = this_play.pitcher.card.pitcherscouting.pitchingcard.hold
|
||||
|
||||
@ -10,3 +10,4 @@ pytest
|
||||
pytest-asyncio
|
||||
pandas
|
||||
psycopg2-binary
|
||||
# psycopg[binary]
|
||||
|
||||
99
utilities/supabase.py
Normal file
99
utilities/supabase.py
Normal file
@ -0,0 +1,99 @@
|
||||
import datetime
|
||||
import psycopg as pg
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List, Optional
|
||||
|
||||
# Load environment variables from .env
|
||||
load_dotenv()
|
||||
|
||||
# Fetch variables
|
||||
USER = os.getenv("user")
|
||||
PASSWORD = os.getenv("password")
|
||||
HOST = os.getenv("host")
|
||||
PORT = os.getenv("port")
|
||||
DBNAME = os.getenv("database")
|
||||
POOLMODE = os.getenv("pool_mode")
|
||||
|
||||
def get_connection():
|
||||
# Connect to the database
|
||||
try:
|
||||
connection = pg.connect(
|
||||
user=USER,
|
||||
password=PASSWORD,
|
||||
host=HOST,
|
||||
port=PORT,
|
||||
dbname=DBNAME,
|
||||
# pool_mode=POOLMODE
|
||||
)
|
||||
print("Connection successful!")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Failed to connect: {e}")
|
||||
|
||||
return connection
|
||||
|
||||
|
||||
def map_rows(model: type[BaseModel], cursor) -> list[BaseModel]:
|
||||
columns = [desc[0] for desc in cursor.description]
|
||||
return [model.model_validate(dict(zip(columns, row))) for row in cursor.fetchall()]
|
||||
|
||||
|
||||
class Player(BaseModel):
|
||||
id: Optional[int] = None # bigint, identity, primary key
|
||||
created_at: Optional[datetime.datetime] = Field(default_factory=datetime.datetime.now) # optional, defaults to now
|
||||
name: Optional[str] = None # text, not null
|
||||
cost: Optional[int] = None # smallint, not null
|
||||
image: Optional[str] = None # text, not null
|
||||
image2: Optional[str] = None # text, nullable
|
||||
cardset_id: Optional[int] = None # bigint, not null, foreign key
|
||||
set_num: Optional[int] = None # integer, nullable
|
||||
headshot: Optional[str] = None # text, nullable
|
||||
vanity_card: Optional[str] = None # text, nullable
|
||||
strat_code: Optional[str] = None # text, nullable
|
||||
bbref_id: Optional[str] = None # text, nullable
|
||||
fangr_id: Optional[str] = None # text, nullable
|
||||
description: Optional[str] = None # text, not null
|
||||
quantity: Optional[int] = Field(default=999) # smallint, not null, default 999
|
||||
franchise: Optional[str] = None # enum or text? Adjust if you have a Franchise model or enum
|
||||
mlbclub: Optional[str] = None # enum or text? Same as above
|
||||
positions: Optional[List[str]] = Field(default_factory=lambda: ['DH']) # text[], nullable, default '{DH}'
|
||||
rarity_id: Optional[int] = None # bigint, not null, foreign key
|
||||
mlbplayer_id: Optional[int] = None # bigint, nullable, foreign key
|
||||
|
||||
|
||||
def main():
|
||||
connection = get_connection()
|
||||
|
||||
# Create a cursor to execute SQL queries
|
||||
cursor = connection.cursor()
|
||||
|
||||
# Example query
|
||||
# cursor.execute("SELECT NOW();")
|
||||
# result = cursor.fetchone()
|
||||
# print("Current Time:", result)
|
||||
|
||||
cursor.execute(
|
||||
'''
|
||||
SELECT id, name, cost, image, headshot
|
||||
FROM players
|
||||
WHERE cost > 950 and cost < 1000
|
||||
'''
|
||||
)
|
||||
|
||||
# Not working, yet. query is missing fields that were previously required
|
||||
players = map_rows(Player, cursor)
|
||||
|
||||
# Close the cursor and connection
|
||||
cursor.close()
|
||||
connection.close()
|
||||
print("Connection closed.")
|
||||
|
||||
for row in players:
|
||||
print(row)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in New Issue
Block a user