hopefully all rules are now implemented
This commit is contained in:
parent
b0bdbe0d0f
commit
fb6da7cfa7
1 changed files with 19 additions and 13 deletions
32
bot.py
32
bot.py
|
@ -68,15 +68,7 @@ def reply_to_query(bot, update):
|
||||||
playable = list()
|
playable = list()
|
||||||
|
|
||||||
if game.choosing_color:
|
if game.choosing_color:
|
||||||
for color in c.COLORS:
|
choose_color(results)
|
||||||
results.append(
|
|
||||||
InlineQueryResultArticle(
|
|
||||||
id=color,
|
|
||||||
title="Choose Color",
|
|
||||||
message_text=color,
|
|
||||||
description=color.upper()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
playable = list(sorted(player.playable_cards()))
|
playable = list(sorted(player.playable_cards()))
|
||||||
|
|
||||||
|
@ -85,8 +77,9 @@ def reply_to_query(bot, update):
|
||||||
elif playable:
|
elif playable:
|
||||||
for card in playable:
|
for card in playable:
|
||||||
play_card(card, results)
|
play_card(card, results)
|
||||||
elif not game.choosing_color:
|
|
||||||
draw(player, results)
|
if playable is not False and not game.choosing_color and not player.drew:
|
||||||
|
draw(player, results, could_play_card=bool(len(playable)))
|
||||||
|
|
||||||
if player.drew:
|
if player.drew:
|
||||||
pass_(results)
|
pass_(results)
|
||||||
|
@ -99,6 +92,18 @@ def reply_to_query(bot, update):
|
||||||
bot.answerInlineQuery(update.inline_query.id, results, cache_time=0)
|
bot.answerInlineQuery(update.inline_query.id, results, cache_time=0)
|
||||||
|
|
||||||
|
|
||||||
|
def choose_color(results):
|
||||||
|
for color in c.COLORS:
|
||||||
|
results.append(
|
||||||
|
InlineQueryResultArticle(
|
||||||
|
id=color,
|
||||||
|
title="Choose Color",
|
||||||
|
message_text=color,
|
||||||
|
description=color.upper()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def other_cards(playable, player, results):
|
def other_cards(playable, player, results):
|
||||||
results.append(
|
results.append(
|
||||||
InlineQueryResultArticle(
|
InlineQueryResultArticle(
|
||||||
|
@ -111,11 +116,12 @@ def other_cards(playable, player, results):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def draw(player, results):
|
def draw(player, results, could_play_card):
|
||||||
results.append(
|
results.append(
|
||||||
InlineQueryResultArticle(
|
InlineQueryResultArticle(
|
||||||
"draw",
|
"draw",
|
||||||
title="No suitable cards...",
|
title=("No suitable cards..." if not could_play_card else
|
||||||
|
"I don't want to play a card..."),
|
||||||
description="Draw!",
|
description="Draw!",
|
||||||
message_text='Drawing %d card(s)'
|
message_text='Drawing %d card(s)'
|
||||||
% (player.game.draw_counter or 1)
|
% (player.game.draw_counter or 1)
|
||||||
|
|
Loading…
Reference in a new issue