Skip to content

Commit

Permalink
Add function to repeatly recreate character jsons
Browse files Browse the repository at this point in the history
  • Loading branch information
TLNBS2405 committed Nov 27, 2023
1 parent 27d61b2 commit d89d16c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/json_movelist/azucena.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
"id": "Azucena-3,2",
"input": "3,2",
"name": "Groovy Strike",
"notes": "\n* \nBalcony break\n* Combo from 1st hit with 5f delay\n* Input can be delayed 10f delay}",
"notes": "\n* \nBalcony break\n* Combo from 1st hit with 5f delay\n* Input can be delayed 10f delay",
"on_block": "-12~-11",
"on_ch": "+33d (+25)",
"on_hit": "+6~+7",
Expand Down Expand Up @@ -495,7 +495,7 @@
"id": "Azucena-Back throw",
"input": "Back throw",
"name": "Caffeine Abduction",
"notes": "\n* Throw break 2",
"notes": "",
"on_block": "",
"on_ch": "",
"on_hit": "+0d",
Expand Down Expand Up @@ -767,7 +767,7 @@
"on_hit": "+0d",
"recovery": "r28",
"startup": "i12~13",
"target": "t"
"target": "mt"
},
{
"damage": "15",
Expand Down Expand Up @@ -1545,7 +1545,7 @@
"id": "Azucena-H.b+2,F",
"input": "H.b+2,F",
"name": "Mil Nudillo > Nuevo Libertador",
"notes": "\n*Chip damage on block",
"notes": "Chip damage on block",
"on_block": "+7",
"on_ch": "",
"on_hit": "+54a (+34)",
Expand Down Expand Up @@ -2133,7 +2133,7 @@
"id": "Azucena-uf+1+2",
"input": "uf+1+2",
"name": "Inti Raymi Necklace",
"notes": "\n* Throw break 1+2\n* Side switch",
"notes": "\n* Throw break 1+2\n* Can side switch on hit",
"on_block": "+0",
"on_ch": "",
"on_hit": "-3d",
Expand Down
15 changes: 12 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import json, datetime, logging, os, discord
import json, datetime, logging, os, discord, sched, time

from src.module import character_importer
from src.module import configurator
from src.module import json_movelist_reader
from threading import Thread


logger = logging.getLogger(__name__)
logger.setLevel(logging.WARNING)

base_path = os.path.dirname(__file__)
config = configurator.Configurator(os.path.abspath(os.path.join(base_path, "resources", "config.json")))

character_list_path = "resources/character_list.json"
discord_token = config.read_config()['DISCORD_TOKEN']


Expand Down Expand Up @@ -43,19 +45,26 @@ async def self(interaction: discord.Interaction, character_name: str, move: str)
await interaction.response.send_message(content=result, ephemeral=False)


def create_all_character_json(character_list_path: str):
def create_all_character_json(character_list_path: str, scheduler):
try:
with open(character_list_path) as file:
characters = json.load(file)

for character_meta in characters:
character = character_importer.import_character(character_meta)
character.export_movelist_as_json()
scheduler.enter(3600,1,create_all_character_json, (character_list_path,scheduler,))

except Exception as e:
raise Exception("Error when importing character from wavu" + str(e))


try:
## Repeat creating character json once an hour
scheduler = sched.scheduler(time.time, time.sleep)
scheduler.enter(3600,1,create_all_character_json, (character_list_path,scheduler,))
Thread(target=scheduler.run).start()

client.run(discord_token)

except Exception as e:
Expand Down

0 comments on commit d89d16c

Please sign in to comment.