/classes/tgame.js

https://code.google.com/p/smallgoeditor/ · JavaScript · 153 lines · 86 code · 5 blank · 62 comment · 45 complexity · 7e01c77bb09c37037ddd95f238803d6c MD5 · raw file

  1. //////////////////////////////////////////////////////////////////////////////
  2. //  ласс »√–ј //
  3. //////////////////////////////////////////////////////////////////////////////
  4. /****c* SmallGoEditor/TGame
  5. * NAME
  6. *  ласс TGame Ч описывает игру
  7. * VERSION
  8. * 0.3 (20.06.2011)
  9. * FUNCTION
  10. *  ласс, описывающий основные параметры игры (партии).
  11. * PROPERTIES
  12. * {Integer} SGFMoveIndex ЧЧ индекс текущего узла
  13. * {Integer} WCaptured ЧЧ белых сн€то
  14. * {Integer} BCaptured ЧЧ чЄрных сн€то
  15. * {Boolean} BlackMove ЧЧ ход чЄрных или нет (true - да)
  16. * {String} AN ЧЧ Annotation
  17. * {String} BR ЧЧ Black rank
  18. * {String} BT ЧЧ Black team
  19. * {String} CP ЧЧ Copyright
  20. * {String} DT ЧЧ Date
  21. * {String} EV ЧЧ Event
  22. * {String} GC ЧЧ Game comment
  23. * {String} GN ЧЧ Game name
  24. * {String} ON ЧЧ Opening
  25. * {String} OT ЧЧ Overtime
  26. * {String} PB ЧЧ Player Black
  27. * {String} PC ЧЧ Place
  28. * {String} PW ЧЧ Player White
  29. * {String} RE ЧЧ Result
  30. * {String} RO ЧЧ Round
  31. * {String} RU ЧЧ Rules
  32. * {String} SO ЧЧ Source
  33. * {String} TM ЧЧ Timelimit
  34. * {String} US ЧЧ User
  35. * {String} WR ЧЧ White rank
  36. * {String} WT ЧЧ White team
  37. * {String} Cur_C ЧЧ Comment
  38. * METHODS
  39. * {String} Show ЧЧ возвращает информацию о партии
  40. * INPUTS
  41. * {Integer} Symbol ЧЧ номер отображаемого символа
  42. * {Char} Type ЧЧ тип линейки
  43. * AUTHOR
  44. * Dolu mailto:dolu.bl@gmail.com
  45. *********/
  46. function TGame()
  47. {
  48. this.SGFMoveIndex = 0;
  49. this.WCaptured = 0;
  50. this.BCaptured = 0;
  51. this.BlackMove = true;
  52. this.Cur_C = null;
  53. this.AN = null;
  54. this.BR = null;
  55. this.BT = null;
  56. this.CP = null;
  57. this.DT = null;
  58. this.EV = null;
  59. this.GC = null;
  60. this.GN = null;
  61. this.ON = null;
  62. this.OT = null;
  63. this.PB = null;
  64. this.PC = null;
  65. this.PW = null;
  66. this.RE = null;
  67. this.RO = null;
  68. this.RU = null;
  69. this.SO = null;
  70. this.TM = null;
  71. this.US = null;
  72. this.WR = null;
  73. this.WT = null;
  74. /****m* SmallGoEditor/TGame.Show
  75. * NAME
  76. * Show Ч возвращает информацию о партии
  77. * FUNCTION
  78. * Ётот метод формирует и возвращает HTML код с информацией о партии.
  79. * INPUTS
  80. * -
  81. * RESULT
  82. * {String} ЧЧ HTML код с информацией о партии
  83. * SOURCE
  84. */
  85. this.Show = function()
  86. {
  87. var result = "";
  88. // выводим чей ход
  89. result += "<tr>";
  90. result += "<td>’од:</td>";
  91. if (this.BlackMove)
  92. {
  93. result += "<td>чЄрных</td>"
  94. }
  95. else
  96. {
  97. result += "<td>белых</td>"
  98. };
  99. result += "</tr>";
  100. // SGF ходы
  101. result += "<tr>";
  102. result += "<td>Ќомер хода в SGF:</td>";
  103. result += "<td>" + this.SGFMoveIndex + "</td>"
  104. result += "</tr>";
  105. // выводим колличество пленных камней
  106. result += "<tr>";
  107. result += "<td>„Єрных сн€то:</td>";
  108. result += "<td>" + this.BCaptured + "</td>"
  109. result += "</tr>";
  110. result += "<tr>";
  111. result += "<td>Ѕелых сн€то:</td>";
  112. result += "<td>" + this.WCaptured + "</td>"
  113. result += "</tr>";
  114. // вывод коментариев
  115. if (this.Cur_C != null)
  116. {
  117. result += "<tr><td valign='top'>Comments:</td><td><textarea class='Options' id='CommentArea' rows=10 cols=45>" + this.Cur_C + "</textarea></td></tr>";
  118. }
  119. else
  120. {
  121. result += "<tr><td valign='top'>Comments:</td><td><textarea class='Options' id='CommentArea' rows=10 cols=45></textarea></td></tr>";
  122. };
  123. // вывод SGF данных
  124. if (this.GN != null) {result += "<tr><td>Game name:</td><td>" + this.GN + "</td></tr>";};
  125. if (this.GC != null) {result += "<tr><td>Game comment:</td><td>" + this.GC + "</td></tr>";};
  126. if (this.AN != null) {result += "<tr><td>Annotation:</td><td>" + this.AN + "</td></tr>";};
  127. if (this.DT != null) {result += "<tr><td>Date:</td><td>" + this.DT + "</td></tr>";};
  128. if (this.CP != null) {result += "<tr><td>Copyright:</td><td>" + this.CP + "</td></tr>";};
  129. if (this.PB != null) {result += "<tr><td>Player Black:</td><td>" + this.PB + "</td></tr>";};
  130. if (this.BR != null) {result += "<tr><td>Black rank:</td><td>" + this.BR + "</td></tr>";};
  131. if (this.BT != null) {result += "<tr><td>Black team:</td><td>" + this.BT + "</td></tr>";};
  132. if (this.PW != null) {result += "<tr><td>Player White:</td><td>" + this.PW + "</td></tr>";};
  133. if (this.WR != null) {result += "<tr><td>White rank:</td><td>" + this.WR + "</td></tr>";};
  134. if (this.WT != null) {result += "<tr><td>White team:</td><td>" + this.WT + "</td></tr>";};
  135. if (this.RE != null) {result += "<tr><td>Result:</td><td>" + this.RE + "</td></tr>";};
  136. if (this.TM != null) {result += "<tr><td>Timelimit:</td><td>" + this.TM + "</td></tr>";};
  137. if (this.EV != null) {result += "<tr><td>Event:</td><td>" + this.EV + "</td></tr>";};
  138. if (this.ON != null) {result += "<tr><td>Opening:</td><td>" + this.ON + "</td></tr>";};
  139. if (this.OT != null) {result += "<tr><td>Overtime:</td><td>" + this.OT + "</td></tr>";};
  140. if (this.PC != null) {result += "<tr><td>Place:</td><td>" + this.PC + "</td></tr>";};
  141. if (this.RO != null) {result += "<tr><td>Round:</td><td>" + this.RO + "</td></tr>";};
  142. if (this.RU != null) {result += "<tr><td>Rules:</td><td>" + this.RU + "</td></tr>";};
  143. if (this.SO != null) {result += "<tr><td>Source:</td><td>" + this.SO + "</td></tr>";};
  144. if (this.US != null) {result += "<tr><td>User:</td><td>" + this.US + "</td></tr>";};
  145. return result;
  146. };
  147. /*********/
  148. };