OSDN Git Service

Merge remote-tracking branch 'origin/wdoor-stable' into wdoor-stable
[shogi-server/shogi-server.git] / shogi_server / piece.rb
index ab8efba..8717dff 100644 (file)
@@ -1,7 +1,7 @@
 ## $Id$
 
 ## Copyright (C) 2004 NABEYA Kenichi (aka nanami@2ch)
-## Copyright (C) 2007-2008 Daigo Moriwaki (daigo at debian dot org)
+## Copyright (C) 2007-2012 Daigo Moriwaki (daigo at debian dot org)
 ##
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -154,18 +154,17 @@ class Piece
     @promoted_name
   end
 
+  def current_name
+    return @promoted ? @promoted_name : @name
+  end
+
   def to_s
     if (@sente)
       sg = "+"
     else
       sg = "-"
     end
-    if (@promoted)
-      n = @promoted_name
-    else
-      n = @name
-    end
-    return sg + n
+    return sg + current_name
   end
 end