]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
uno plugin: don't allow g9r9 card specification
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 18 Oct 2010 22:39:13 +0000 (00:39 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 18 Oct 2010 22:39:13 +0000 (00:39 +0200)
The regexp should make sure that the second card is equal to the first
specified card, instead of matching the card expression one or two
times. Otherwise, a play like 'pl g9r9' would be accepted when the
player had two r9 cards and could play them.

This is only a aesthetical change because the plays would still be
valid, albeit (1) surprising and (2) mismatching what the user actually
wrote.

data/rbot/plugins/games/uno.rb

index 870526fc38e8a9636d14252d97dcdca535d06147..adaa127f15bb34845ea51a4f86b83c892988b545 100644 (file)
@@ -382,7 +382,7 @@ class UnoGame
   def play_card(source, cards)
     debug "Playing card #{cards}"
     p = get_player(source)
-    shorts = cards.gsub(/\s+/,'').match(/^(?:([rbgy]\+?\d){1,2}|([rbgy][rs])|(w(?:\+4)?)([rbgy])?)$/).to_a
+    shorts = cards.gsub(/\s+/,'').match(/^(?:([rbgy]\+?\d)\1|([rbgy][rs])|(w(?:\+4)?)([rbgy])?)$/).to_a
     debug shorts.inspect
     if shorts.empty?
       announce _("what cards were that again?")