summaryrefslogtreecommitdiff
path: root/rbot/plugins/roshambo.rb
diff options
context:
space:
mode:
authorTom Gilbert <tom@linuxbrit.co.uk>2005-07-27 15:59:13 +0000
committerTom Gilbert <tom@linuxbrit.co.uk>2005-07-27 15:59:13 +0000
commit21949774b91eaec6ecde4eaa8ad121e2c0a36b87 (patch)
tree41a7601e168018ac203bad7ca8d7f9f82515bc28 /rbot/plugins/roshambo.rb
parent51cf09ec02d089bfdd80e5f728cfc92a234dc437 (diff)
rearrange repo for packaging
Diffstat (limited to 'rbot/plugins/roshambo.rb')
-rw-r--r--rbot/plugins/roshambo.rb54
1 files changed, 0 insertions, 54 deletions
diff --git a/rbot/plugins/roshambo.rb b/rbot/plugins/roshambo.rb
deleted file mode 100644
index 4f20fb15..00000000
--- a/rbot/plugins/roshambo.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-# Play the game of roshambo (rock-paper-scissors)
-# Copyright (C) 2004 Hans Fugal
-# Distributed under the same license as rbot itself
-require 'time'
-class RoshamboPlugin < Plugin
- def initialize
- super
- @scoreboard = {}
- end
- def help(plugin, topic="")
- "roshambo <rock|paper|scissors> => play roshambo"
- end
- def privmsg(m)
- # simultaneity
- choice = choose
-
- # init scoreboard
- if (not @scoreboard.has_key?(m.sourcenick) or (Time.now - @scoreboard[m.sourcenick]['timestamp']) > 3600)
- @scoreboard[m.sourcenick] = {'me'=>0,'you'=>0,'timestamp'=>Time.now}
- end
- case m.params
- when 'rock','paper','scissors'
- s = score(choice,m.params)
- @scoreboard[m.sourcenick]['timestamp'] = Time.now
- myscore=@scoreboard[m.sourcenick]['me']
- yourscore=@scoreboard[m.sourcenick]['you']
- case s
- when 1
- yourscore=@scoreboard[m.sourcenick]['you'] += 1
- m.reply "#{choice}. You win. Score: me #{myscore} you #{yourscore}"
- when 0
- m.reply "#{choice}. We tie. Score: me #{myscore} you #{yourscore}"
- when -1
- myscore=@scoreboard[m.sourcenick]['me'] += 1
- m.reply "#{choice}! I win! Score: me #{myscore} you #{yourscore}"
- end
- else
- m.reply "incorrect usage: " + help(m.plugin)
- end
- end
-
- def choose
- ['rock','paper','scissors'][rand(3)]
- end
- def score(a,b)
- beats = {'rock'=>'scissors', 'paper'=>'rock', 'scissors'=>'paper'}
- return -1 if beats[a] == b
- return 1 if beats[b] == a
- return 0
- end
-end
-plugin = RoshamboPlugin.new
-plugin.register("roshambo")
-plugin.register("rps")