Skip to content

Commit

Permalink
Add automatically creation of aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
TLNBS2405 committed Dec 18, 2023
1 parent 79ee6ba commit 7f9169e
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 19 deletions.
25 changes: 20 additions & 5 deletions src/json_movelist/asuka.json
Original file line number Diff line number Diff line change
Expand Up @@ -952,10 +952,13 @@
"target": "l(,th)"
},
{
"alias": [
"b+2+4"
],
"damage": "25",
"gif": "",
"id": "Asuka-b+1+3",
"input": "b+1+3_b+2+4",
"input": "b+1+3",
"name": "Attack Reversal",
"notes": "\n* Does 25 + 50% of reversed attack as damage\n* Opp. Position on hit: Reverse Pos Foot-sd. Face-up\n* Reverses limb-based h/m attacks",
"on_block": "-6",
Expand All @@ -966,10 +969,13 @@
"target": ""
},
{
"alias": [
"b+2+4*"
],
"damage": "25",
"gif": "",
"id": "Asuka-b+1+3*",
"input": "b+1+3*_b+2+4*",
"input": "b+1+3*",
"name": "Attack Reversal (Hold)",
"notes": "\n* Does 25 + 50% of reversed attack as damage\n* Opp. Position on hit: Reverse Pos Foot-sd. Face-up\n* Reverses limb-based h/m attacks",
"on_block": "-6",
Expand Down Expand Up @@ -2226,10 +2232,13 @@
"target": "l"
},
{
"alias": [
"f+2+4,1"
],
"damage": "020",
"gif": "",
"id": "Asuka-Destabilizer.1",
"input": "f+1+3_f+2+4,1",
"input": "f+1+3,1",
"name": "Compulsory Reform",
"notes": "\n* [[:Template:HE]]\n* Gain Naniwa Gusto on Heat Activation",
"on_block": "",
Expand All @@ -2240,10 +2249,13 @@
"target": "t(h)m"
},
{
"alias": [
"f+2+4Destabilizer.4"
],
"damage": "019",
"gif": "",
"id": "Asuka-Destabilizer.4",
"input": "f+1+3_f+2+4Destabilizer.4",
"input": "f+1+3Destabilizer.4",
"name": "Inescapable Tirade",
"notes": "",
"on_block": "",
Expand Down Expand Up @@ -2618,10 +2630,13 @@
"target": "h"
},
{
"alias": [
"f+2+4"
],
"damage": "0",
"gif": "",
"id": "Asuka-f+1+3",
"input": "f+1+3_f+2+4",
"input": "f+1+3",
"name": "Destabilizer",
"notes": "\n* Break: none\n* Opp. Position on break: \n* Opp. Position on hit: ",
"on_block": "",
Expand Down
20 changes: 16 additions & 4 deletions src/json_movelist/azucena.json
Original file line number Diff line number Diff line change
Expand Up @@ -1344,10 +1344,13 @@
"target": ""
},
{
"alias": [
"BT.b+4"
],
"damage": "",
"gif": "",
"id": "Azucena-BT.b+3_4",
"input": "BT.b+3_4",
"input": "BT.b+3",
"name": "Shuffle Walk",
"notes": "",
"on_block": "",
Expand Down Expand Up @@ -1526,10 +1529,13 @@
"target": "l"
},
{
"alias": [
"d+2+4"
],
"damage": "30",
"gif": "",
"id": "Azucena-d+1+3_d+2+4",
"input": "d+1+3_d+2+4",
"input": "d+1+3",
"name": "Smell the Coffee",
"notes": "\n* \nHeat Engager\n* Crouch throw\n* Unbreakable",
"on_block": "",
Expand Down Expand Up @@ -3878,10 +3884,13 @@
"target": ""
},
{
"alias": [
"LIB.d+2+4"
],
"damage": "30",
"gif": "",
"id": "Azucena-LIB.d+1+3_d+2+4",
"input": "LIB.d+1+3_d+2+4",
"input": "LIB.d+1+3",
"name": "Smell the Coffee",
"notes": "\n* \nHeat Engager\n* Crouch throw",
"on_block": "",
Expand Down Expand Up @@ -3976,10 +3985,13 @@
"target": "m"
},
{
"alias": [
"LIB.D"
],
"damage": "",
"gif": "",
"id": "Azucena-LIB.U_D",
"input": "LIB.U_D",
"input": "LIB.U",
"name": "Milagros Show",
"notes": "\n* Parries all high/low attacks\n* Regenerates heat with each step",
"on_block": "",
Expand Down
10 changes: 8 additions & 2 deletions src/json_movelist/jun.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,13 @@
"target": "h,h,sp"
},
{
"alias": [
"1,2,d"
],
"damage": "5,8",
"gif": "",
"id": "Jun-1,2,u_d",
"input": "1,2,u_d",
"input": "1,2,u",
"name": "",
"notes": "",
"on_block": "+1",
Expand Down Expand Up @@ -3122,10 +3125,13 @@
"target": "m,sp"
},
{
"alias": [
"f+3~d"
],
"damage": "13",
"gif": "",
"id": "Jun-f+3~u_d",
"input": "f+3~u_d",
"input": "f+3~u",
"name": "",
"notes": "",
"on_block": "-2",
Expand Down
25 changes: 20 additions & 5 deletions src/json_movelist/kazuya.json
Original file line number Diff line number Diff line change
Expand Up @@ -1022,10 +1022,13 @@
"target": "m"
},
{
"alias": [
"BT.2"
],
"damage": "15",
"gif": "",
"id": "Kazuya-BT.1_2",
"input": "BT.1_2",
"input": "BT.1",
"name": "Spin Knuckle Jab",
"notes": "",
"on_block": "-8",
Expand All @@ -1050,10 +1053,13 @@
"target": "h"
},
{
"alias": [
"BT.4"
],
"damage": "18",
"gif": "",
"id": "Kazuya-BT.3_4",
"input": "BT.3_4",
"input": "BT.3",
"name": "Spin Kick",
"notes": "",
"on_block": "-8",
Expand All @@ -1078,10 +1084,13 @@
"target": "h"
},
{
"alias": [
"BT.d+2"
],
"damage": "10",
"gif": "",
"id": "Kazuya-BT.d+1_d+2",
"input": "BT.d+1_d+2",
"input": "BT.d+1",
"name": "Crouch Spin Knuckle",
"notes": "",
"on_block": "-2",
Expand All @@ -1106,10 +1115,13 @@
"target": "sm"
},
{
"alias": [
"BT.d+4"
],
"damage": "12",
"gif": "",
"id": "Kazuya-BT.d+3_d+4",
"input": "BT.d+3_d+4",
"input": "BT.d+3",
"name": "Crouch Spin Kick",
"notes": "",
"on_block": "-11",
Expand Down Expand Up @@ -1148,10 +1160,13 @@
"target": "m"
},
{
"alias": [
"BT.uf+4"
],
"damage": "-",
"gif": "",
"id": "Kazuya-BT.uf+3_uf+4",
"input": "BT.uf+3_uf+4",
"input": "BT.uf+3",
"name": "Reverse Jump Kick",
"notes": "",
"on_block": "",
Expand Down
4 changes: 3 additions & 1 deletion src/module/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Move:
def __init__(self, id: str, name: str, input: str, target: str, damage: str, on_block: str, on_hit: str, on_ch: str,
startup: str, recovery: str, notes: str, gif: str):
startup: str, recovery: str, notes: str, gif: str, alias: List[str]):
self.id = id
self.name = name
self.input = input
Expand All @@ -18,6 +18,8 @@ def __init__(self, id: str, name: str, input: str, target: str, damage: str, on_
self.recovery = recovery
self.notes = notes
self.gif = gif
if alias:
self.alias = alias


class MoveEncoder(JSONEncoder):
Expand Down
5 changes: 5 additions & 0 deletions src/wavu/test/asuka.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "asuka",
"portrait": "x",
"wavu_page": "page"
}
5 changes: 5 additions & 0 deletions src/wavu/test/jun.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "jun",
"portrait": "x",
"wavu_page": "page"
}
14 changes: 14 additions & 0 deletions src/wavu/test/test_wavu_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ def test_get_character_movelist(self):
character_movelist = wavu_reader.get_character_movelist("Azucena")
self.assertEqual(character_movelist[0].input,"1")

def test_create_alias(self):

character_movelist = wavu_reader.get_character_movelist("asuka")
move = wavu_reader.get_move("Asuka-Destabilizer.1",character_movelist)
self.assertEqual(move.alias,["f+2+4,1"])

move = wavu_reader.get_move("Asuka-f+1+3",character_movelist)
self.assertEqual(move.alias,["f+2+4"])


character_movelist = wavu_reader.get_character_movelist("jun")
move = wavu_reader.get_move("Jun-1,2,u_d",character_movelist)
self.assertEqual(move.alias,["1,2,d"])
self.assertEqual(move.input,"1,2,u")

def test_get_move(self):
character_movelist = wavu_reader.get_character_movelist("Azucena")
Expand Down
38 changes: 36 additions & 2 deletions src/wavu/wavu_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,52 @@ def _get_all_parent_values_of(field: str, move_id: str, move_list_json: list) ->
for move in move_list_json:
if move["title"]["id"] == move_id:
if move["title"]["parent"]:
complete_input += _get_all_parent_values_of(field, move["title"]["parent"], move_list_json)
original_move = move["title"]["parent"]
if "_" in original_move:
original_move = original_move.split("_")[0]
complete_input += _get_all_parent_values_of(field,original_move, move_list_json)
return complete_input + move["title"][field]
else:
return ""

def _remove_non_ascii(data):
return re.sub(r'[^\x00-\x7F]+', '', data)


#last entry is always the input
def _create_alias(input :str) -> List[str]:

parts = input.split("_")
input = parts[0]
aliases = parts[1:]
result = []
for entry in aliases:
num_characters = len(entry)
x = len(input)-num_characters
if x<0:
x=0
original_input= input[0:x]
alias = original_input + entry
if len(alias) > len(input):
input=input+entry[len(input):]

result.append(alias)
result.append(input)
return result

def _convert_json_movelist(move_list_json: list) -> List[Move]:
move_list = []
for move in move_list_json:
alias = []
id = _remove_non_ascii(move["title"]["id"])
name = _remove_non_ascii(move["title"]["name"])

input = _remove_non_ascii(_get_all_parent_values_of("input", move["title"]["parent"], move_list_json) + move["title"]["input"])
if "_" in input:
result = _create_alias(input)
input = result[-1]
alias = result[0:(len(result)-1)]

target = _remove_non_ascii(_get_all_parent_values_of("target", move["title"]["parent"], move_list_json) + move["title"]["target"])
damage = _remove_non_ascii(_get_all_parent_values_of("damage", move["title"]["parent"], move_list_json) + move["title"]["damage"])

Expand All @@ -74,7 +106,9 @@ def _convert_json_movelist(move_list_json: list) -> List[Move]:

notes = html.unescape(move["title"]["notes"])
notes = BeautifulSoup(notes, features="lxml").get_text()
move = Move(id, name, input, target, damage, on_block, on_hit, on_ch, startup, recovery, notes, "")


move = Move(id, name, input, target, damage, on_block, on_hit, on_ch, startup, recovery, notes, "", alias)
move_list.append(move)
return move_list

Expand Down

0 comments on commit 7f9169e

Please sign in to comment.