@cards = []
end
def has_card?(short)
- cards = []
+ has = []
@cards.each { |c|
- cards << c if c.shortform == short
+ has << c if c.shortform == short
}
- if cards.empty?
+ if has.empty?
return false
else
- return cards
+ return has
end
end
def to_s
end
if card.picker > 0
@picker += card.picker
+ @last_picker = @discard.picker
end
if card.special?
@special = true
def can_play(card)
# When a +something is online, you can only play
- # a +something of same or higher something, or a Reverse
+ # a +something of same or higher something, or a Reverse of
+ # the correct color
# TODO make optional
if @picker > 0
- if card.color and card.color != @color
- return false
- end
- if card.value == 'Reverse' or card.picker >= @discard.picker
+ if (card.value == 'Reverse' and card.color == @color) or card.picker >= @last_picker
return true
else
return false
announce _("%{p}, choose a color with: co r|b|g|y") % { :p => p }
end
else
- announce _("you don't have that card")
+ announce _("you don't have two cards of that kind")
end
+ else
+ announce _("you don't have that card")
end
end
announce _('what color is that?')
return
end
- announce _('color is now %{c}') % { :c => @color.downcase }
+ announce _('color is now %{c}') % {
+ :c => UnoGame.irc_color_bg(@color)+" #{@color} "
+ }
next_turn
end
end
end
end
+ picked.sort!
notify player, _("You picked %{picked}") % { :picked => picked.join(' ') }
player.cards += picked
player.cards.sort!
:uno => UNO, :p => @players.first
}
if @picker > 0
- p = @player[1]
+ p = @players[1]
announce _("%{p} has to pick %{b}%{n}%{b} cards!") % {
:p => p, :n => @picker, :b => Bold
}
- deal(@player[1], @picker)
+ deal(p, @picker)
@picker = 0
end
score = @players.inject(0) do |sum, p|
g = @games[m.channel]
case m.plugin.intern
when :jo # join game
+ return if m.params
g.add_player(m.source)
when :pe # pick card
+ return if m.params
if g.has_turn?(m.source)
if g.player_has_picked
m.reply _("you already picked a card")
m.reply _("It's not your turn")
end
when :pa # pass turn
+ return if m.params
if g.has_turn?(m.source)
g.pass(m.source)
else
m.reply _("It's not your turn")
end
when :ca # show current cards
+ return if m.params
g.show_all_cards(m.source)
when :cd # show current discard
+ return if m.params
g.show_discard
# TODO
# when :ch
# g.challenge
when :od # show playing order
+ return if m.params
g.show_order
when :ti # show play time
+ return if m.params
g.show_time
when :tu # show whose turn is it
+ return if m.params
if g.has_turn?(m.source)
m.nickreply _("it's your turn, sleepyhead")
else