# playing several games, each per channel. A game can be turn-based, where only new
# players can interrupt a turn to join, or a free mode where anyone can speak at any
# time.
+#
+# In Japanese mode, if present, the plugin can use normalize-japanese
+# <http://neruchan.mine.nu:60880/normalize-japanese.rb> to allow
+# katakana words be used like hiragana.
#
# TODO
# * a system to describe settings, so they can be displayed, changed and saved
# announce the current word, and player if take_turns?
def announce
- say (if take_turns?
+ say(if take_turns?
_("%{current_player}, it's your turn. %{previous_word} -> %{current_word}") %
{ :current_player => current_player, :previous_word => previous_word,
:current_word => current_word }
:listen => /\A\S+\Z/u,
:overlap_lengths => 1..4,
:desc => 'Use Japanese words in hiragana; 1-4 kana at the beginning of the next word must overlap with those at the end of the previous word.',
- # Optionally use a module to normalize Japanese words, enabling input in multiple writing systems
+ :normalize =>
+ begin
+ require 'normalize-japanese'
+ lambda {|w| w.to_hiragana}
+ rescue LoadError
+ lambda {|w| w}
+ end
}
}
end
end
# all messages from a channel is sent to its shiritori game if any
- def listen(m)
- return unless m.kind_of?(PrivMessage)
+ def message(m)
return unless @games.has_key?(m.channel)
# send the message to the game in the channel to handle it
@games[m.channel].handle_message m
def cleanup
@games.each_key {|g| g.die}
@games.clear
+ super
end
end