This repository has been archived by the owner on Jun 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1db573
commit 786a119
Showing
5 changed files
with
113 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Couldn't think of a good name for the file but this just caches the gauntlets and map-packs. Bunched them up as they are REALLY similar. | ||
from conn.mysql import myconn | ||
from objects.levels import Gauntlet, MapPack | ||
from objects.misc import RGB | ||
import logging | ||
|
||
map_packs = [] | ||
gauntlets = [] | ||
|
||
async def cron_cache_mappacks(): | ||
"""Cron job that caches the map packs.""" | ||
map_packs.clear() | ||
# We get all of the map packs from the database. | ||
async with myconn.conn.cursor() as mycursor: | ||
await mycursor.execute("SELECT ID, name, levels, stars, coins, difficulty, rgbcolors FROM mappacks") # Shouldnt be too much I think. | ||
packs_db = await mycursor.fetchall() | ||
|
||
for pack in packs_db: | ||
# Create the necessary variables and maybe error handle. | ||
level_list = pack[2].split(",") | ||
colour_list = pack[6].split(",") | ||
try: | ||
colour = RGB(colour_list[0],colour_list[1],colour_list[2]) | ||
except IndexError: | ||
logging.warn(f"Map pack '{pack[2]}' has an invalid colour! Setting to white.") | ||
colour = RGB(255,255,255) | ||
map_packs.append(MapPack( | ||
pack[0], | ||
pack[1], | ||
level_list, | ||
pack[3], | ||
pack[4], | ||
pack[5], | ||
colour | ||
)) | ||
|
||
async def cron_cache_gauntlets(): | ||
"""Caches the in-game gauntlets.""" | ||
gauntlets.clear() | ||
# Getting all of the gauntlets from the database. | ||
async with myconn.conn.cursor() as mycursor: | ||
await mycursor.execute("SELECT ID, level1,level2,level3,level4,level5 FROM gauntlets") | ||
gauntlets_db = await mycursor.fetchall() | ||
|
||
for gauntlet in gauntlets_db: | ||
gauntlets.append(Gauntlet( | ||
gauntlet[0],gauntlet[1],gauntlet[2],gauntlet[3],gauntlet[4],gauntlet[5] | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters