• R/O
  • SSH
  • HTTPS

thief: コミット


コミットメタ情報

リビジョン38 (tree)
日時2012-01-21 23:36:05
作者seussnu

ログメッセージ

0.0.8-alpha3
・ キーの入力待ち処理にミスがあったので修正

変更サマリ

差分

--- thief.js (revision 37)
+++ thief.js (revision 38)
@@ -363,7 +363,7 @@
363363 }
364364 THIEF.html.addDebugMessage('...' + obj.get(THIEF.PROP.displayName) + 'を' + this.get(THIEF.PROP.displayName) + 'のインベントリ座標[' + objX + ', ' + objY + ']から除外完了。');
365365
366- if(this.type === 'level' && obj.active){
366+ if (this.type === 'level' && obj.active) {
367367 THIEF.html.addDebugMessage('アクティブリストから除外');
368368 this[THIEF.PROP.actObjectList].remove(obj);
369369 }
@@ -421,7 +421,7 @@
421421 this.inventory[i][j].push(obj);
422422 THIEF.html.addDebugMessage('[' + i + ', ' + j + ']に' + obj.get(THIEF.PROP.alphabet) + 'として追加');
423423
424- if(this.type === 'level' && obj.active){
424+ if (this.type === 'level' && obj.active) {
425425 THIEF.html.addDebugMessage('アクティブリストに追加');
426426 this[THIEF.PROP.actObjectList].push(obj);
427427 }
@@ -581,7 +581,7 @@
581581 THIEF.html.addDebugMessage('死亡処理を開始...');
582582 THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.killBy, this.get(THIEF.PROP.displayName), obj.get(THIEF.PROP.displayName)));
583583 THIEF.global.actLV.removeFromInventory(this);
584- this.next = function() {
584+ this.action = function() {
585585 return true
586586 };
587587 THIEF.html.addDebugMessage('...死亡処理を完了。')
@@ -863,19 +863,14 @@
863863 };
864864
865865 THIEF.func.method.inputWait = function () {
866- this.next = THIEF.func.method.manual;
866+ this.action = THIEF.func.method.action;
867867 THIEF.html.addDebugMessage('入力待ち');
868868 THIEF.html.addMessage(); // 改行
869869 return false;
870870 };
871871
872-// 基本は AI 処理とする
873-THIEF.func.method.next = function() {
874- return this.cpu();
875-};
872+THIEF.func.method.getObjectList = function(compObj, recursive) {
876873
877-THIEF.func.method.getObjectList = function(compObj, recursive){
878-
879874 var list = [];
880875 if (typeof this.inventory !== "undefined") {
881876 var width = this.get(THIEF.PROP.inventoryWidth);
@@ -892,8 +887,8 @@
892887 for (var z = 0; z < depth; z++) {
893888
894889 var result = true;
895- for(var name in compObj){
896- if(this.inventory[x][y][z][name] === compObj[name]){
890+ for (var name in compObj) {
891+ if (this.inventory[x][y][z][name] === compObj[name]) {
897892
898893 } else {
899894 result = false;
@@ -900,10 +895,10 @@
900895 break;
901896 }
902897 }
903- if(result){
898+ if (result) {
904899 list.push(this.inventory[x][y][z]);
905900 }
906- if(recursive){
901+ if (recursive) {
907902 // 持ち物の持ち物も検索
908903 list = list.concat(this.inventory[x][y][z].getObjectList(compObj, recursive));
909904 }
@@ -915,21 +910,21 @@
915910 return list;
916911 };
917912
918-THIEF.func.method.execActiveObjects = function(){
913+THIEF.func.method.execActiveObjects = function() {
919914 var result = true;
920915
921916 if (this[THIEF.PROP.actObjectList]) {
922917 // アクティブリストを降順にソート
923- this[THIEF.PROP.actObjectList].sort(function(a, b){
918+ this[THIEF.PROP.actObjectList].sort(function(a, b) {
924919 return b.ct - a.ct;
925920 });
926-
927- while(this[THIEF.PROP.actObjectList][0] && this[THIEF.PROP.actObjectList][0].ct >= 100){
921+
922+ while (this[THIEF.PROP.actObjectList][0] && this[THIEF.PROP.actObjectList][0].ct >= 100) {
928923 var obj = this[THIEF.PROP.actObjectList][0];
929- if(obj.ct >= 100){
924+ if (obj.ct >= 100) {
930925 THIEF.html.addDebugMessage(obj.get(THIEF.PROP.displayName) + ' の処理を開始...');
931926 result = obj.action();
932- if(result){
927+ if (result) {
933928 THIEF.html.addDebugMessage('...処理を完了');
934929 } else {
935930 THIEF.html.addDebugMessage('...' + obj.get(THIEF.PROP.displayName) + ' は処理が完了しなかった。');
@@ -938,7 +933,7 @@
938933 }
939934
940935 // アクティブリストを降順にソート
941- this[THIEF.PROP.actObjectList].sort(function(a, b){
936+ this[THIEF.PROP.actObjectList].sort(function(a, b) {
942937 return b.ct - a.ct;
943938 });
944939 }
@@ -949,7 +944,13 @@
949944 THIEF.func.method.action = function() {
950945
951946 THIEF.html.addDebugMessage(this.get(THIEF.PROP.displayName) + ' の行動を開始...');
952- var result = this.next();
947+ var result;
948+ if (this.isManual) {
949+ result = this.manual();
950+ } else {
951+ result = this.cpu();
952+ }
953+
953954 THIEF.html.addDebugMessage('... ' + this.get(THIEF.PROP.displayName) + ' の行動を完了。 (result = ' + result + ')');
954955
955956 return result;
@@ -973,7 +974,7 @@
973974 var finish;
974975 var code = THIEF.global.keycode;
975976
976- if (code === 0) {
977+ if (code === 0 || isNaN(code)) {
977978 finish = false;
978979 THIEF.html.addDebugMessage('無効なキー入力のため、何の処理もしない。')
979980 } else {
@@ -996,7 +997,7 @@
996997 THIEF.html.addDebugMessage('...' + String.fromCharCode(code) + '(' + code + ')の入力に対する処理を完了。(return : ' + finish + ')');
997998
998999 if (finish) {
999- this.next = THIEF.func.method.inputWait;
1000+ this.action = THIEF.func.method.inputWait;
10001001 }
10011002 }
10021003
@@ -1136,6 +1137,7 @@
11361137 };
11371138
11381139 THIEF.func.command.rest = function() {
1140+ this.ct = 99;
11391141 return true;
11401142 };
11411143
@@ -1564,6 +1566,7 @@
15641566 THIEF.global.adventurer.inventoryWidth = 10;
15651567 THIEF.global.adventurer.inventoryCellSize = 1;
15661568 THIEF.global.adventurer.ct = 100;
1569+ THIEF.global.adventurer.isManual = true;
15671570 var point = THIEF.global.actLV.getInventoryRandomFreeSpace(THIEF.global.adventurer);
15681571 THIEF.global.actLV.addToInventory(THIEF.global.adventurer, point.x, point.y);
15691572
@@ -1589,24 +1592,23 @@
15891592 //noinspection DynamicallyGeneratedCodeJS
15901593 setTimeout(THIEF.util.next, 100);
15911594 }
1592-
1593- // 毎ターンの終了時、または中断時(ユーザの入力待ち)に、画面の更新を行う
1594- //THIEF.html.addMessage();
1595-
15961595 };
15971596
15981597 THIEF.util.step = function () {
15991598 var completion = true;
16001599 var compCounter = 15;
1600+ //var lock = false;
16011601
16021602 return function () {
1603+ //if(!lock){
1604+ //lock = true;
16031605 if (completion) {
16041606 THIEF.global.turn++;
16051607 THIEF.html.addDebugMessage('<em>ターン:' + THIEF.global.turn + ' を開始</em>...');
16061608 THIEF.html.addDebugMessage('CT の増減を開始...');
1607- for(var i=0; i<THIEF.global.actLV[THIEF.PROP.actObjectList].length; i++){
1609+ for (var i = 0; i < THIEF.global.actLV[THIEF.PROP.actObjectList].length; i++) {
16081610 var obj = THIEF.global.actLV[THIEF.PROP.actObjectList][i];
1609- if(obj.dex){
1611+ if (obj.dex) {
16101612 obj.ct += obj.dex * 4;
16111613 } else {
16121614 obj.ct = 100;
@@ -1644,7 +1646,8 @@
16441646 THIEF.html.addDebugMessage('...ターン:' + THIEF.global.turn + ' を中断。(ユーザからの入力待ち)');
16451647 THIEF.html.addDebugMessage();
16461648 }
1647-
1649+ //}
1650+ //lock = false;
16481651 return completion;
16491652 };
16501653 }();
旧リポジトリブラウザで表示