PageRenderTime 123ms CodeModel.GetById 40ms app.highlight 42ms RepoModel.GetById 38ms app.codeStats 1ms

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