A human player is recommened to use a name ending with '_human'.
ex. 'hoge_human', 'hoge_human@p1'
+2009-12-20 Daigo Moriwaki <daigo at debian dot org>
+
+ * [shogi-server]
+ - shogi_server/player.rb: Added new methods: is_human? and
+ is_computer?.
+ A human player is recommened to use a name ending with '_human'.
+ ex. 'hoge_human', 'hoge_human@p1'
+
2009-12-04 Daigo Moriwaki <daigo at debian dot org>
+
* [shogi-server]
- The HUP signal is not supported by Ruby on Windows.
# true for Sente; false for Gote
attr_accessor :sente
+ def is_human?
+ return [%r!_human$!, %r!_human@!].any? do |re|
+ re.match(@name)
+ end
+ end
+
+ def is_computer?
+ return !is_human?
+ end
+
def modified_at
@modified_at || Time.now
end
def test_rating_group
assert_nothing_raised {@p.rating_group = 1}
end
+
+ def test_human1
+ @p.name = "hoge_human"
+ assert(@p.is_human?)
+ assert(!@p.is_computer?)
+ end
+
+ def test_human2
+ @p.name = "hoge_human@p1"
+ assert(@p.is_human?)
+ assert(!@p.is_computer?)
+ end
end