• R/O
  • SSH
  • HTTPS

thief: コミット


コミットメタ情報

リビジョン40 (tree)
日時2012-12-20 23:51:46
作者seussnu

ログメッセージ

0.0.8-alpha6
・ JSHintベースに諸々修正

変更サマリ

差分

--- thief.js (revision 39)
+++ thief.js (revision 40)
@@ -31,7 +31,7 @@
3131
3232 var THIEF = {
3333 conf : {
34- id : 'Thief', // was used "HTML's id", and "System tag".
34+ id : 'Thief', // was used "id of HTML", and "System tag".
3535 textColor : '#FFFFFF',
3636 emTextColor : '#FF0000',
3737 bgColor : '#000000',
@@ -39,7 +39,7 @@
3939 gridStyle : '0px none #888888', // css td border options
4040 mapWidth : 60,
4141 mapHeight : 20,
42- languagePriolity : ['AUTO', 'en', 'ja'],
42+ languagePriority : ['AUTO', 'en', 'ja'],
4343 statusPosition : 'bottom', // top or bottom
4444 statusLineFormat : [
4545 '${THIEF.global.actDG.%get@name%}:${THIEF.global.actDG.nowLV}' +
@@ -61,11 +61,11 @@
6161 messagePosition : 'top', // top or bottom
6262 messageLines : 3,
6363 messageHistorySize : 256,
64- // infomationOverlap : true,
64+ // informationOverlap : true,
6565 mainWindowPosition : 'left', // css float option (left, right, none)
6666 msgOverflow : 'hidden', // css overflow option (visible, scroll, hidden, auto)
6767 itemSort : ['$', '"', ']', '[', '%', '!', '?', '+', '=', '/', '(', ')', '*' ],
68- debugmode : true
68+ debugMode : true
6969 },
7070
7171 global : {
@@ -72,18 +72,18 @@
7272 actLV : null,
7373 actDG : null,
7474 turn : 0,
75- keycode : NaN,
75+ keyCode : NaN,
7676 hist : [],
7777 adventurer : null, // Player
7878 size : {
79- Window : {width : Number.NaN, height : Number.NaN},
80- Main : {width : Number.NaN, height : Number.NaN}, // Input, Message, Map, Status
81- Input : {width : Number.NaN, height : Number.NaN}, // 入力欄
82- Message : {width : Number.NaN, height : Number.NaN}, // メッセージ欄(入力上部)
83- Map : {width : Number.NaN, height : Number.NaN}, // マップ
84- Status : {width : Number.NaN, height : Number.NaN}, // ステータス
85- Infomation : {width : Number.NaN, height : Number.NaN}, // 情報出力(インベントリの内容など)
86- Debug : {width : Number.NaN, height : Number.NaN} // デバッグ情報
79+ Window : {width : -1, height : -1},
80+ Main : {width : -1, height : -1}, // Input, Message, Map, Status
81+ Input : {width : -1, height : -1}, // 入力欄
82+ Message : {width : -1, height : -1}, // メッセージ欄(入力上部)
83+ Map : {width : -1, height : -1}, // マップ
84+ Status : {width : -1, height : -1}, // ステータス
85+ Information : {width : -1, height : -1}, // 情報出力(インベントリの内容など)
86+ Debug : {width : -1, height : -1} // デバッグ情報
8787 }
8888 },
8989
@@ -111,13 +111,58 @@
111111 LT : '<'.charCodeAt(0),
112112 GT : '>'.charCodeAt(0),
113113 Asterisk : '*'.charCodeAt(0),
114- A : 65, B : 66, C : 67, D : 68, E : 69, F : 70, G : 71, H : 72, I : 73,
115- J : 74, K : 75, L : 76, M : 77, N : 78, O : 79, P : 80, Q : 81, R : 82,
116- S : 83, T : 84, U : 85, V : 86, W : 87, X : 88, Y : 89, Z : 90,
117- a : 97, b : 98, c : 99, d : 100, e : 101, f : 102, g : 103, h : 104,
118- i : 105, j : 106, k : 107, l : 108, m : 109, n : 110, o : 111, p : 112,
119- q : 113, r : 114, s : 115, t : 116, u : 117, v : 118, w : 119, x : 120,
120- y : 121, z : 122,
114+ A : 65,
115+ B : 66,
116+ C : 67,
117+ D : 68,
118+ E : 69,
119+ F : 70,
120+ G : 71,
121+ H : 72,
122+ I : 73,
123+ J : 74,
124+ K : 75,
125+ L : 76,
126+ M : 77,
127+ N : 78,
128+ O : 79,
129+ P : 80,
130+ Q : 81,
131+ R : 82,
132+ S : 83,
133+ T : 84,
134+ U : 85,
135+ V : 86,
136+ W : 87,
137+ X : 88,
138+ Y : 89,
139+ Z : 90,
140+ a : 97,
141+ b : 98,
142+ c : 99,
143+ d : 100,
144+ e : 101,
145+ f : 102,
146+ g : 103,
147+ h : 104,
148+ i : 105,
149+ j : 106,
150+ k : 107,
151+ l : 108,
152+ m : 109,
153+ n : 110,
154+ o : 111,
155+ p : 112,
156+ q : 113,
157+ r : 114,
158+ s : 115,
159+ t : 116,
160+ u : 117,
161+ v : 118,
162+ w : 119,
163+ x : 120,
164+ y : 121,
165+ z : 122,
121166 // [ = WinKey = 91
122167 // \ = WinKey = 92
123168 F1 : 112, // = p
@@ -155,7 +200,7 @@
155200 actObjectList : 'actObjectList',
156201 isActive : 'isActive',
157202 ct : 'ct',
158- maxct : 'maxct',
203+ maxCT : 'maxCT',
159204 dex : 'dex',
160205 hp : 'hp',
161206 attack : 'attack',
@@ -174,7 +219,7 @@
174219 //
175220
176221 //noinspection JSUnusedGlobalSymbols,JSValidateTypes
177-window.onload = function (onload) {
222+window.onload = (function (onload) {
178223 return function () {
179224 if (!!onload) {
180225 onload();
@@ -181,10 +226,10 @@
181226 }
182227 THIEF.util.init();
183228 };
184-}(window.onload);
229+}(window.onload));
185230
186231 //noinspection JSUnusedGlobalSymbols
187-window.onresize = function (onresize) {
232+window.onresize = (function (onresize) {
188233 return function () {
189234
190235 if (!!onresize) {
@@ -196,13 +241,9 @@
196241 THIEF.global.size.Window.height = window.innerHeight;
197242 } else {
198243 THIEF.global.size.Window.width =
199- document.documentElement.clientWidth
200- || document.body.clientWidth
201- || document.body.scrollWidth;
244+ document.documentElement.clientWidth || document.body.clientWidth || document.body.scrollWidth;
202245 THIEF.global.size.Window.height =
203- document.documentElement.clientHeight
204- || document.body.clientHeight
205- || document.body.scrollHeight;
246+ document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight;
206247 }
207248
208249 /*
@@ -222,20 +263,20 @@
222263 THIEF.global.size.Debug = document.getElementById('Debug').offsetHeight;
223264 */
224265 };
225-}(window.onresize);
266+}(window.onresize));
226267
227268
228269 //noinspection JSUnusedGlobalSymbols
229-document.onkeypress = function (onkeypress) {
270+document.onkeypress = (function (onkeypress) {
230271 return function (event) {
231272 if (!!onkeypress) {
232273 onkeypress(event);
233274 }
234- THIEF.global.keycode = THIEF.util.getKeyCode(event);
275+ THIEF.global.keyCode = THIEF.util.getKeyCode(event);
235276 THIEF.util.next();
236- THIEF.global.keycode = 0;
277+ THIEF.global.keyCode = 0;
237278 };
238-}(document.onkeypress);
279+}(document.onkeypress));
239280
240281 if (!Object.create) {
241282 Object.create = function (o) {
@@ -247,16 +288,18 @@
247288 }
248289
249290 if (!Math.sign) {
291+ var result;
250292 Math.sign = function (num) {
251293 if (num > 0) {
252- return 1;
294+ result = 1;
253295 } else {
254296 if (num < 0) {
255- return -1;
297+ result = -1;
256298 } else {
257- return 0;
299+ result = 0;
258300 }
259301 }
302+ return result;
260303 };
261304 }
262305
@@ -267,26 +310,20 @@
267310 val += Math.round(Math.random() * sides + 0.5);
268311 }
269312 return val;
270- }
313+ };
271314 }
272315
273316 if (!Array.prototype.remove) {
274317 Array.prototype.remove = function (o) {
275- var len = this.length;
276318 var result = false;
277- for (var i = 0; i < len; i++) {
278- if (!result && this[i] === o) {
319+ for (var i = 0; i < this.length; i++) {
320+ if ( this[i] === o ) {
321+ this.splice(i, 1);
322+ //noinspection AssignmentToForLoopParameterJS
323+ i--;
279324 result = true;
280- delete this[i];
281325 }
282- if (result) {
283- // shifting
284- this[i] = this[i + 1];
285- }
286326 }
287- if (result) {
288- this.length = len - 1;
289- }
290327 return result;
291328 };
292329 }
@@ -412,7 +449,7 @@
412449 } else {
413450 obj[THIEF.PROP.alphabet] = alp;
414451 }
415- THIEF.html.addDebugMessage('新たに ' + alp + ' を割り当てた。')
452+ THIEF.html.addDebugMessage('新たに ' + alp + ' を割り当てた。');
416453 }
417454 THIEF.html.addDebugMessage('...アルファベットの割り当て処理完了。');
418455 }
@@ -482,7 +519,7 @@
482519
483520 var free;
484521
485- outloop : for (var ancY = startY; ancY < invHeight; ancY++) {
522+ outLoop : for (var ancY = startY; ancY < invHeight; ancY++) {
486523 //alert(ancY + '行目を処理...');
487524 for (var ancX = startX; ancX < invWidth; ancX++) {
488525 //alert(ancX + ', ' + ancY);
@@ -490,7 +527,7 @@
490527
491528 //THIEF.html.addDebugMessage(ancX + ', ' + ancY + 'を確認...');
492529
493- inloop : for (var targetY = ancY; targetY < ancY + objInvShapeHeight; targetY++) {
530+ inLoop : for (var targetY = ancY; targetY < ancY + objInvShapeHeight; targetY++) {
494531 for (var targetX = ancX + objInvShapeWight - 1; targetX >= ancX; targetX--) {
495532 if (this.inventory && this.inventory[targetX] && this.inventory[targetX][targetY]) {
496533 if (this.inventory[targetX][targetY].length <= invDepth) {
@@ -505,13 +542,13 @@
505542 free = false;
506543 ancX = targetX;
507544 //THIEF.html.addDebugMessage(targetX + ', ' + targetY + 'にある' + lastObj.get(THIEF.PARAM.name) + 'には重ねられない');
508- break inloop;
545+ break inLoop;
509546 }
510547 } else {
511548 free = false;
512549 ancX = targetX;
513550 //THIEF.html.addDebugMessage(targetX + ', ' + targetY + ' は高さが足りないからダメ');
514- break inloop;
551+ break inLoop;
515552 }
516553
517554
@@ -528,10 +565,10 @@
528565 width : objInvShapeWight,
529566 height : objInvShapeHeight
530567 };
531- break outloop;
568+ break outLoop;
532569 }
533570 if (once) {
534- break outloop;
571+ break outLoop;
535572 }
536573 }
537574 }
@@ -582,9 +619,9 @@
582619 THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.killBy, this.get(THIEF.PROP.displayName), obj.get(THIEF.PROP.displayName)));
583620 THIEF.global.actLV.removeFromInventory(this);
584621 this.action = function () {
585- return true
622+ return true;
586623 };
587- THIEF.html.addDebugMessage('...死亡処理を完了。')
624+ THIEF.html.addDebugMessage('...死亡処理を完了。');
588625 }
589626
590627 THIEF.html.addDebugMessage('...攻撃処理を完了。');
@@ -716,7 +753,7 @@
716753 // 選択用関数返却
717754 return function () {
718755 var finish = false;
719- switch (THIEF.global.keycode) {
756+ switch (THIEF.global.keyCode) {
720757
721758 case 0:
722759 break;
@@ -751,8 +788,8 @@
751788 break;
752789
753790 default:
754- var item = targets[String.fromCharCode(THIEF.global.keycode)];
755- var itemID = THIEF.conf.id + '_' + String.fromCharCode(THIEF.global.keycode);
791+ var item = targets[String.fromCharCode(THIEF.global.keyCode)];
792+ var itemID = THIEF.conf.id + '_' + String.fromCharCode(THIEF.global.keyCode);
756793 if (typeof item !== 'undefined') {
757794 if (document.getElementById(itemID).innerHTML === '&nbsp;-&nbsp;') {
758795 document.getElementById(itemID).innerHTML = '&nbsp;+&nbsp;';
@@ -772,7 +809,7 @@
772809 var result = false;
773810 if (finish) {
774811 // 画面クリア
775- THIEF.html.clearInfomation('');
812+ THIEF.html.clearInfomation();
776813
777814 // アクションを元に戻す
778815 this.action = THIEF.func.method.action;
@@ -915,10 +952,8 @@
915952
916953 if (this[THIEF.PROP.actObjectList]) {
917954 // アクティブリストを降順にソート
918- this[THIEF.PROP.actObjectList].sort(function (a, b) {
919- return b.ct - a.ct;
920- });
921-
955+ var sortOrder = function (a, b) { return b.ct - a.ct; };
956+ this[THIEF.PROP.actObjectList].sort(sortOrder);
922957 while (this[THIEF.PROP.actObjectList][0] && this[THIEF.PROP.actObjectList][0].ct >= 100) {
923958 var obj = this[THIEF.PROP.actObjectList][0];
924959 if (obj.ct >= 100) {
@@ -933,9 +968,7 @@
933968 }
934969
935970 // アクティブリストを降順にソート
936- this[THIEF.PROP.actObjectList].sort(function (a, b) {
937- return b.ct - a.ct;
938- });
971+ this[THIEF.PROP.actObjectList].sort(sortOrder);
939972 }
940973 }
941974 return result;
@@ -972,11 +1005,11 @@
9721005 THIEF.func.method.manual = function () {
9731006
9741007 var finish;
975- var code = THIEF.global.keycode;
1008+ var code = THIEF.global.keyCode;
9761009
9771010 if (code === 0 || isNaN(code)) {
9781011 finish = false;
979- THIEF.html.addDebugMessage('無効なキー入力のため、何の処理もしない。')
1012+ THIEF.html.addDebugMessage('無効なキー入力のため、何の処理もしない。');
9801013 } else {
9811014 THIEF.html.addDebugMessage(String.fromCharCode(code) + '(' + code + ')の入力に対する処理を開始...');
9821015
@@ -1312,7 +1345,7 @@
13121345
13131346 this.action = function () {
13141347 var finish = false;
1315- switch (THIEF.global.keycode) {
1348+ switch (THIEF.global.keyCode) {
13161349
13171350 case key.Esc:
13181351 finish = true;
@@ -1327,6 +1360,7 @@
13271360 case key.LT:
13281361 index--;
13291362 if (index < 0) {
1363+ //noinspection ReuseOfLocalVariableJS
13301364 index = THIEF.global.hist.length - 1;
13311365 }
13321366 break;
@@ -1341,6 +1375,7 @@
13411375 case key.GT:
13421376 index++;
13431377 if (index >= THIEF.global.hist.length) {
1378+ //noinspection ReuseOfLocalVariableJS
13441379 index = 0;
13451380 }
13461381 break;
@@ -1351,7 +1386,7 @@
13511386
13521387 if (finish) {
13531388 // 画面クリア
1354- THIEF.html.clearInfomation('');
1389+ THIEF.html.clearInfomation();
13551390 // アクションを元に戻す
13561391 this.action = THIEF.func.method.action;
13571392 } else {
@@ -1396,25 +1431,25 @@
13961431 this.action = function () {
13971432 var finish = false;
13981433 var update = false;
1399- if ((THIEF.KEY.a <= THIEF.global.keycode && THIEF.global.keycode <= THIEF.KEY.z) || (THIEF.KEY.A <= THIEF.global.keycode && THIEF.global.keycode <= THIEF.KEY.Z)) {
1400- line += String.fromCharCode(THIEF.global.keycode);
1434+ if ((THIEF.KEY.a <= THIEF.global.keyCode && THIEF.global.keyCode <= THIEF.KEY.z) || (THIEF.KEY.A <= THIEF.global.keyCode && THIEF.global.keyCode <= THIEF.KEY.Z)) {
1435+ line += String.fromCharCode(THIEF.global.keyCode);
14011436 update = true;
1402- } else if (THIEF.global.keycode === THIEF.KEY.Space) {
1437+ } else if (THIEF.global.keyCode === THIEF.KEY.Space) {
14031438 line += ' ';
14041439 update = true;
1405- } else if (THIEF.global.keycode === THIEF.KEY.Backspace) {
1440+ } else if (THIEF.global.keyCode === THIEF.KEY.Backspace) {
14061441 line = line.slice(0, line.length - 1);
14071442 update = true;
1408- } else if (THIEF.global.keycode === THIEF.KEY.Esc) {
1443+ } else if (THIEF.global.keyCode === THIEF.KEY.Esc) {
14091444 THIEF.html.setInput('&nbsp;');
14101445 THIEF.html.clearInfomation();
14111446 this.action = THIEF.func.method.action;
1412- } else if (THIEF.global.keycode === THIEF.KEY.Enter) {
1447+ } else if (THIEF.global.keyCode === THIEF.KEY.Enter) {
14131448 THIEF.html.setInput('&nbsp;');
14141449 THIEF.html.clearInfomation();
14151450 this.action = THIEF.func.method.action;
14161451 if (typeof THIEF.Data.Keymap[target].cmd === 'function') {
1417- THIEF.global.keycode = 0;
1452+ THIEF.global.keyCode = 0;
14181453 finish = THIEF.Data.Keymap[target].cmd.call(this);
14191454 } else {
14201455 THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.commandNotFound, line));
@@ -1435,6 +1470,7 @@
14351470 THIEF.html.addInput('<span style="color:' + THIEF.conf.grayColor + '">' + target.slice(line.length, target.length) + '</span>');
14361471 } else {
14371472 THIEF.html.addInput('&brvbar;');
1473+ //noinspection ReuseOfLocalVariableJS
14381474 target = '';
14391475 }
14401476 }
@@ -1625,6 +1661,7 @@
16251661 }
16261662
16271663 THIEF.html.addDebugMessage('アクティブになったオブジェクトの処理を実施...');
1664+ //noinspection ReuseOfLocalVariableJS
16281665 completion = THIEF.global.actLV.execActiveObjects();
16291666 THIEF.html.addDebugMessage('...アクティブになったオブジェクトの処理を完了');
16301667
@@ -1631,12 +1668,15 @@
16311668 THIEF.util.updateStatus();
16321669
16331670 if (compCounter < 0) {
1671+ //noinspection ReuseOfLocalVariableJS
16341672 compCounter = 15;
1673+ //noinspection ReuseOfLocalVariableJS
16351674 completion = false;
1636- THIEF.html.addDebugMessage('無限ループにならないように、15回以上ループするなら強制的にブレイク。')
1675+ THIEF.html.addDebugMessage('無限ループにならないように、15回以上ループするなら強制的にブレイク。');
16371676 } else if (completion) {
16381677 compCounter--;
16391678 } else {
1679+ //noinspection ReuseOfLocalVariableJS
16401680 compCounter = 15;
16411681 }
16421682
@@ -1677,9 +1717,9 @@
16771717 if (document.all) {
16781718 code = event.keyCode;
16791719 } else if (document.getElementById) {
1680- code = parseInt((parseInt(e.keyCode) === 0) ? e.charCode : e.keyCode);
1720+ code = parseInt((parseInt(e.keyCode, 10) === 0) ? e.charCode : e.keyCode, 10);
16811721 } else { // document.layers
1682- code = parseInt(e.which.toString());
1722+ code = parseInt(e.which.toString(), 10);
16831723 }
16841724
16851725
@@ -1769,6 +1809,7 @@
17691809 //THIEF.html.addDebugMessage('オブジェクトの生成処理を開始...');
17701810 //THIEF.html.addDebugMessage('マスターの有無を確認...');
17711811
1812+ var propName;
17721813 if (typeof obj !== 'undefined' && typeof obj.uniqNumber === 'undefined') {
17731814 THIEF.html.addDebugMessage('要求オブジェクトのマスタが存在しないので作成開始...');
17741815
@@ -1789,7 +1830,6 @@
17891830 THIEF.html.addDebugMessage('this,' + stack.toString() + '.');
17901831
17911832 // 以下の順番で作成します
1792- var propName;
17931833 while (stack.length > 0) {
17941834 inhPrev = inh || '$';
17951835 inh = stack.pop();
@@ -1854,6 +1894,7 @@
18541894 THIEF.html.addDebugMessage('...作成完了');
18551895 }
18561896 }
1897+ //noinspection ReuseOfLocalVariableJS
18571898 inhPrev = inh;
18581899
18591900 THIEF.html.addDebugMessage('...作成完了');
@@ -2010,7 +2051,9 @@
20102051 THIEF.html.addDebugMessage('複数のテンプレートがしていされているため逐次的に書式コピー');
20112052 for (var i = 0; i < dun[lvNum].level.length; i++) {
20122053 for (var name in THIEF.Data.Scenario.$Template[dun[lvNum].level[i]]) {
2013- template[name] = THIEF.Data.Scenario.$Template[dun[lvNum].level[i]][name]
2054+ if (THIEF.Data.Scenario.$Template[dun[lvNum].level[i]][name] !== 'undefined'){
2055+ template[name] = THIEF.Data.Scenario.$Template[dun[lvNum].level[i]][name];
2056+ }
20142057 }
20152058 }
20162059 }
@@ -2095,7 +2138,7 @@
20952138 branchWay.nextDun[branchWay.nextLv].branchDun = dun;
20962139 branchWay.nextDun[branchWay.nextLv].branchDir = 'up';
20972140 break;
2098- case 'teleport':
2141+ //case 'teleport':
20992142 default:
21002143 break;
21012144 }
@@ -2103,7 +2146,7 @@
21032146 if (template.branchDirPoint) {
21042147 branchWay.point = template.branchDirPoint;
21052148 } else {
2106- branchWay.point = level.getInventoryRandomFreeSpace(branchWay)
2149+ branchWay.point = level.getInventoryRandomFreeSpace(branchWay);
21072150 }
21082151 branchWay.color = 'red';
21092152 branchWay.isBranch = true;
@@ -2145,16 +2188,18 @@
21452188 var spaceEdges = [
21462189 {x : 1, y : 1}
21472190 ]; // 左上は常にスペースの角のため
2148- var roonCount = 0;
2149- var roop = 0;
2150- var roopLimit = 300; // 300 回くらい試行して駄目ならあきらめる
2151- while (roonCount < maxRooms && roop < roopLimit) {
2152- roop++;
2191+ var loopCounter = 0;
2192+ var loop = 0;
2193+ var loopLimit = 300; // 300 回くらい試行して駄目ならあきらめる
2194+ var ay;
2195+ var ax;
2196+ while (loopCounter < maxRooms && loop < loopLimit) {
2197+ loop++;
21532198
21542199 //アンカーは分割線(通路)の開始位置
21552200 //アンカーを計算(周囲 2(=1*2) マスと、さらに 2 マス(部屋壁の厚み分) は引いている)
2156- var ax = Math.floor((Math.random() * (width - width * 0.1 - 4) ) + width * 0.1 + 2);
2157- var ay = Math.floor((Math.random() * (height - height * 0.1 - 4) ) + height * 0.1 + 2);
2201+ ax = Math.floor((Math.random() * (width - width * 0.1 - 4) ) + width * 0.1 + 2);
2202+ ay = Math.floor((Math.random() * (height - height * 0.1 - 4) ) + height * 0.1 + 2);
21582203
21592204 // アンカーに、既に部屋があればやり直し
21602205 if (map[ax][ay].length !== 0) {
@@ -2212,7 +2257,7 @@
22122257
22132258 // 一般的にマップ全体は横幅の方が長いと仮定している
22142259 // 分割は、最初は縦、次は横の方がなんとなく綺麗になる
2215- if ((roonCount % 2 === 0 && my > mx) || (roonCount % 2 === 1 && my <= mx)) {
2260+ if ((loopCounter % 2 === 0 && my > mx) || (loopCounter % 2 === 1 && my <= mx)) {
22162261 continue;
22172262 }
22182263
@@ -2259,7 +2304,7 @@
22592304 }
22602305 }
22612306 }
2262- roonCount++;
2307+ loopCounter++;
22632308 }
22642309
22652310
@@ -2323,6 +2368,45 @@
23232368
23242369 // 部屋の位置関係を取得し、縦横各1通を生成する
23252370 // 部屋は次の部屋と比較され、最後の部屋は最初の部屋と比較される(孤立する部屋を作らないようにするため)
2371+
2372+ // 通路を作成用関数
2373+ // 二度ドアを作るか、通路に当たったら終了
2374+ var setFloor = function (x, y, vx, vy) {
2375+ var index = 0;
2376+ var wallCounter = 0;
2377+ var diffX;
2378+ var diffY;
2379+ var flr;
2380+ while (true) {
2381+ diffX = index * vx;
2382+ diffY = index * vy;
2383+ flr = map[ax - diffX][ay - diffY].getLast();
2384+ index++;
2385+
2386+ // 名にもないのであればとりあえず通路を作る
2387+ if (typeof flr === 'undefined') {
2388+ map[ax - diffX][ay - diffY].push(THIEF.util.factory(THIEF.Data.Obj.DarkFloor));
2389+ continue;
2390+ }
2391+
2392+ // 壁ならば通路に置換
2393+ if (flr.isBasedOn(THIEF.Data.Obj.NormalWall)) {
2394+ map[ax - diffX][ay - diffY].pop();
2395+ map[ax - diffX][ay - diffY].push(THIEF.util.factory(THIEF.Data.Obj.LitFloor));
2396+ wallCounter++;
2397+ if (wallCounter === 2) {
2398+ break;
2399+ }
2400+ continue;
2401+ }
2402+
2403+ // それ以外なら終了
2404+ if (flr.isBasedOn(THIEF.Data.Obj.DarkFloor) || flr.isBasedOn(THIEF.Data.Obj.NonDiggableWall)) {
2405+ break;
2406+ }
2407+ }
2408+ };
2409+
23262410 roomsInfo.push(roomsInfo[0]);
23272411 for (i = 0; i < (roomsInfo.length - 1); i++) {
23282412
@@ -2335,7 +2419,7 @@
23352419 ax = 1 + roomsInfo[i].x + Math.round(Math.random() * (roomsInfo[i].width - 3));
23362420 ay = 1 + roomsInfo[i].y + Math.round(Math.random() * (roomsInfo[i].height - 3));
23372421
2338- if (THIEF.conf.debugmode) {
2422+ if (THIEF.conf.debugMode) {
23392423 map[roomsInfo[i].x + Math.round(roomsInfo[i].width / 2) - 1][roomsInfo[i].y + Math.round(roomsInfo[i].height / 2) - 1].getLast().color = 'red';
23402424 map[roomsInfo[i].x][roomsInfo[i].y].getLast().color = 'olive';
23412425 map[ax][ay].getLast().color = 'green';
@@ -2342,47 +2426,6 @@
23422426 }
23432427
23442428 //alert('x:' + roomsInfo[i].x + ', y:' + roomsInfo[i].y + ', width:' + roomsInfo[i].width + ', height:' + roomsInfo[i].height + '\nvx:' + vx + ', vy:' + vy + ', ax:' + ax + ', ay:' + ay);
2345-
2346- // 通路を作成
2347- // 二度ドアを作るか、通路に当たったら終了
2348-
2349- var wallCounter;
2350- var fl;
2351- var setFloor = function (x, y, vx, vy) {
2352- index = 0;
2353- wallCounter = 0;
2354- var diffX;
2355- var diffY;
2356- while (true) {
2357- diffX = index * vx;
2358- diffY = index * vy;
2359- fl = map[ax - diffX][ay - diffY].getLast();
2360- index++;
2361-
2362- // 名にもないのであればとりあえず通路を作る
2363- if (typeof fl === 'undefined') {
2364- map[ax - diffX][ay - diffY].push(THIEF.util.factory(THIEF.Data.Obj.DarkFloor));
2365- continue;
2366- }
2367-
2368- // 壁ならば通路に置換
2369- if (fl.isBasedOn(THIEF.Data.Obj.NormalWall)) {
2370- map[ax - diffX][ay - diffY].pop();
2371- map[ax - diffX][ay - diffY].push(THIEF.util.factory(THIEF.Data.Obj.LitFloor));
2372- wallCounter++;
2373- if (wallCounter === 2) {
2374- break;
2375- }
2376- continue;
2377- }
2378-
2379- // それ以外なら終了
2380- if (fl.isBasedOn(THIEF.Data.Obj.DarkFloor)
2381- || fl.isBasedOn(THIEF.Data.Obj.NonDiggableWall)) {
2382- break;
2383- }
2384- }
2385- };
23862429 // 縦軸
23872430 if (vx !== 0) {
23882431 setFloor(ax, ay, vx, 0);
@@ -2499,6 +2542,9 @@
24992542 }
25002543 map[w][h].push(THIEF.util.factory(THIEF.Data.Obj.LitFloor));
25012544 break;
2545+ case '':
2546+ THIEF.html.addDebugMessage('文字なし?');
2547+ break;
25022548 default:
25032549 THIEF.html.addDebugMessage(map[h].charAt(w) + 'はまだ対応していない。');
25042550 break;
@@ -2695,22 +2741,22 @@
26952741 case 'string' :
26962742 switch (ope) {
26972743 case '+' :
2698- revP[index - 2] = revP[index - 2] + revP[index - 1];
2744+ revP[index - 2] += revP[index - 1];
26992745 break;
27002746 case '-' :
2701- revP[index - 2] = revP[index - 2] - revP[index - 1];
2747+ revP[index - 2] -= revP[index - 1];
27022748 break;
27032749 case '/' :
2704- revP[index - 2] = revP[index - 2] / revP[index - 1];
2750+ revP[index - 2] /= revP[index - 1];
27052751 break;
27062752 case '*' :
2707- revP[index - 2] = revP[index - 2] * revP[index - 1];
2753+ revP[index - 2] *= revP[index - 1];
27082754 break;
27092755 case '%' :
2710- revP[index - 2] = revP[index - 2] % revP[index - 1];
2756+ revP[index - 2] %= revP[index - 1];
27112757 break;
27122758 case '^' :
2713- revP[index - 2] = revP[index - 2] ^ revP[index - 1];
2759+ revP[index - 2] = Math.pow(revP[index - 2], revP[index - 1]);
27142760 break;
27152761 case 'd' :
27162762 revP[index - 2] = Math.dice(revP[index - 2], revP[index - 1]);
@@ -2757,18 +2803,18 @@
27572803 text = arguments[0];
27582804
27592805 // 言語が複数あれば選択
2760- for (i = 0; i < THIEF.conf.languagePriolity.length; i++) {
2806+ for (i = 0; i < THIEF.conf.languagePriority.length; i++) {
27612807 var lang;
27622808
2763- if (THIEF.conf.languagePriolity[i] === 'AUTO') {
2809+ if (THIEF.conf.languagePriority[i] === 'AUTO') {
27642810 lang = (navigator.language || navigator.userLanguage).substr(0, 2);
27652811 } else {
2766- lang = THIEF.conf.languagePriolity[i];
2812+ lang = THIEF.conf.languagePriority[i];
27672813 }
27682814
27692815 if (arguments[0][lang]) {
27702816 text = arguments[0][lang];
2771- THIEF.html.addDebugMessage('言語設定は、優先度 ' + i + ' の ' + THIEF.conf.languagePriolity[i] + ' : ' + text);
2817+ THIEF.html.addDebugMessage('言語設定は、優先度 ' + i + ' の ' + THIEF.conf.languagePriority[i] + ' : ' + text);
27722818 break;
27732819 }
27742820 }
@@ -2802,7 +2848,7 @@
28022848 // @ で区切られた部分は関数の引数とする
28032849 // 例:${THIEF.global.adventurer.%get@name%} &#x2665;:${THIEF.global.adventurer.%get@hp%}
28042850 var variables = text.match(/\$\{[A-Za-z0-9_$.%@]+\}/g);
2805- if (variables !== null) {
2851+ if (variables !== true) {
28062852 for (i = 0; i < variables.length; i++) {
28072853 // ${ と } を削除
28082854 var variable = variables[i].slice(2, variables[i].length - 1);
@@ -2828,11 +2874,11 @@
28282874 // 関数処理
28292875 } else {
28302876 // 前後の % を削除し、@で分割
2831- var arguments = tree[j].slice(1, tree[j].length - 1).split('@');
2877+ var functions = tree[j].slice(1, tree[j].length - 1).split('@');
28322878 var args = [];
2833- var func = arguments[0];
2834- for (var l = 1; l < arguments.length; l++) {
2835- args.push(arguments[l]);
2879+ var func = functions[0];
2880+ for (var l = 1; l < functions.length; l++) {
2881+ args.push(functions[l]);
28362882 }
28372883 val = val[func].apply(val, args);
28382884
@@ -2941,7 +2987,7 @@
29412987
29422988 return function (text) {
29432989
2944- if (THIEF.conf.debugmode) {
2990+ if (THIEF.conf.debugMode) {
29452991 if (typeof text === 'string') {
29462992 // 文字列が ... から開始する場合にはインデントを減らす
29472993 if (text.match(/^\.\.\./) && indent.length > 0) {
@@ -2963,7 +3009,7 @@
29633009 }
29643010 document.getElementById(THIEF.conf.id + 'Debug').innerHTML = line;
29653011 document.getElementById(THIEF.conf.id + 'Debug').scrollTop = 0;
2966- hist = [];
3012+ //hist = [];
29673013 //indent = '';
29683014
29693015 }
@@ -3064,7 +3110,7 @@
30643110 var mesg = THIEF.conf.id + 'Message'; // メッセージ欄(入力上部)
30653111 var maps = THIEF.conf.id + 'Map'; // マップ
30663112 var stus = THIEF.conf.id + 'Status'; // ステータス
3067- var info = THIEF.conf.id + 'Infomation'; // 情報出力(インベントリの内容など)
3113+ var info = THIEF.conf.id + 'Information'; // 情報出力(インベントリの内容など)
30683114 var foot = THIEF.conf.id + 'Footer'; //
30693115 var dbug = THIEF.conf.id + 'Debug'; // デバッグ情報
30703116 sheet.addStyle('#' + root, 'color', THIEF.conf.textColor);
@@ -3165,7 +3211,7 @@
31653211
31663212
31673213 // デバッグ画面
3168- if (THIEF.conf.debugmode) {
3214+ if (THIEF.conf.debugMode) {
31693215 line += '<p style="text-align:center;">Debug Info</p>\n';
31703216 line += '<div id="' + dbug + '"></div>\n';
31713217 }
@@ -3485,7 +3531,7 @@
34853531 displayName : function () {
34863532 var text = '';
34873533 if (this.equiped) {
3488- text += '[E] '
3534+ text += '[E] ';
34893535 }
34903536 text += this.get(THIEF.PROP.name) + '(<span style="color:' + this.get(THIEF.PROP.color) + '">' + this.get(THIEF.PROP.symbol) + '</span>)';
34913537 return text;
@@ -3583,7 +3629,7 @@
35833629 THIEF.Data.Obj.$Monster = {
35843630 isActive : true,
35853631 ct : 0,
3586- maxct : 100,
3632+ maxCT : 100,
35873633 isMonster : true
35883634 };
35893635
@@ -4065,7 +4111,7 @@
40654111 levelNum : 10,
40664112 startLevel : 2,
40674113 hierarchy : [
4068- {level : ['First', 'SmallRoom', 'Safety'], base : 2},
4114+ {level : ['First', 'SmallRoom', 'Safety'], base : 2, chance : 100},
40694115 {branch : 'SideRoad', base : 3, range : 1, branchDir : 'down'}
40704116 //{level : 'BigRoom', base : 4, range :3, chance : 50}
40714117 ]
旧リポジトリブラウザで表示