Skip to content

Commit

Permalink
Create alts for strings recursively
Browse files Browse the repository at this point in the history
Creates alts for child strings if the root parent has an alt
  • Loading branch information
AbhijeetKrishnan committed Mar 24, 2024
1 parent 2dc4ac4 commit 4dde6a4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/frame_service/wavu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ def _convert_json_move(move_json: Any) -> WavuMove:
recovery = _normalize_data(move_json["recv"])

if "alias" in move_json:
alias = tuple(_process_dotlist(_remove_html_tags(_normalize_data(move_json["alias"]))))
tmp_alias = _process_dotlist(_remove_html_tags(_normalize_data(move_json["alias"])))
alias = tuple(x for x in tmp_alias if x != "")
else:
alias = ()

if "alt" in move_json:
alt = tuple(_process_dotlist(_remove_html_tags(_normalize_data(move_json["alt"]))))
tmp_alt = _process_dotlist(_remove_html_tags(_normalize_data(move_json["alt"])))
alt = tuple(x for x in tmp_alt if x != "")
else:
alt = ()

Expand Down Expand Up @@ -196,19 +198,28 @@ def _convert_wavu_movelist(movelist: List[WavuMove]) -> Dict[str, Move]:
parent_target = curr_move.target
parent_damage = curr_move.damage
root_startup = curr_move.startup # child move startups are equal to oldest parent move startup
root_alt = curr_move.alt
seen[curr_move.id] = True

while stack:
curr_id = stack.pop()
curr_move = wavu_movelist[curr_id]

# prepend commas to input, target, and damage fields if they don't already exist
if len(curr_move.input) > 0 and curr_move.input[0] != ",":
curr_move.input = "," + curr_move.input
if len(curr_move.target) > 0 and curr_move.target[0] != ",":
curr_move.target = "," + curr_move.target
if len(curr_move.damage) > 0 and curr_move.damage[0] != ",":
curr_move.damage = "," + curr_move.damage

# if the root parent has alts, append them to the current move's alts
if len(root_alt) > 0:
tmp_curr_alt = list(curr_move.alt)
for alt in root_alt:
tmp_curr_alt.append(alt + curr_move.input)
curr_move.alt = tuple(tmp_curr_alt)

curr_move.input = parent_input + curr_move.input
curr_move.target = parent_target + curr_move.target
curr_move.damage = parent_damage + curr_move.damage
Expand Down

0 comments on commit 4dde6a4

Please sign in to comment.