Skip to content

Commit

Permalink
Merge pull request #15 from AbhijeetKrishnan/master
Browse files Browse the repository at this point in the history
Fix issue with move queries with `*` in the input not being handled correctly
  • Loading branch information
TLNBS2405 authored Jul 18, 2024
2 parents 4d6c124 + d2cbaee commit 4dc1598
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 47 deletions.
69 changes: 37 additions & 32 deletions src/frame_service/wavu/static/character_list.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
[
{
"name": "alisa",
"portrait": "https://wavu.wiki/w/images/d/dd/AlisaT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/AlisaT8.png",
"page": "https://wavu.wiki/t/Alisa"
},
{
"name": "asuka",
"portrait": "https://wavu.wiki/w/images/c/cb/AsukaT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/AsukaT8.png",
"page": "https://wavu.wiki/t/Asuka"
},
{
"name": "azucena",
"portrait": "https://wavu.wiki/w/images/6/65/AzucenaT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/AzucenaT8.png",
"page": "https://wavu.wiki/t/Azucena"
},
{
"name": "bryan",
"portrait": "https://wavu.wiki/w/images/3/32/BryanT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/BryanT8.png",
"page": "https://wavu.wiki/t/Bryan"
},
{
"name": "claudio",
"portrait": "https://wavu.wiki/w/images/c/c1/ClaudioT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/ClaudioT8.png",
"page": "https://wavu.wiki/t/Claudio"
},
{
"name": "devil_jin",
"portrait": "https://wavu.wiki/w/images/9/98/Devil_JinT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/Devil_JinT8.png",
"page": "https://wavu.wiki/t/Devil_Jin"
},
{
"name": "dragunov",
"portrait": "https://wavu.wiki/w/images/d/d0/DragunovT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/DragunovT8.png",
"page": "https://wavu.wiki/t/Dragunov"
},
{
"name": "feng",
"portrait": "https://wavu.wiki/w/images/f/fa/FengT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/FengT8.png",
"page": "https://wavu.wiki/t/Feng"
},
{
"name": "hwoarang",
"portrait": "https://wavu.wiki/w/images/c/ce/HwoarangT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/HwoarangT8.png",
"page": "https://wavu.wiki/t/Hwoarang"
},
{
Expand All @@ -51,117 +51,122 @@
},
{
"name": "jin",
"portrait": "https://wavu.wiki/w/images/7/74/JinT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/JinT8.png",
"page": "https://wavu.wiki/t/Jin"
},
{
"name": "jun",
"portrait": "https://wavu.wiki/w/images/0/0e/JunT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/JunT8.png",
"page": "https://wavu.wiki/t/Jun"
},
{
"name": "kazuya",
"portrait": "https://wavu.wiki/w/images/9/90/KazuyaT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/KazuyaT8.png",
"page": "https://wavu.wiki/t/Kazuya"
},
{
"name": "king",
"portrait": "https://wavu.wiki/w/images/f/f2/KingT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/KingT8.png",
"page": "https://wavu.wiki/t/King"
},
{
"name": "kuma",
"portrait": "https://wavu.wiki/w/images/4/41/KumaT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/KumaT8.png",
"page": "https://wavu.wiki/t/Kuma"
},
{
"name": "lars",
"portrait": "https://wavu.wiki/w/images/f/fc/LarsT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/LarsT8.png",
"page": "https://wavu.wiki/t/Lars"
},
{
"name": "law",
"portrait": "https://wavu.wiki/w/images/5/58/LawT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/LawT8.png",
"page": "https://wavu.wiki/t/Law"
},
{
"name": "lee",
"portrait": "https://wavu.wiki/w/images/9/9d/LeeT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/LeeT8.png",
"page": "https://wavu.wiki/t/Lee"
},
{
"name": "leo",
"portrait": "https://wavu.wiki/w/images/9/95/LeoT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/LeoT8.png",
"page": "https://wavu.wiki/t/Leo"
},
{
"name": "leroy",
"portrait": "https://wavu.wiki/w/images/3/39/LeroyT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/LeroyT8.png",
"page": "https://wavu.wiki/t/Leroy"
},
{
"name": "lidia",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/LidiaT8.png",
"page": "https://wavu.wiki/t/Lidia"
},
{
"name": "lili",
"portrait": "https://wavu.wiki/w/images/d/d0/LiliT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/LiliT8.png",
"page": "https://wavu.wiki/t/Lili"
},
{
"name": "nina",
"portrait": "https://wavu.wiki/w/images/2/20/NinaT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/NinaT8.png",
"page": "https://wavu.wiki/t/Nina"
},
{
"name": "panda",
"portrait": "https://wavu.wiki/w/images/6/6a/PandaT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/PandaT8.png",
"page": "https://wavu.wiki/t/Panda"
},
{
"name": "paul",
"portrait": "https://wavu.wiki/w/images/5/52/PaulT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/PaulT8.png",
"page": "https://wavu.wiki/t/Paul"
},
{
"name": "raven",
"portrait": "https://wavu.wiki/w/images/3/30/RavenT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/RavenT8.png",
"page": "https://wavu.wiki/t/Raven"
},
{
"name": "reina",
"portrait": "https://wavu.wiki/w/images/f/f4/ReinaT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/ReinaT8.png",
"page": "https://wavu.wiki/t/Reina"
},
{
"name": "shaheen",
"portrait": "https://wavu.wiki/w/images/d/d8/ShaheenT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/ShaheenT8.png",
"page": "https://wavu.wiki/t/Shaheen"
},
{
"name": "steve",
"portrait": "https://wavu.wiki/w/images/0/0b/SteveT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/SteveT8.png",
"page": "https://wavu.wiki/t/Steve"
},
{
"name": "victor",
"portrait": "https://wavu.wiki/w/images/f/f3/VictorT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/VictorT8.png",
"page": "https://wavu.wiki/t/Victor"
},
{
"name": "xiaoyu",
"portrait": "https://wavu.wiki/w/images/a/a1/XiaoyuT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/XiaoyuT8.png",
"page": "https://wavu.wiki/t/Xiaoyu"
},
{
"name": "yoshimitsu",
"portrait": "https://wavu.wiki/w/images/6/6d/YoshimitsuT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/YoshimitsuT8.png",
"page": "https://wavu.wiki/t/Yoshimitsu"
},
{
"name": "zafina",
"portrait": "https://wavu.wiki/w/images/7/77/ZafinaT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/ZafinaT8.png",
"page": "https://wavu.wiki/t/Zafina"
},
{
"name": "eddy",
"portrait": "https://wavu.wiki/w/images/7/7d/EddyT8.png",
"portrait": "https://wavu.wiki/t/Special:Redirect/file/EddyT8.png",
"page": "https://wavu.wiki/t/Eddy"
}
]
2 changes: 1 addition & 1 deletion src/frame_service/wavu/tests/test_wavu.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_get_frame_data() -> None:
with requests.session() as session:
char = wavu.get_frame_data(CharacterName.AZUCENA, session)
assert char.name.value.title() == "Azucena"
assert char.portrait == "https://wavu.wiki/w/images/6/65/AzucenaT8.png"
assert char.portrait == "https://wavu.wiki/t/Special:Redirect/file/AzucenaT8.png"


def test_all_char_meta() -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/frame_service/wavu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _convert_json_move(move_json: Any) -> WavuMove:

name = html.unescape(_process_links(move_json["name"]))

input = html.unescape(html.unescape(_normalize_data(move_json["input"]))).replace("*", "\\*")
input = html.unescape(html.unescape(_normalize_data(move_json["input"])))

target = _normalize_data(move_json["target"])

Expand Down
22 changes: 12 additions & 10 deletions src/framedb/const.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import enum
from typing import Dict, List

NUM_CHARACTERS = 33
NUM_CHARACTERS = 34


class CharacterName(enum.Enum):
Expand All @@ -25,19 +25,20 @@ class CharacterName(enum.Enum):
LAW = "law"
LEE = "lee"
LEO = "leo"
LEROY = "leroy"
LIDIA = "lidia"
LILI = "lili"
RAVEN = "raven"
REINA = "reina"
NINA = "nina"
PANDA = "panda"
PAUL = "paul"
RAVEN = "raven"
REINA = "reina"
SHAHEEN = "shaheen"
STEVE = "steve"
VICTOR = "victor"
YOSHIMITSU = "yoshimitsu"
XIAOYU = "xiaoyu"
ZAFINA = "zafina"
LEROY = "leroy"
VICTOR = "victor"

def pretty(self) -> str:
return self.value.replace("_", " ").title()
Expand All @@ -54,7 +55,7 @@ def url_encode(self) -> str:
CharacterName.CLAUDIO: ["cld", "cla"],
CharacterName.DEVIL_JIN: ["dj", "deviljin", "dvj", "djin"],
CharacterName.DRAGUNOV: ["drag", "sergei", "dragu"],
CharacterName.EDDY: ["ed"],
CharacterName.EDDY: ["ed", "capo"],
CharacterName.FENG: ["fen"],
CharacterName.HWOARANG: ["hwo"],
CharacterName.JACK_8: ["j8", "jack8", "jack"],
Expand All @@ -67,19 +68,20 @@ def url_encode(self) -> str:
CharacterName.LAW: ["marshall"],
CharacterName.LEE: ["violet"],
CharacterName.LEO: [],
CharacterName.LEROY: ["ler"],
CharacterName.LIDIA: ["lid", "pm"],
CharacterName.LILI: ["lil"],
CharacterName.RAVEN: ["masterraven", "mraven", "maven", "mrv", "raven", "rav"],
CharacterName.REINA: ["rei"],
CharacterName.NINA: ["nin"],
CharacterName.PANDA: ["pan"],
CharacterName.PAUL: [],
CharacterName.RAVEN: ["masterraven", "mraven", "maven", "mrv", "raven", "rav"],
CharacterName.REINA: ["rei"],
CharacterName.SHAHEEN: ["sha"],
CharacterName.STEVE: ["stv", "ste", "fox"],
CharacterName.VICTOR: ["vic"],
CharacterName.YOSHIMITSU: ["yoshi", "manji", "yos"],
CharacterName.XIAOYU: ["xiao", "ling"],
CharacterName.ZAFINA: ["zaffy", "zaf"],
CharacterName.LEROY: ["ler"],
CharacterName.VICTOR: ["vic"],
}


Expand Down
3 changes: 3 additions & 0 deletions src/framedb/framedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def get_move_by_input(self, character: CharacterName, input_query: str) -> Move
for entry in character_movelist
if FrameDb._simplify_input(entry.input) == FrameDb._simplify_input(input_query)
]
# simple_inputs = [FrameDb._simplify_input(entry.input) for entry in character_movelist]
# simplified_input_query = FrameDb._simplify_input(input_query)
# import code; code.interact(local=locals())
if result:
return result[0]

Expand Down
7 changes: 4 additions & 3 deletions src/heihachi/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_similar_moves_embed( # TODO: look into improving the similar moves flow
)

if len(similar_moves) > 0:
embed.add_field(name="Similar Moves", value="\n".join([move.input for move in similar_moves]))
embed.add_field(name="Similar Moves", value="\n".join([move.input.replace("*", "\\*") for move in similar_moves]))
else:
embed.add_field(name="No similar moves found", value="")
embed.set_thumbnail(url=character.portrait)
Expand All @@ -47,7 +47,7 @@ def get_success_movelist_embed(
For e.g., to a move type
"""

desc_string = "\n".join(sorted([move.input for move in moves]))
desc_string = "\n".join(sorted([move.input.replace("*", "\\*") for move in moves]))

embed = discord.Embed(
title=f"{title}\n",
Expand All @@ -73,8 +73,9 @@ def get_success_embed(message: Any | None) -> discord.Embed:
def get_move_embed(frame_service: FrameService, character: Character, move: Move) -> discord.Embed:
"""Returns the embed message for character and move."""

escaped_input = move.input.replace("*", "\\*")
embed = discord.Embed(
title=f"**{move.input}**",
title=f"**{escaped_input}**",
colour=SUCCESS_COLOR,
description=move.name,
url=frame_service.get_move_url(character, move),
Expand Down

0 comments on commit 4dc1598

Please sign in to comment.