UNO: channel-specific prefix characters

This commit is contained in:
oddluck 2020-07-18 10:08:07 +00:00
parent de97e07397
commit 82f1044bb4

View File

@ -94,6 +94,15 @@ class UNO(callbacks.Plugin):
irc.reply("Error: allow_game=False") irc.reply("Error: allow_game=False")
return return
def get(group):
v = group.getSpecific(channel=msg.args[0])
return v()
try:
prefixChar = get(conf.supybot.reply.whenAddressedBy.chars)[0]
except:
prefixChar = ""
# may want to add a game variant later # may want to add a game variant later
if text: if text:
gametype = text.lower().strip() gametype = text.lower().strip()
@ -133,9 +142,9 @@ class UNO(callbacks.Plugin):
nick, nick,
gametype.capitalize(), gametype.capitalize(),
table + 1, table + 1,
self.prefixChar, prefixChar,
self.prefixChar, prefixChar,
self.prefixChar, prefixChar,
), ),
prefixNick=False, prefixNick=False,
) )
@ -205,6 +214,16 @@ class UNO(callbacks.Plugin):
irc.reply("Error: You are not playing UNO at any of the tables.") irc.reply("Error: You are not playing UNO at any of the tables.")
return return
channel = self.game[table]["channel"] channel = self.game[table]["channel"]
def get(group):
v = group.getSpecific(channel=channel)
return v()
try:
prefixChar = get(conf.supybot.reply.whenAddressedBy.chars)[0]
except:
prefixChar = ""
opponents = [p for p in list(self.game[table]["players"].keys()) if p != nick] opponents = [p for p in list(self.game[table]["players"].keys()) if p != nick]
opponent = opponents[0] opponent = opponents[0]
opponent_cards = [ opponent_cards = [
@ -268,8 +287,14 @@ class UNO(callbacks.Plugin):
yourhandcolor = utils.str.commaAndify(yourhandcolor) yourhandcolor = utils.str.commaAndify(yourhandcolor)
txt = ( txt = (
"It is your turn. The top card is %s. You have %s cards (%s)." "It is your turn. The top card is %s. You have %s cards (%s)."
' %s. To play a card, use the "uno play" command.' ' %s. To play a card, use the "%suno play" command.'
% (topcardcolor, ncards, yourhandcolor, opponent_cards) % (
topcardcolor,
ncards,
yourhandcolor,
opponent_cards,
prefixChar,
)
) )
if self.channeloptions["use_notice"] == True: if self.channeloptions["use_notice"] == True:
self.reply(irc, txt, to=nick, notice=True, private=True) self.reply(irc, txt, to=nick, notice=True, private=True)
@ -283,8 +308,8 @@ class UNO(callbacks.Plugin):
turnplayer = "your" turnplayer = "your"
txt = ( txt = (
"It is your turn. The top card is %s. You have %s cards (%s)." "It is your turn. The top card is %s. You have %s cards (%s)."
' %s. To play a card, use the "uno play" command.' ' %s. To play a card, use the "%suno play" command.'
% (topcard, ncards, yourhand, opponent_cards) % (topcard, ncards, yourhand, opponent_cards, prefixChar)
) )
if self.channeloptions["use_notice"] == True: if self.channeloptions["use_notice"] == True:
self.reply(irc, txt, to=nick, notice=True, private=True) self.reply(irc, txt, to=nick, notice=True, private=True)
@ -382,6 +407,15 @@ class UNO(callbacks.Plugin):
irc.reply("Error: allow_game=False") irc.reply("Error: allow_game=False")
return return
def get(group):
v = group.getSpecific(channel=msg.args[0])
return v()
try:
prefixChar = get(conf.supybot.reply.whenAddressedBy.chars)[0]
except:
prefixChar = ""
nick = msg.nick nick = msg.nick
if table != None: if table != None:
table -= 1 # make tables zero based table -= 1 # make tables zero based
@ -450,7 +484,7 @@ class UNO(callbacks.Plugin):
irc.reply( irc.reply(
"%s has joined the %s game at table %s. Use %suno begin to" "%s has joined the %s game at table %s. Use %suno begin to"
" begin the game." " begin the game."
% (nick, self.game[table]["type"], table + 1, self.prefixChar), % (nick, self.game[table]["type"], table + 1, prefixChar),
prefixNick=False, prefixNick=False,
to=self.game[table]["channel"], to=self.game[table]["channel"],
) )
@ -784,6 +818,15 @@ class UNO(callbacks.Plugin):
nick = msg.nick nick = msg.nick
def get(group):
v = group.getSpecific(channel=msg.args[0])
return v()
try:
prefixChar = get(conf.supybot.reply.whenAddressedBy.chars)[0]
except:
prefixChar = ""
table = self._gettablefromnick(nick) table = self._gettablefromnick(nick)
if table == None: if table == None:
irc.reply("Error: You are not playing a game at any of the tables.") irc.reply("Error: You are not playing a game at any of the tables.")
@ -848,7 +891,7 @@ class UNO(callbacks.Plugin):
irc, irc,
"You draw a %s from the draw pile. You can choose not to" "You draw a %s from the draw pile. You can choose not to"
' play this card using "%suno play done"' ' play this card using "%suno play done"'
% (c, self.prefixChar), % (c, prefixChar),
to=nick, to=nick,
notice=True, notice=True,
private=True, private=True,