Skip to content

Commit

Permalink
fix: add power list for pda games
Browse files Browse the repository at this point in the history
  • Loading branch information
Byung authored and Byung committed Aug 31, 2022
1 parent 97f83af commit 54bb18c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion daidepp/parser/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
arrangement = pce / aly_vss / drw / slo / not / nar / xdo / dmz / and / orr / scd / occ / cho / for / xoy / ydo / snd / fwd / bcc
pce = "PCE" lpar power (ws power)* rpar
aly_vss = "ALY" lpar power (ws power)* rpar "VSS" lpar power (ws power)* rpar
drw = "DRW"
drw = "DRW" (lpar power (ws power)+ rpar)?
slo = "SLO" lpar power rpar
not = "NOT" lpar arrangement rpar
nar = "NAR" lpar arrangement rpar
Expand Down
14 changes: 13 additions & 1 deletion daidepp/parser/node_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,19 @@ def visit_aly_vss(self, node, visited_children):
return ("ALY_VSS", (aly_list, vss_list))

def visit_drw(self, node, visited_children):
return node.text
_, par_powers = visited_children

if isinstance(par_powers, Node) and not par_powers.text:
return "DRW"

# For Partial draws are allowed (PDA) variant game
_, power, ws_powers, _ = par_powers[0]
pow_list = [power]
for ws_pow in ws_powers:
_, pow = ws_pow
pow_list.append(pow)

return ("DRW", pow_list)

def visit_slo(self, node, visited_children):
_, _, power, _ = visited_children
Expand Down

0 comments on commit 54bb18c

Please sign in to comment.