Turn ___ into _
This commit is contained in:
parent
df7132725f
commit
46084d4f64
1 changed files with 20 additions and 1 deletions
21
gameloop.py
21
gameloop.py
|
@ -5,7 +5,6 @@ from collections import namedtuple
|
|||
import cardcast_api
|
||||
|
||||
# TODO: rando
|
||||
# TODO: collapse several _ in a row into one
|
||||
# TODO: keep track of where cards come from purge from hand when deck remove
|
||||
|
||||
class events(enum.Enum):
|
||||
|
@ -151,6 +150,26 @@ def game(send, notice, get_event):
|
|||
# Get cards
|
||||
calls, responses = cardcast_api.cards(code)
|
||||
|
||||
# Preprocess calls so that ___ becomes only one _
|
||||
# _ are indicated by splitting the card at that point, e.g.
|
||||
# ['foo ', '.'] is "foo _."
|
||||
# Two blanks a row will thus be ['foo ', '', '.']
|
||||
# We can't just remove every single '', since it can be valid
|
||||
# at the start and the end of a card
|
||||
for i in range(len(calls)):
|
||||
call = []
|
||||
for index, part in enumerate(calls[i]):
|
||||
if index == 0 or index == len(calls[i]) - 1:
|
||||
# Always pass these ones through
|
||||
call.append(part)
|
||||
elif part == '':
|
||||
# Remove '' in the middle
|
||||
continue
|
||||
else:
|
||||
call.append(part)
|
||||
|
||||
calls[i] = call
|
||||
|
||||
# Add a new deck to list of decks
|
||||
decks[code] = Deck(
|
||||
code = code,
|
||||
|
|
Loading…
Reference in a new issue