Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Rush Duel search #40

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/bastion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dotenv import load_dotenv

from clients import get_api_client
from limit_regulation import master_duel_limit_regulation
from limit_regulation import master_duel_limit_regulation, rush_duel_limit_regulation
from mention import MentionsThread
from stream import CommentsThread, SubmissionsThread

Expand All @@ -15,11 +15,14 @@ def main():
load_dotenv()
api_client = get_api_client()
master_duel_limit_regulation.set_client(api_client)
rush_duel_limit_regulation.set_client(api_client)
submissions_thread = SubmissionsThread(api_client)
comments_thread = CommentsThread(api_client)
mentions_thread = MentionsThread(api_client)
master_duel_limit_regulation.update(True)
master_duel_limit_regulation.start()
rush_duel_limit_regulation.update(True)
rush_duel_limit_regulation.start()
submissions_thread.start()
comments_thread.start()
mentions_thread.start()
Expand Down
66 changes: 66 additions & 0 deletions src/rush_duel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from typing import Any

from card import format_card_text
from limit_regulation import rush_duel_limit_regulation


def generate_rush_card_display(card: Any) -> str:
yugipedia = (

Check failure on line 8 in src/rush_duel.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

src/rush_duel.py:8:5: F841 Local variable `yugipedia` is assigned to but never used
f"https://yugipedia.com/wiki/{card["konami_id"]}?utm_source=bastion&utm_medium=reddit"
if card["konami_id"]
else f"https://yugipedia.com/wiki/?curid={card["yugipedia_page_id"]}&utm_source=bastion&utm_medium=reddit"
)
rushcard = f"https://rushcard.io/card/?search={card["yugipedia_page_id"]}&utm_source=bastion&utm_medium=reddit"

full_text = f"## [{card['name']['en']}]({rushcard})\n"

# Links

description = ""
if card.get("legend"):
description += "__**LEGEND**__\n"
elif card["konami_id"]:
limit_regulation_display = (
rush_duel_limit_regulation.get(card["konami_id"]) or 3
)
description += f"^(**Limit**: {limit_regulation_display}) \n"

if card["card_type"] == "Monster":
description += f"^(**Type**: {card['monster_type_line']}) \n"
description += f"^(**Attribute**: {card['attribute']}) \n"
description += f"^(**Level**: {card['level']} **ATK**: {card['atk']} **DEF**: {card['def']}) \n"
if "maximum_atk" in card:
description += f"^(**MAXIMUM ATK**: {card['maximum_atk']}) \n"
if card.get("summoning_condition"):
description += f"\n{format_card_text(card["summoning_condition"]["en"])}"
if "materials" in card:
description += f"\n{format_card_text(card["materials"]["en"])}"
if "Fusion" in card["monster_type_line"] and "text" in card:
# This is effectively the localised materials line for non-Effect Fusion monsters
description += f"\n{format_card_text(card["text"]["en"])}"

full_text += f"{description}\n\n"

if "requirement" in card:
full_text += f"**[REQUIREMENT]**\n\n{format_card_text(card['requirement']['en'])}\n\n"
effect_type = "EFFECT"
if "Continuous" in card.get("effect_types", ""):
effect_type = "CONTINUOUS EFFECT"
elif "Multi-Choice" in card.get("effect_types", ""):
effect_type = "MULTI-CHOICE EFFECT"
full_text += (
f"**[{effect_type}]**\n\n{format_card_text(card['effect']['en'])}\n\n"
)
elif "text" in card and "Fusion" not in card["monster_type_line"]:
full_text += f"**Card Text**\n\n{format_card_text(card['text']['en'])}"
else:
# Spells and Traps
description += "\n\n"
description += f"{card['property']} {card['card_type']}"
full_text += f"{description}\n\n"
full_text += f"**[REQUIREMENT]**\n\n{format_card_text(card['requirement']['en'])}\n\n"
full_text += f"**[EFFECT]**\n\n{format_card_text(card['effect']['en'])}\n\n"

# Add Links
full_text += f"Konami ID #{card['konami_id']}" if card["konami_id"] else "Not yet released"
return full_text
Loading