//マップ情報クラス //2002/06/20 18:12 by Tsukasa Jitoh function TMapInf() { this.maps = new Array(); this.currentIdx = -1; this.MapRollFlag = true; //マップ追加 this.addMap = TMapInf_addMap; function TMapInf_addMap(info, table, setsumon, successPtn, kaito) { if(this.maps.length == 0) this.moveFirst(); return this.maps[this.maps.length] = new TMapInfData(info, table, setsumon, successPtn, kaito); } //指定マップ取得 this.getMap = TMapInf_getMap; function TMapInf_getMap(index) { if(index === null) return this.getMap(this.currentIdx); else return (index < 0 || index >= this.maps.length)? null: this.maps[index]; } //次のマップ取得 this.getNext = TMapInf_getNext; function TMapInf_getNext() { return this.getMap(this.moveNext()); } //前のマップ取得 this.getPrev = TMapInf_getPrev; function TMapInf_getPrev() { return this.getMap(this.movePrev()); } //マップロール指定 this.setMapRoll = TMapInf_setMapRoll; function TMapInf_setMapRoll(flag) { this.MapRollFlag = flag; } //最初のマップへ移動 this.moveFirst = TMapInf_moveFirst; function TMapInf_moveFirst() { return this.currentIdx = (this.maps.length > 0? 0: -1); } //最後のマップへ移動 this.moveLast = TMapInf_moveLast; function TMapInf_moveLast() { return this.currentIdx = this.maps.length - 1; } //次のマップへ移動 this.moveNext = TMapInf_moveNext; function TMapInf_moveNext() { this.currentIdx++; if(this.currentIdx >= this.maps.length) { if(this.MapRollFlag) this.moveFirst(); else this.currentIdx = this.maps.length; } return (this.isEOF()? -1: this.currentIdx); } //前のマップへ移動 this.movePrev = TMapInf_movePrev; function TMapInf_movePrev() { this.currentIdx--; if(this.currentIdx < 0) { if(this.MapRollFlag) this.moveLast(); else this.currentIdx = -1; } return (this.isEOF()? -1: this.currentIdx); } //EOF判定 this.isEOF = TMapInf_isEOF; function TMapInf_isEOF() { return (this.currentIdx < 0 || this.currentIdx >= this.maps.length); } //マップ番号取得 this.getMapNo = TMapInf_getMapNo; function TMapInf_getMapNo() { return this.currentIdx; } //マップレコード function TMapInfData(info, table, setsumon, successPtn, kaito) { //バージョン・作者情報(文字列) this.info = info; //初期マップデータ(2次元配列) // 駒 = 0:巣, 1:水, 2:餌, 10:竜1, 20:竜2, 30:竜3, 40:竜4, 50:竜5, 60:竜6 this.m = table; //設問(string) this.setsumon = setsumon; //終了条件 this.successPtn = successPtn; //回答例(2次元配列) // (駒, y, x) this.kaito = kaito; } }