From c595b6896af5feb3d85fb0d0d0e529bce702cde5 Mon Sep 17 00:00:00 2001 From: David Gadling Date: Sun, 9 May 2010 10:05:23 -0700 Subject: [PATCH] roshambo: Lizard-Spock expansion --- data/rbot/plugins/games/roshambo.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/data/rbot/plugins/games/roshambo.rb b/data/rbot/plugins/games/roshambo.rb index 5637ad96..30f02a16 100644 --- a/data/rbot/plugins/games/roshambo.rb +++ b/data/rbot/plugins/games/roshambo.rb @@ -17,12 +17,18 @@ class RoshamboPlugin < Plugin def initialize super @scoreboard = {} - @beats = { :rock => :scissors, :paper => :rock, :scissors => :paper} + @beats = { + :rock => [:scissors, :lizard], + :paper => [:rock, :spock], + :scissors => [:paper, :lizard], + :spock => [:rock, :scissors], + :lizard => [:spock, :paper], + } @plays = @beats.keys end def help(plugin, topic="") - _("roshambo or rps => play roshambo") + _("roshambo or rps => play roshambo") end def rps(m, params) @@ -51,12 +57,12 @@ class RoshamboPlugin < Plugin end def score(bot_choice, human_choice) - return -1 if @beats[bot_choice] == human_choice - return 1 if @beats[human_choice] == bot_choice + return -1 if @beats[bot_choice].include? human_choice + return 1 if @beats[human_choice].include? bot_choice return 0 end end plugin = RoshamboPlugin.new -plugin.map "roshambo :play", :action => :rps, :requirements => { :play => /rock|paper|scissors/ } -plugin.map "rps :play", :action => :rps, :requirements => { :play => /rock|paper|scissors/ } +plugin.map "roshambo :play", :action => :rps, :requirements => { :play => /rock|paper|scissors|lizard|spock/ } +plugin.map "rps :play", :action => :rps, :requirements => { :play => /rock|paper|scissors|lizard|spock/ } -- 2.32.0.93.g670b81a890