[Foo [_]] → [Foo _]
This commit is contained in:
parent
bc3daf8032
commit
dff760e0f4
30
gameloop.py
30
gameloop.py
|
@ -809,7 +809,7 @@ def game(send, notice, voice, devoice, get_event):
|
|||
|
||||
notice(nick, cards)
|
||||
|
||||
def combine_cards(call, responses, dereference_backreferences = True):
|
||||
def combine_cards(call, responses, dereference_responses = True):
|
||||
# This function is really messy, in part due to the format used
|
||||
#
|
||||
# `call` is a list of strings, and here I'll refer to each of
|
||||
|
@ -877,7 +877,11 @@ def game(send, notice, voice, devoice, get_event):
|
|||
#
|
||||
# Additionally, we have a special mode in case we are displaying
|
||||
# the round call card, where we do not look up the responses
|
||||
# pointed to by backreferences, but instead add the $<num>
|
||||
# pointed to by backreferences or blanks, but instead add the
|
||||
# $<num> or _. In this mode `responses` still has to be correct
|
||||
# length in order to recognize valid backreferences and to
|
||||
# distinguish between a blank and end of a card (this could
|
||||
# admitedly use some work).
|
||||
|
||||
formatting_state = IRCFormattingState()
|
||||
no_formatting = IRCFormattingState()
|
||||
|
@ -899,11 +903,19 @@ def game(send, notice, voice, devoice, get_event):
|
|||
# If there is still one, add the response coming
|
||||
# after that segment
|
||||
if part_index < len(responses):
|
||||
r.append(to_formatting_state(formatting_state, no_formatting))
|
||||
r.append('[')
|
||||
r.append(sanitize(responses[part_index], no_formatting))
|
||||
r.append(']')
|
||||
r.append(to_formatting_state(no_formatting, formatting_state))
|
||||
if dereference_responses:
|
||||
# Add response
|
||||
r.append(to_formatting_state(formatting_state, no_formatting))
|
||||
r.append('[')
|
||||
r.append(sanitize(responses[part_index], no_formatting))
|
||||
r.append(']')
|
||||
r.append(to_formatting_state(no_formatting, formatting_state))
|
||||
|
||||
else:
|
||||
# Add the blank itself (useful for displaying the call card)
|
||||
r.append(to_formatting_state(formatting_state, no_formatting))
|
||||
r.append('_')
|
||||
r.append(to_formatting_state(no_formatting, formatting_state))
|
||||
|
||||
# Start on a new part as well as a new segment
|
||||
part_index += 1
|
||||
|
@ -928,7 +940,7 @@ def game(send, notice, voice, devoice, get_event):
|
|||
call_segment, formatting_state = handle_control_codes(call_part[segment_start_index:index - 2], formatting_state)
|
||||
r.append(call_segment)
|
||||
|
||||
if dereference_backreferences:
|
||||
if dereference_responses:
|
||||
# Add the response this backreference refers to
|
||||
r.append(to_formatting_state(formatting_state, no_formatting))
|
||||
r.append('[')
|
||||
|
@ -973,7 +985,7 @@ def game(send, notice, voice, devoice, get_event):
|
|||
num_blanks = len(round_call_card.text) - 1
|
||||
|
||||
send('Round %i. %s is czar. %s choose your cards' % (round_number, czar.nick, ', '.join(i.nick for i in choosers)))
|
||||
send('[%s]' % combine_cards(round_call_card.text, ['_'] * num_blanks, dereference_backreferences = False))
|
||||
send('[%s]' % combine_cards(round_call_card.text, ['_'] * num_blanks, dereference_responses = False))
|
||||
|
||||
# Have bots choose first
|
||||
for bot in bots.values():
|
||||
|
|
Loading…
Reference in New Issue