[Foo [_]] → [Foo _]
This commit is contained in:
parent
bc3daf8032
commit
dff760e0f4
20
gameloop.py
20
gameloop.py
|
@ -809,7 +809,7 @@ def game(send, notice, voice, devoice, get_event):
|
||||||
|
|
||||||
notice(nick, cards)
|
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
|
# 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
|
# `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
|
# Additionally, we have a special mode in case we are displaying
|
||||||
# the round call card, where we do not look up the responses
|
# 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()
|
formatting_state = IRCFormattingState()
|
||||||
no_formatting = IRCFormattingState()
|
no_formatting = IRCFormattingState()
|
||||||
|
@ -899,12 +903,20 @@ def game(send, notice, voice, devoice, get_event):
|
||||||
# If there is still one, add the response coming
|
# If there is still one, add the response coming
|
||||||
# after that segment
|
# after that segment
|
||||||
if part_index < len(responses):
|
if part_index < len(responses):
|
||||||
|
if dereference_responses:
|
||||||
|
# Add response
|
||||||
r.append(to_formatting_state(formatting_state, no_formatting))
|
r.append(to_formatting_state(formatting_state, no_formatting))
|
||||||
r.append('[')
|
r.append('[')
|
||||||
r.append(sanitize(responses[part_index], no_formatting))
|
r.append(sanitize(responses[part_index], no_formatting))
|
||||||
r.append(']')
|
r.append(']')
|
||||||
r.append(to_formatting_state(no_formatting, formatting_state))
|
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
|
# Start on a new part as well as a new segment
|
||||||
part_index += 1
|
part_index += 1
|
||||||
index = 0
|
index = 0
|
||||||
|
@ -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)
|
call_segment, formatting_state = handle_control_codes(call_part[segment_start_index:index - 2], formatting_state)
|
||||||
r.append(call_segment)
|
r.append(call_segment)
|
||||||
|
|
||||||
if dereference_backreferences:
|
if dereference_responses:
|
||||||
# Add the response this backreference refers to
|
# Add the response this backreference refers to
|
||||||
r.append(to_formatting_state(formatting_state, no_formatting))
|
r.append(to_formatting_state(formatting_state, no_formatting))
|
||||||
r.append('[')
|
r.append('[')
|
||||||
|
@ -973,7 +985,7 @@ def game(send, notice, voice, devoice, get_event):
|
||||||
num_blanks = len(round_call_card.text) - 1
|
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('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
|
# Have bots choose first
|
||||||
for bot in bots.values():
|
for bot in bots.values():
|
||||||
|
|
Loading…
Reference in New Issue