1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
function _sasite(after, before, koma, option, comment) { if (option == undefined) option = 0; if (comment == undefined) comment = ""; this.after = after; this.before = before; this.koma = koma; this.option = option; this.comment = comment; } // 空の指し手 _sasite.get_empty_sasite = function() { return new _sasite(-1, -1, -1); } _sasite.prototype.is_empty_sasite = function() { return this.koma == -1; } _sasite.prototype.equals = function(other) { if (this == other) return true; return this.after == other.after && this.before == other.before && this.koma == other.koma && (this.option & _opt.NARI) == (other.option & _opt.NARI); } _sasite.prototype.to_string = function() { if (this.is_empty_sasite()) return ""; var koma = this.koma; var s; s = koma < 16 ? _str.SENTE : _str.GOTE; var pos = this.after; s += (pos % 9 + 1) + _str.KANSUUJI[Math.floor(pos / 9) + 1]; var option = this.option; s += _util.opt_moji(option & _opt.DOU); var moji = _koma.MOJI[koma % 16]; if (moji == "") return ""; s += moji; for (var i = _opt.SUGU; i >= _opt.NARI; i >>= 1) if (i != _opt.DOU) s += _util.opt_moji(option & i); return s; }