0.0.7-alpha6
・ インデントをざっと修正
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - This software is licensed under the BSD license. | |
2 | + This software is licensed under the new BSD license. | |
3 | 3 | |
4 | 4 | Copyright (c) 2011, Seussnu Koromotani |
5 | 5 | All rights reserved. |
@@ -282,7 +282,8 @@ | ||
282 | 282 | |
283 | 283 | if (!Object.create) { |
284 | 284 | Object.create = function(o) { |
285 | - var func = function() { }; | |
285 | + var func = function() { | |
286 | + }; | |
286 | 287 | func.prototype = o; |
287 | 288 | return new func(); |
288 | 289 | }; |
@@ -303,7 +304,7 @@ | ||
303 | 304 | } |
304 | 305 | |
305 | 306 | if (!Math.dice) { |
306 | - Math.dice = function(fre, sides){ | |
307 | + Math.dice = function(fre, sides) { | |
307 | 308 | var val = 0; |
308 | 309 | for (var i = 0; i < fre; i++) { |
309 | 310 | val += Math.round(Math.random() * sides + 0.5); |
@@ -366,8 +367,8 @@ | ||
366 | 367 | THIEF.func.method.get = function (param) { |
367 | 368 | var val; |
368 | 369 | |
369 | - if(THIEF.global.debugmode){ | |
370 | - if(typeof param === 'undefined'){ | |
370 | + if (THIEF.global.debugmode) { | |
371 | + if (typeof param === 'undefined') { | |
371 | 372 | alert('引数が指定されていません'); |
372 | 373 | } |
373 | 374 | } |
@@ -390,7 +391,7 @@ | ||
390 | 391 | return val; |
391 | 392 | }; |
392 | 393 | |
393 | -THIEF.func.method.isBasedOn = function (obj){ | |
394 | +THIEF.func.method.isBasedOn = function (obj) { | |
394 | 395 | return this.uniqNumber === obj.uniqNumber; |
395 | 396 | }; |
396 | 397 |
@@ -446,7 +447,7 @@ | ||
446 | 447 | } |
447 | 448 | |
448 | 449 | // Item の場合のみアルファベットを設定 |
449 | - if(obj.isItem){ | |
450 | + if (obj.isItem) { | |
450 | 451 | THIEF.html.addDebugMessage(obj.get(THIEF.PROP.displayName) + ' はアイテムなので、アルファベットの割り当てを行う...'); |
451 | 452 | var alphabets = this.getInventoryAlphabets(); |
452 | 453 | if (typeof obj.get(THIEF.PROP.alphabet) === 'string' && alphabets.indexOf(obj.get(THIEF.PROP.alphabet)) === -1) { |
@@ -459,7 +460,7 @@ | ||
459 | 460 | } else { |
460 | 461 | obj[THIEF.PROP.alphabet] = alp; |
461 | 462 | } |
462 | - THIEF.html.addDebugMessage('新たに ' + alp + ' を割り当てた。') | |
463 | + THIEF.html.addDebugMessage('新たに ' + alp + ' を割り当てた。') | |
463 | 464 | } |
464 | 465 | THIEF.html.addDebugMessage('...アルファベットの割り当て処理完了。'); |
465 | 466 | } |
@@ -564,8 +565,8 @@ | ||
564 | 565 | |
565 | 566 | //my.slot[THIEF.PARAM.slot.hand] = selected[0]; |
566 | 567 | var val; |
567 | - if(typeof obj.slot === 'undefined' || typeof obj.slot[THIEF.Data.Obj.$Item.slot] === 'undefined'){ | |
568 | - if(typeof obj.damage === 'undefined'){ | |
568 | + if (typeof obj.slot === 'undefined' || typeof obj.slot[THIEF.Data.Obj.$Item.slot] === 'undefined') { | |
569 | + if (typeof obj.damage === 'undefined') { | |
569 | 570 | val = '1d2'; |
570 | 571 | } else { |
571 | 572 | val = obj.damage; |
@@ -577,7 +578,7 @@ | ||
577 | 578 | var revP = THIEF.util.infixToRevP(val); |
578 | 579 | var damage = THIEF.util.execRevP(revP); |
579 | 580 | |
580 | - THIEF.html.addDebugMessage('ベースダメージ : ' + damage ); | |
581 | + THIEF.html.addDebugMessage('ベースダメージ : ' + damage); | |
581 | 582 | damage += obj.get(THIEF.PROP.db); |
582 | 583 | THIEF.html.addDebugMessage('ダメージボーナス追加後 : ' + damage); |
583 | 584 | var ac = this.get(THIEF.PROP.armorPoint); |
@@ -584,7 +585,7 @@ | ||
584 | 585 | THIEF.html.addDebugMessage('AC適用後 : ' + (damage - ac)); |
585 | 586 | damage -= ac; |
586 | 587 | |
587 | - if(damage> 0){ | |
588 | + if (damage > 0) { | |
588 | 589 | THIEF.html.addDebugMessage(this.get(THIEF.PROP.displayName) + ' HP : ' + this.get(THIEF.PROP.hp) + ' -> ' + (this.get(THIEF.PROP.hp) - damage) + 'とする。'); |
589 | 590 | this.hp -= damage; |
590 | 591 | THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.attack, damage, this.get(THIEF.PROP.displayName), obj.get(THIEF.PROP.displayName))); |
@@ -641,14 +642,14 @@ | ||
641 | 642 | // ループ処理を加えること |
642 | 643 | THIEF.func.method.getInventoryAlphabets = function() { |
643 | 644 | var alphabets = []; |
644 | - if(this.inventory){ | |
645 | - for(var i=0; i<this.get(THIEF.PROP.inventoryWidth); i++){ | |
646 | - if(this.inventory[i]){ | |
647 | - for(var j=0; j<this.get(THIEF.PROP.inventoryHeight); j++){ | |
648 | - if(this.inventory[i][j]){ | |
649 | - for(var k=0; k<this.inventory[i][j].length; k++){ | |
645 | + if (this.inventory) { | |
646 | + for (var i = 0; i < this.get(THIEF.PROP.inventoryWidth); i++) { | |
647 | + if (this.inventory[i]) { | |
648 | + for (var j = 0; j < this.get(THIEF.PROP.inventoryHeight); j++) { | |
649 | + if (this.inventory[i][j]) { | |
650 | + for (var k = 0; k < this.inventory[i][j].length; k++) { | |
650 | 651 | var alphabet = this.inventory[i][j][k].get(THIEF.PROP.alphabet); |
651 | - if(alphabet){ | |
652 | + if (alphabet) { | |
652 | 653 | alphabets.push(alphabet); |
653 | 654 | } |
654 | 655 | } |
@@ -769,12 +770,12 @@ | ||
769 | 770 | |
770 | 771 | // すべてを選択しない |
771 | 772 | case key.Minus: |
772 | - if(immediately) { | |
773 | + if (immediately) { | |
773 | 774 | selected.push(undefined); |
774 | 775 | finish = true; |
775 | 776 | } else { |
776 | 777 | selected.length = 0; |
777 | - for(var i=0; i<targets.length; i++){ | |
778 | + for (var i = 0; i < targets.length; i++) { | |
778 | 779 | // 表示を初期化すること |
779 | 780 | } |
780 | 781 | } |
@@ -929,7 +930,9 @@ | ||
929 | 930 | }; |
930 | 931 | |
931 | 932 | // 基本は AI 処理とする |
932 | -THIEF.func.method.next = function() { return this.cpu(); }; | |
933 | +THIEF.func.method.next = function() { | |
934 | + return this.cpu(); | |
935 | +}; | |
933 | 936 | |
934 | 937 | THIEF.func.method.notify = function() { |
935 | 938 |
@@ -955,7 +958,7 @@ | ||
955 | 958 | // CT を増加 |
956 | 959 | if (this.get(THIEF.PROP.active)) { |
957 | 960 | |
958 | - if(this.ct > 100){ | |
961 | + if (this.ct > 100) { | |
959 | 962 | this.ct = 100; |
960 | 963 | } |
961 | 964 |
@@ -1061,8 +1064,8 @@ | ||
1061 | 1064 | } else { |
1062 | 1065 | THIEF.html.addDebugMessage(String.fromCharCode(code) + '(' + code + ')の入力に対する処理を開始...'); |
1063 | 1066 | |
1064 | - for(var name in THIEF.Data.Keymap){ | |
1065 | - if(THIEF.Data.Keymap[name].key !== 'undefined' && THIEF.Data.Keymap[name].key === code){ | |
1067 | + for (var name in THIEF.Data.Keymap) { | |
1068 | + if (THIEF.Data.Keymap[name].key !== 'undefined' && THIEF.Data.Keymap[name].key === code) { | |
1066 | 1069 | THIEF.html.addDebugMessage(this.get(THIEF.PROP.displayName) + ' の ' + name + ' コマンドを実行'); |
1067 | 1070 | finish = THIEF.Data.Keymap[name].cmd.call(this); |
1068 | 1071 | break; |
@@ -1198,7 +1201,7 @@ | ||
1198 | 1201 | if (from.removeFromInventory(selected[i])) { |
1199 | 1202 | |
1200 | 1203 | // 装備済みなら外す |
1201 | - if(typeof from.slot !== 'undefined' && typeof from.slot[selected[i].slot] !== 'undefined'){ | |
1204 | + if (typeof from.slot !== 'undefined' && typeof from.slot[selected[i].slot] !== 'undefined') { | |
1202 | 1205 | delete from.slot[selected[i].slot].equiped; |
1203 | 1206 | delete from.slot[selected[i].slot]; |
1204 | 1207 | THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.equipNone, from.get(THIEF.PROP.displayName), selected[i].get(THIEF.PROP.slotName))); |
@@ -1336,7 +1339,7 @@ | ||
1336 | 1339 | for (var i = THIEF.conf.mapHeight; i >= 0; i--) { |
1337 | 1340 | if (typeof THIEF.global.hist[index - i] !== 'undefined') { |
1338 | 1341 | THIEF.html.addInfomation(THIEF.global.hist[index - i].turn + ' : ' + THIEF.global.hist[index - i].text); |
1339 | - if (index - i === THIEF.global.hist.length - 1) { | |
1342 | + if (index - i === THIEF.global.hist.length - 1) { | |
1340 | 1343 | THIEF.html.addInfomation('<div style="text-align:center;">--Now--</div>'); |
1341 | 1344 | } |
1342 | 1345 | } |
@@ -1355,7 +1358,7 @@ | ||
1355 | 1358 | |
1356 | 1359 | var com = []; |
1357 | 1360 | for (var name in THIEF.Data.Keymap) { |
1358 | - if( typeof THIEF.Data.Keymap[name].txt !== 'undefined' ) { | |
1361 | + if (typeof THIEF.Data.Keymap[name].txt !== 'undefined') { | |
1359 | 1362 | com.push(name); |
1360 | 1363 | } |
1361 | 1364 | } |
@@ -1451,11 +1454,13 @@ | ||
1451 | 1454 | var act = false; |
1452 | 1455 | if (selected.length > 0) { |
1453 | 1456 | act = true; |
1454 | - if(typeof my.slot === 'undefined'){ my.slot = {}; } | |
1457 | + if (typeof my.slot === 'undefined') { | |
1458 | + my.slot = {}; | |
1459 | + } | |
1455 | 1460 | |
1456 | 1461 | // 既に付けている装備を外す必要があるか |
1457 | - if(typeof selected[0] !== 'undefined' && typeof my.slot[selected[0].slot] !== 'undefined'){ | |
1458 | - if(selected[0] === my.slot[selected[0].slot]){ | |
1462 | + if (typeof selected[0] !== 'undefined' && typeof my.slot[selected[0].slot] !== 'undefined') { | |
1463 | + if (selected[0] === my.slot[selected[0].slot]) { | |
1459 | 1464 | THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.equipAlready, selected[0].get(THIEF.PROP.displayName), my.get(THIEF.PROP.displayName))); |
1460 | 1465 | selected[0] = undefined; |
1461 | 1466 | } else { |
@@ -1467,7 +1472,7 @@ | ||
1467 | 1472 | } |
1468 | 1473 | |
1469 | 1474 | // 装備 |
1470 | - if(typeof selected[0] !== 'undefined'){ | |
1475 | + if (typeof selected[0] !== 'undefined') { | |
1471 | 1476 | my.slot[selected[0].slot] = selected[0]; |
1472 | 1477 | my.slot[selected[0].slot].equiped = true; |
1473 | 1478 | THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.equipItem, selected[0].get(THIEF.PROP.displayName), my.get(THIEF.PROP.displayName), selected[0].get(THIEF.PROP.slotName))); |
@@ -1531,7 +1536,7 @@ | ||
1531 | 1536 | THIEF.global.adventurer.inventoryWidth = 10; |
1532 | 1537 | THIEF.global.adventurer.inventoryCellSize = 1; |
1533 | 1538 | THIEF.global.adventurer.ct = 100; |
1534 | - | |
1539 | + | |
1535 | 1540 | THIEF.global.actLV.addToInventory(THIEF.global.adventurer); |
1536 | 1541 | |
1537 | 1542 |
@@ -1598,7 +1603,7 @@ | ||
1598 | 1603 | compCounter = 15; |
1599 | 1604 | } |
1600 | 1605 | |
1601 | - if(completion){ | |
1606 | + if (completion) { | |
1602 | 1607 | THIEF.html.addDebugMessage('...ターン:' + THIEF.global.turn + ' を完了。'); |
1603 | 1608 | } else { |
1604 | 1609 | THIEF.html.addDebugMessage('...ターン:' + THIEF.global.turn + ' を中断。(ユーザからの入力待ち)'); |
@@ -1651,7 +1656,7 @@ | ||
1651 | 1656 | |
1652 | 1657 | } else { |
1653 | 1658 | |
1654 | - if(e.shiftKey) { | |
1659 | + if (e.shiftKey) { | |
1655 | 1660 | // |
1656 | 1661 | } else { |
1657 | 1662 | switch (code) { |
@@ -1682,7 +1687,7 @@ | ||
1682 | 1687 | } |
1683 | 1688 | } |
1684 | 1689 | |
1685 | - if(e.ctrlKey){ | |
1690 | + if (e.ctrlKey) { | |
1686 | 1691 | switch (code) { |
1687 | 1692 | // コピペ・ブックマーク用 |
1688 | 1693 | case THIEF.KEY.a: |
@@ -1694,7 +1699,7 @@ | ||
1694 | 1699 | code = 0; |
1695 | 1700 | } |
1696 | 1701 | break; |
1697 | - | |
1702 | + | |
1698 | 1703 | default: |
1699 | 1704 | break; |
1700 | 1705 | } |
@@ -1753,7 +1758,7 @@ | ||
1753 | 1758 | if (typeof THIEF.Data.Obj[inh].uniqNumber === 'undefined') { |
1754 | 1759 | THIEF.html.addDebugMessage(inh + ' のマスタが生成されていないので作成...'); |
1755 | 1760 | |
1756 | - if(typeof THIEF.Data.Obj[inh].uniqNumber === 'undefined'){ | |
1761 | + if (typeof THIEF.Data.Obj[inh].uniqNumber === 'undefined') { | |
1757 | 1762 | THIEF.Data.Obj[inh].uniqNumber = id; |
1758 | 1763 | id++; |
1759 | 1764 | } |
@@ -1801,7 +1806,7 @@ | ||
1801 | 1806 | THIEF.html.addDebugMessage('.' + propName); |
1802 | 1807 | } |
1803 | 1808 | } |
1804 | - THIEF.html.addDebugMessage('.inheritance = ' + inhPrev ); | |
1809 | + THIEF.html.addDebugMessage('.inheritance = ' + inhPrev); | |
1805 | 1810 | tree[THIEF.Data.Obj[inh].uniqNumber].inheritance = inhPrev; |
1806 | 1811 | THIEF.html.addDebugMessage('...コピー完了'); |
1807 | 1812 |
@@ -1817,18 +1822,18 @@ | ||
1817 | 1822 | obj.uniqNumber = id; |
1818 | 1823 | id++; |
1819 | 1824 | |
1820 | - if(obj !== THIEF.Data.Obj.$){ | |
1825 | + if (obj !== THIEF.Data.Obj.$) { | |
1821 | 1826 | THIEF.html.addDebugMessage('要求オブジェクトのマスタ作成開始...'); |
1822 | 1827 | THIEF.html.addDebugMessage(inhPrev + ' より雛形オブジェクトを作成'); |
1823 | 1828 | tree[obj.uniqNumber] = Object.create(tree[THIEF.Data.Obj[inhPrev].uniqNumber]); |
1824 | 1829 | THIEF.html.addDebugMessage('Own Property をコピー開始...'); |
1825 | - for(propName in obj) { | |
1826 | - if(obj.hasOwnProperty(propName)){ | |
1830 | + for (propName in obj) { | |
1831 | + if (obj.hasOwnProperty(propName)) { | |
1827 | 1832 | tree[obj.uniqNumber][propName] = obj[propName]; |
1828 | 1833 | THIEF.html.addDebugMessage('.' + propName); |
1829 | 1834 | } |
1830 | 1835 | } |
1831 | - THIEF.html.addDebugMessage('.inheritance = ' + inhPrev ); | |
1836 | + THIEF.html.addDebugMessage('.inheritance = ' + inhPrev); | |
1832 | 1837 | tree[obj.uniqNumber].inheritance = inhPrev; |
1833 | 1838 | THIEF.html.addDebugMessage('...コピー完了'); |
1834 | 1839 | THIEF.html.addDebugMessage('...マスタ作成完了'); |
@@ -1842,20 +1847,20 @@ | ||
1842 | 1847 | THIEF.html.addDebugMessage('マスターからインスタンスを作成'); |
1843 | 1848 | THIEF.html.addDebugMessage('初期化を開始...'); |
1844 | 1849 | var val = Object.create(tree[obj.uniqNumber]); |
1845 | - for (propName in val){ | |
1846 | - if(typeof val[propName] === 'string' && val[propName].charAt(0) === '_'){ | |
1850 | + for (propName in val) { | |
1851 | + if (typeof val[propName] === 'string' && val[propName].charAt(0) === '_') { | |
1847 | 1852 | THIEF.html.addDebugMessage(propName + ' の変数を初期化します'); |
1848 | - val[propName] = THIEF.util.execRevP(THIEF.util.infixToRevP(val[propName].slice(1))); | |
1853 | + val[propName] = THIEF.util.execRevP(THIEF.util.infixToRevP(val[propName].slice(1))); | |
1849 | 1854 | THIEF.html.addDebugMessage(propName + ' : ' + val[propName]); |
1850 | 1855 | } |
1851 | 1856 | } |
1852 | 1857 | |
1853 | - if(typeof val.pow === 'number' && typeof val.san !== 'number'){ | |
1858 | + if (typeof val.pow === 'number' && typeof val.san !== 'number') { | |
1854 | 1859 | val.san = val.pow * 5; |
1855 | 1860 | THIEF.html.addDebugMessage('san : ' + val.san); |
1856 | 1861 | } |
1857 | 1862 | |
1858 | - if(typeof val.hp === 'undefined') { | |
1863 | + if (typeof val.hp === 'undefined') { | |
1859 | 1864 | val.hp = Math.ceil((val.con + val.siz) / 2); |
1860 | 1865 | } |
1861 | 1866 |
@@ -1874,7 +1879,7 @@ | ||
1874 | 1879 | lv.inventory = THIEF.util.createMap(THIEF.conf.mapWidth, THIEF.conf.mapHeight); |
1875 | 1880 | lv[THIEF.PROP.name] = {ja:'テストレベル', en:'Practice'}; |
1876 | 1881 | lv[THIEF.PROP.inventoryWidth] = THIEF.conf.mapWidth; |
1877 | - lv[THIEF.PROP.inventoryHeight] = THIEF.conf.mapHeight; | |
1882 | + lv[THIEF.PROP.inventoryHeight] = THIEF.conf.mapHeight; | |
1878 | 1883 | lv[THIEF.PROP.inventoryDepth] = THIEF.conf.mapDepth; |
1879 | 1884 | lv.inventoryCellSize = 1; |
1880 | 1885 | return lv; |
@@ -1892,7 +1897,7 @@ | ||
1892 | 1897 | for (j = 0; j < height; j++) { |
1893 | 1898 | line[j] = []; |
1894 | 1899 | if (i === 0 || j === 0 || i === (width - 1) || j === (height - 1)) { |
1895 | - line[j].push( THIEF.util.factory(THIEF.Data.Obj.NonDiggableWall) ); | |
1900 | + line[j].push(THIEF.util.factory(THIEF.Data.Obj.NonDiggableWall)); | |
1896 | 1901 | } |
1897 | 1902 | } |
1898 | 1903 | map[i] = line; |
@@ -1901,7 +1906,9 @@ | ||
1901 | 1906 | // マップ分割 |
1902 | 1907 | var maxRooms = Math.floor(Math.random() * (width + height) / 10) + (width + height) / 20; |
1903 | 1908 | var anchors = []; // 部屋の起点(一番左上=若い座標) |
1904 | - var spaceEdges = [ {x:1, y:1} ]; // 左上は常にスペースの角のため | |
1909 | + var spaceEdges = [ | |
1910 | + {x:1, y:1} | |
1911 | + ]; // 左上は常にスペースの角のため | |
1905 | 1912 | var roonCount = 0; |
1906 | 1913 | var roop = 0; |
1907 | 1914 | var roopLimit = 300; // 300 回くらい試行して駄目ならあきらめる |
@@ -1976,7 +1983,7 @@ | ||
1976 | 1983 | // 一般的にマップ全体は横幅の方が長いと仮定している |
1977 | 1984 | // 壁までの距離が短い方に伸ばすように分割線を引く |
1978 | 1985 | // 長い方に伸ばすように引くと部屋が小さくなるため |
1979 | - map[ax][ay].push( THIEF.util.factory(THIEF.Data.Obj.DarkFloor) ); | |
1986 | + map[ax][ay].push(THIEF.util.factory(THIEF.Data.Obj.DarkFloor)); | |
1980 | 1987 | anchors.push({x:ax, y:ay}); |
1981 | 1988 | |
1982 | 1989 | if (my < mx) { |
@@ -2063,7 +2070,7 @@ | ||
2063 | 2070 | endY++; |
2064 | 2071 | } |
2065 | 2072 | |
2066 | - roomsInfo.push({x:x+startX, y:y+startY, width:endX-startX, height:endY-startY}); | |
2073 | + roomsInfo.push({x:x + startX, y:y + startY, width:endX - startX, height:endY - startY}); | |
2067 | 2074 | |
2068 | 2075 | // 部屋作成 |
2069 | 2076 | for (i = startX; i < endX; i++) { |
@@ -2081,23 +2088,23 @@ | ||
2081 | 2088 | // 部屋の位置関係を取得し、縦横各1通を生成する |
2082 | 2089 | // 部屋は次の部屋と比較され、最後の部屋は最初の部屋と比較される(孤立する部屋を作らないようにするため) |
2083 | 2090 | roomsInfo.push(roomsInfo[0]); |
2084 | - for(i = 0; i < (roomsInfo.length-1); i++){ | |
2091 | + for (i = 0; i < (roomsInfo.length - 1); i++) { | |
2085 | 2092 | |
2086 | 2093 | // 中心を計算し、通路を伸ばす方向を決める |
2087 | - var vx = Math.sign((roomsInfo[i].x + roomsInfo[i].width/2) - (roomsInfo[i+1].x + roomsInfo[i+1].width/2)); | |
2088 | - var vy = Math.sign((roomsInfo[i].y + roomsInfo[i].height/2) - (roomsInfo[i+1].y + roomsInfo[i+1].height/2)); | |
2094 | + var vx = Math.sign((roomsInfo[i].x + roomsInfo[i].width / 2) - (roomsInfo[i + 1].x + roomsInfo[i + 1].width / 2)); | |
2095 | + var vy = Math.sign((roomsInfo[i].y + roomsInfo[i].height / 2) - (roomsInfo[i + 1].y + roomsInfo[i + 1].height / 2)); | |
2089 | 2096 | |
2090 | 2097 | // 部屋の中から適当に一つポイントを決める |
2091 | 2098 | // 壁にめり込まないように 座標+1, 長さ-3 (-1分は原点) |
2092 | 2099 | ax = 1 + roomsInfo[i].x + Math.round(Math.random() * (roomsInfo[i].width - 3)); |
2093 | - ay = 1 + roomsInfo[i].y + Math.round(Math.random() * (roomsInfo[i].height -3)); | |
2100 | + ay = 1 + roomsInfo[i].y + Math.round(Math.random() * (roomsInfo[i].height - 3)); | |
2094 | 2101 | |
2095 | - if(THIEF.conf.debugmode){ | |
2096 | - map[roomsInfo[i].x + Math.round(roomsInfo[i].width/2) -1][roomsInfo[i].y + Math.round(roomsInfo[i].height/2) -1].getLast().color = 'red'; | |
2102 | + if (THIEF.conf.debugmode) { | |
2103 | + map[roomsInfo[i].x + Math.round(roomsInfo[i].width / 2) - 1][roomsInfo[i].y + Math.round(roomsInfo[i].height / 2) - 1].getLast().color = 'red'; | |
2097 | 2104 | map[roomsInfo[i].x][roomsInfo[i].y].getLast().color = 'olive'; |
2098 | 2105 | map[ax][ay].getLast().color = 'green'; |
2099 | 2106 | } |
2100 | - | |
2107 | + | |
2101 | 2108 | //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); |
2102 | 2109 | |
2103 | 2110 | // 通路を作成 |
@@ -2110,24 +2117,24 @@ | ||
2110 | 2117 | wallCounter = 0; |
2111 | 2118 | var diffX; |
2112 | 2119 | var diffY; |
2113 | - while(true){ | |
2114 | - diffX = index*vx; | |
2115 | - diffY = index*vy; | |
2120 | + while (true) { | |
2121 | + diffX = index * vx; | |
2122 | + diffY = index * vy; | |
2116 | 2123 | fl = map[ax - diffX][ay - diffY].getLast(); |
2117 | 2124 | index++; |
2118 | 2125 | |
2119 | 2126 | // 名にもないのであればとりあえず通路を作る |
2120 | - if(typeof fl === 'undefined') { | |
2127 | + if (typeof fl === 'undefined') { | |
2121 | 2128 | map[ax - diffX][ay - diffY].push(THIEF.util.factory(THIEF.Data.Obj.DarkFloor)); |
2122 | 2129 | continue; |
2123 | 2130 | } |
2124 | 2131 | |
2125 | 2132 | // 壁ならば通路に置換 |
2126 | - if(fl.isBasedOn(THIEF.Data.Obj.NormalWall)){ | |
2133 | + if (fl.isBasedOn(THIEF.Data.Obj.NormalWall)) { | |
2127 | 2134 | map[ax - diffX][ay - diffY].pop(); |
2128 | 2135 | map[ax - diffX][ay - diffY].push(THIEF.util.factory(THIEF.Data.Obj.LitFloor)); |
2129 | 2136 | wallCounter++; |
2130 | - if(wallCounter === 2){ | |
2137 | + if (wallCounter === 2) { | |
2131 | 2138 | break; |
2132 | 2139 | } |
2133 | 2140 | continue; |
@@ -2134,78 +2141,77 @@ | ||
2134 | 2141 | } |
2135 | 2142 | |
2136 | 2143 | // それ以外なら終了 |
2137 | - if(fl.isBasedOn(THIEF.Data.Obj.DarkFloor) | |
2138 | - || fl.isBasedOn(THIEF.Data.Obj.NonDiggableWall)){ | |
2144 | + if (fl.isBasedOn(THIEF.Data.Obj.DarkFloor) | |
2145 | + || fl.isBasedOn(THIEF.Data.Obj.NonDiggableWall)) { | |
2139 | 2146 | break; |
2140 | 2147 | } |
2141 | 2148 | } |
2142 | 2149 | }; |
2143 | 2150 | // 縦軸 |
2144 | - if(vx !== 0){ | |
2151 | + if (vx !== 0) { | |
2145 | 2152 | setFloor(ax, ay, vx, 0); |
2146 | 2153 | } |
2147 | 2154 | // 横軸 |
2148 | - if(vy !== 0){ | |
2155 | + if (vy !== 0) { | |
2149 | 2156 | setFloor(ax, ay, 0, vy); |
2150 | 2157 | } |
2151 | 2158 | } |
2152 | 2159 | |
2153 | 2160 | |
2154 | - | |
2155 | 2161 | // 不要な通路を削除 |
2156 | 2162 | |
2157 | - var clearFloor = function(_x, _y){ | |
2163 | + var clearFloor = function(_x, _y) { | |
2158 | 2164 | var around; |
2159 | 2165 | var x = _x; |
2160 | 2166 | var y = _y; |
2161 | 2167 | var nextX, nextY; |
2162 | 2168 | var flr = map[x][y].getLast(); |
2163 | - if(typeof flr !== 'undefined' && flr.type === THIEF.Data.Obj.$Floor.type ){ | |
2164 | - while(true){ | |
2169 | + if (typeof flr !== 'undefined' && flr.type === THIEF.Data.Obj.$Floor.type) { | |
2170 | + while (true) { | |
2165 | 2171 | // 周囲に通路が一つだけか調べる |
2166 | 2172 | around = 0; |
2167 | - if(typeof map[x-1][y-1].getLast() !== 'undefined' && map[x-1][y-1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2173 | + if (typeof map[x - 1][y - 1].getLast() !== 'undefined' && map[x - 1][y - 1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2168 | 2174 | around++; |
2169 | - nextX=x-1; | |
2170 | - nextY=y-1; | |
2175 | + nextX = x - 1; | |
2176 | + nextY = y - 1; | |
2171 | 2177 | } |
2172 | - if(typeof map[x][y-1].getLast() !== 'undefined' && map[x][y-1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2178 | + if (typeof map[x][y - 1].getLast() !== 'undefined' && map[x][y - 1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2173 | 2179 | around++; |
2174 | - nextX=x; | |
2175 | - nextY=y-1; | |
2180 | + nextX = x; | |
2181 | + nextY = y - 1; | |
2176 | 2182 | } |
2177 | - if(typeof map[x+1][y-1].getLast() !== 'undefined' && map[x+1][y-1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2183 | + if (typeof map[x + 1][y - 1].getLast() !== 'undefined' && map[x + 1][y - 1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2178 | 2184 | around++; |
2179 | - nextX=x+1; | |
2180 | - nextY=y-1; | |
2185 | + nextX = x + 1; | |
2186 | + nextY = y - 1; | |
2181 | 2187 | } |
2182 | - if(typeof map[x-1][y].getLast() !== 'undefined' && map[x-1][y].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2188 | + if (typeof map[x - 1][y].getLast() !== 'undefined' && map[x - 1][y].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2183 | 2189 | around++; |
2184 | - nextX=x-1; | |
2185 | - nextY=y; | |
2190 | + nextX = x - 1; | |
2191 | + nextY = y; | |
2186 | 2192 | } |
2187 | 2193 | // me |
2188 | - if(typeof map[x+1][y].getLast() !== 'undefined' && map[x+1][y].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2194 | + if (typeof map[x + 1][y].getLast() !== 'undefined' && map[x + 1][y].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2189 | 2195 | around++; |
2190 | - nextX=x+1; | |
2191 | - nextY=y; | |
2196 | + nextX = x + 1; | |
2197 | + nextY = y; | |
2192 | 2198 | } |
2193 | - if(typeof map[x-1][y+1].getLast() !== 'undefined' && map[x-1][y+1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2199 | + if (typeof map[x - 1][y + 1].getLast() !== 'undefined' && map[x - 1][y + 1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2194 | 2200 | around++; |
2195 | - nextX=x-1; | |
2196 | - nextY=y+1; | |
2201 | + nextX = x - 1; | |
2202 | + nextY = y + 1; | |
2197 | 2203 | } |
2198 | - if(typeof map[x][y+1].getLast() !== 'undefined' && map[x][y+1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2204 | + if (typeof map[x][y + 1].getLast() !== 'undefined' && map[x][y + 1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2199 | 2205 | around++; |
2200 | - nextX=x; | |
2201 | - nextY=y+1; | |
2206 | + nextX = x; | |
2207 | + nextY = y + 1; | |
2202 | 2208 | } |
2203 | - if(typeof map[x+1][y+1].getLast() !== 'undefined' && map[x+1][y+1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2209 | + if (typeof map[x + 1][y + 1].getLast() !== 'undefined' && map[x + 1][y + 1].getLast().type === THIEF.Data.Obj.$Floor.type) { | |
2204 | 2210 | around++; |
2205 | - nextX=x+1; | |
2206 | - nextY=y+1; | |
2211 | + nextX = x + 1; | |
2212 | + nextY = y + 1; | |
2207 | 2213 | } |
2208 | - if(around === 1){ | |
2214 | + if (around === 1) { | |
2209 | 2215 | map[x][y].pop(); |
2210 | 2216 | map[x][y].push(THIEF.util.factory(THIEF.Data.Obj.HiddenWall)); |
2211 | 2217 | map[nextX][nextY].pop(); |
@@ -2218,13 +2224,13 @@ | ||
2218 | 2224 | } |
2219 | 2225 | } |
2220 | 2226 | }; |
2221 | - for(i=1; i<width-2; i++){ | |
2227 | + for (i = 1; i < width - 2; i++) { | |
2222 | 2228 | clearFloor(i, 1); |
2223 | - clearFloor(i, height-2); | |
2229 | + clearFloor(i, height - 2); | |
2224 | 2230 | } |
2225 | - for(i=1; i<height-2; i++){ | |
2231 | + for (i = 1; i < height - 2; i++) { | |
2226 | 2232 | clearFloor(1, i); |
2227 | - clearFloor(width-2, i); | |
2233 | + clearFloor(width - 2, i); | |
2228 | 2234 | } |
2229 | 2235 | |
2230 | 2236 | // 残りを初期化 |
@@ -2231,7 +2237,7 @@ | ||
2231 | 2237 | for (i = 0; i < width; i++) { |
2232 | 2238 | for (j = 0; j < height; j++) { |
2233 | 2239 | if (map[i][j].length === 0) { |
2234 | - map[i][j].push( THIEF.util.factory(THIEF.Data.Obj.HiddenWall)); | |
2240 | + map[i][j].push(THIEF.util.factory(THIEF.Data.Obj.HiddenWall)); | |
2235 | 2241 | //map[i][j].push( THIEF.util.factory(THIEF.Data.Obj.LitFloor)); |
2236 | 2242 | } |
2237 | 2243 | } |
@@ -2260,7 +2266,7 @@ | ||
2260 | 2266 | point = THIEF.global.actLV.getInventoryFreeSpace(monster, x, y); |
2261 | 2267 | |
2262 | 2268 | if (typeof point !== 'undefined' && THIEF.global.actLV.inventory[x][y].getLast().isBasedOn(THIEF.Data.Obj.LitFloor)) { |
2263 | - //if (point.x === 'number' && typeof point.y === 'number') { | |
2269 | + //if (point.x === 'number' && typeof point.y === 'number') { | |
2264 | 2270 | break; |
2265 | 2271 | } |
2266 | 2272 |
@@ -2289,12 +2295,12 @@ | ||
2289 | 2295 | THIEF.html.addDebugMessage('数式を逆ポーランドに変換開始...'); |
2290 | 2296 | THIEF.html.addDebugMessage('変換前:' + val); |
2291 | 2297 | |
2292 | - for(var i = 0; i < val.length; i++){ | |
2298 | + for (var i = 0; i < val.length; i++) { | |
2293 | 2299 | var ope = val.charAt(i); |
2294 | 2300 | switch (ope) { |
2295 | 2301 | case '+' : |
2296 | 2302 | case '-' : |
2297 | - while(/^[\*\/\^%dM]$/.test(stack.getLast())){ | |
2303 | + while (/^[\*\/\^%dM]$/.test(stack.getLast())) { | |
2298 | 2304 | revP.push(stack.pop()); |
2299 | 2305 | } |
2300 | 2306 | stack.push(ope); |
@@ -2301,7 +2307,7 @@ | ||
2301 | 2307 | break; |
2302 | 2308 | |
2303 | 2309 | case '*' : |
2304 | - while(/^[\/\^%dM]$/.test(stack.getLast())){ | |
2310 | + while (/^[\/\^%dM]$/.test(stack.getLast())) { | |
2305 | 2311 | revP.push(stack.pop()); |
2306 | 2312 | } |
2307 | 2313 | stack.push(ope); |
@@ -2308,7 +2314,7 @@ | ||
2308 | 2314 | break; |
2309 | 2315 | |
2310 | 2316 | case '/' : |
2311 | - while(/^[\^%dM]$/.test(stack.getLast())){ | |
2317 | + while (/^[\^%dM]$/.test(stack.getLast())) { | |
2312 | 2318 | revP.push(stack.pop()); |
2313 | 2319 | } |
2314 | 2320 | stack.push(ope); |
@@ -2317,7 +2323,7 @@ | ||
2317 | 2323 | |
2318 | 2324 | case '^' : |
2319 | 2325 | case '%' : |
2320 | - while(/^[dM]$/.test(stack.getLast())){ | |
2326 | + while (/^[dM]$/.test(stack.getLast())) { | |
2321 | 2327 | revP.push(stack.pop()); |
2322 | 2328 | } |
2323 | 2329 | stack.push(ope); |
@@ -2324,7 +2330,7 @@ | ||
2324 | 2330 | break; |
2325 | 2331 | |
2326 | 2332 | case 'd' : |
2327 | - while(/^[M]$/.test(stack.getLast())){ | |
2333 | + while (/^[M]$/.test(stack.getLast())) { | |
2328 | 2334 | revP.push(stack.pop()); |
2329 | 2335 | } |
2330 | 2336 | stack.push(ope); |
@@ -2336,17 +2342,17 @@ | ||
2336 | 2342 | // Math. を必ず含むこと |
2337 | 2343 | // Math.PId6 とかは使用上無理 |
2338 | 2344 | // Math.round () というように、()の前にスペースが入るのも無理 |
2339 | - for(subIndex=i+5; subIndex<val.length; subIndex++){ | |
2340 | - if(/[^a-zA-Z]$/.test(val.charAt(subIndex))){ | |
2341 | - math = val.substring(i+5, subIndex); | |
2345 | + for (subIndex = i + 5; subIndex < val.length; subIndex++) { | |
2346 | + if (/[^a-zA-Z]$/.test(val.charAt(subIndex))) { | |
2347 | + math = val.substring(i + 5, subIndex); | |
2342 | 2348 | break; |
2343 | - } else if(subIndex === val.length-1){ | |
2344 | - math = val.substring(i+5, val.length); | |
2349 | + } else if (subIndex === val.length - 1) { | |
2350 | + math = val.substring(i + 5, val.length); | |
2345 | 2351 | break; |
2346 | 2352 | } |
2347 | 2353 | } |
2348 | 2354 | |
2349 | - if(typeof Math[math] === 'function'){ | |
2355 | + if (typeof Math[math] === 'function') { | |
2350 | 2356 | revP.push('dummy'); |
2351 | 2357 | stack.push('('); // 先に括弧を処理するため、インデックスはそのまま |
2352 | 2358 | stack.push(Math[math]); |
@@ -2365,11 +2371,11 @@ | ||
2365 | 2371 | |
2366 | 2372 | case ')' : |
2367 | 2373 | // Math 関数の引数の数が不定なので、判別用のダミーの引数を加えておく |
2368 | - if(typeof stack.getLast() === 'function'){ | |
2374 | + if (typeof stack.getLast() === 'function') { | |
2369 | 2375 | //revP.push('dummy'); |
2370 | 2376 | } |
2371 | 2377 | |
2372 | - while(stack.getLast() !== '('){ | |
2378 | + while (stack.getLast() !== '(') { | |
2373 | 2379 | revP.push(stack.pop()); |
2374 | 2380 | } |
2375 | 2381 | stack.pop(); // Delete ( |
@@ -2386,12 +2392,12 @@ | ||
2386 | 2392 | case '8' : |
2387 | 2393 | case '9' : |
2388 | 2394 | case '.' : |
2389 | - for(subIndex = i; subIndex<val.length; subIndex++){ | |
2390 | - if(/[^0-9\.]/.test(val.charAt(subIndex))){ | |
2395 | + for (subIndex = i; subIndex < val.length; subIndex++) { | |
2396 | + if (/[^0-9\.]/.test(val.charAt(subIndex))) { | |
2391 | 2397 | revP.push(parseFloat(val.substring(i, subIndex))); |
2392 | 2398 | subIndex--; // 行き過ぎたインデックスを元に戻す |
2393 | 2399 | break; |
2394 | - } else if(subIndex === val.length-1){ | |
2400 | + } else if (subIndex === val.length - 1) { | |
2395 | 2401 | revP.push(parseFloat(val.substring(i, val.length))); |
2396 | 2402 | break; |
2397 | 2403 | } |
@@ -2405,7 +2411,7 @@ | ||
2405 | 2411 | } |
2406 | 2412 | } |
2407 | 2413 | |
2408 | - while(stack.getLast()){ | |
2414 | + while (stack.getLast()) { | |
2409 | 2415 | revP.push(stack.pop()); |
2410 | 2416 | } |
2411 | 2417 |
@@ -2416,18 +2422,22 @@ | ||
2416 | 2422 | }; |
2417 | 2423 | |
2418 | 2424 | THIEF.util.execRevP = function (val) { |
2425 | + | |
2426 | + // そのうちいろいろな乱数に対応させること | |
2427 | + // http://nethackwiki.com/wiki/Category:Random_number_functions | |
2428 | + | |
2419 | 2429 | THIEF.html.addDebugMessage('逆ポーランド記法の数式を計算開始...'); |
2420 | 2430 | |
2421 | 2431 | var revP; |
2422 | - if(typeof val === 'number'){ | |
2432 | + if (typeof val === 'number') { | |
2423 | 2433 | revP = []; |
2424 | 2434 | revP[0] = val; |
2425 | 2435 | } else { |
2426 | 2436 | revP = val.slice(0); |
2427 | 2437 | } |
2428 | - var index=0; | |
2438 | + var index = 0; | |
2429 | 2439 | THIEF.html.addDebugMessage('X = ' + revP); |
2430 | - for( ; revP.length > 1; index++){ | |
2440 | + for (; revP.length > 1; index++) { | |
2431 | 2441 | var ope = revP[index]; |
2432 | 2442 | |
2433 | 2443 | switch (typeof ope) { |
@@ -2437,47 +2447,49 @@ | ||
2437 | 2447 | case 'string' : |
2438 | 2448 | switch (ope) { |
2439 | 2449 | case '+' : |
2440 | - revP[index-2] = revP[index-2] + revP[index-1]; | |
2450 | + revP[index - 2] = revP[index - 2] + revP[index - 1]; | |
2441 | 2451 | break; |
2442 | 2452 | case '-' : |
2443 | - revP[index-2] = revP[index-2] - revP[index-1]; | |
2453 | + revP[index - 2] = revP[index - 2] - revP[index - 1]; | |
2444 | 2454 | break; |
2445 | 2455 | case '/' : |
2446 | - revP[index-2] = revP[index-2] / revP[index-1]; | |
2456 | + revP[index - 2] = revP[index - 2] / revP[index - 1]; | |
2447 | 2457 | break; |
2448 | 2458 | case '*' : |
2449 | - revP[index-2] = revP[index-2] * revP[index-1]; | |
2459 | + revP[index - 2] = revP[index - 2] * revP[index - 1]; | |
2450 | 2460 | break; |
2451 | 2461 | case '%' : |
2452 | - revP[index-2] = revP[index-2] % revP[index-1]; | |
2462 | + revP[index - 2] = revP[index - 2] % revP[index - 1]; | |
2453 | 2463 | break; |
2454 | 2464 | case '^' : |
2455 | - revP[index-2] = revP[index-2] ^ revP[index-1]; | |
2465 | + revP[index - 2] = revP[index - 2] ^ revP[index - 1]; | |
2456 | 2466 | break; |
2457 | 2467 | case 'd' : |
2458 | - revP[index-2] = Math.dice(revP[index-2], revP[index-1]); | |
2468 | + revP[index - 2] = Math.dice(revP[index - 2], revP[index - 1]); | |
2459 | 2469 | break; |
2460 | 2470 | case 'dummy' : |
2461 | 2471 | continue; |
2462 | - default : break; | |
2472 | + default : | |
2473 | + break; | |
2463 | 2474 | } |
2464 | - revP.splice(index-1, 2); | |
2475 | + revP.splice(index - 1, 2); | |
2465 | 2476 | index -= 2; |
2466 | 2477 | break; |
2467 | 2478 | |
2468 | 2479 | case 'function' : |
2469 | - if(revP[index-2] === 'dummy'){ | |
2470 | - revP[index-2] = revP[index](revP[index-1]); | |
2471 | - revP.splice(index-1, 2); | |
2480 | + if (revP[index - 2] === 'dummy') { | |
2481 | + revP[index - 2] = revP[index](revP[index - 1]); | |
2482 | + revP.splice(index - 1, 2); | |
2472 | 2483 | index -= 2; |
2473 | - } else if (revP[index-3] === 'dummy') { | |
2474 | - revP[index-3] = revP[index](revP[index-2], revP[index-1]); | |
2475 | - revP.splice(index-2, 3); | |
2484 | + } else if (revP[index - 3] === 'dummy') { | |
2485 | + revP[index - 3] = revP[index](revP[index - 2], revP[index - 1]); | |
2486 | + revP.splice(index - 2, 3); | |
2476 | 2487 | index -= 3; |
2477 | 2488 | } |
2478 | 2489 | break; |
2479 | 2490 | |
2480 | - default : break; | |
2491 | + default : | |
2492 | + break; | |
2481 | 2493 | } |
2482 | 2494 | } |
2483 | 2495 |
@@ -2603,9 +2615,10 @@ | ||
2603 | 2615 | THIEF.html.refreshXy = function(x, y) { |
2604 | 2616 | var obj = THIEF.global.actLV.inventory[x][y].getLast(); |
2605 | 2617 | /* |
2606 | - if(typeof obj === 'undefined') { | |
2607 | - THIEF.html.setXy(x, y, '◙'); | |
2608 | - } else */ if (obj.color) { | |
2618 | + if(typeof obj === 'undefined') { | |
2619 | + THIEF.html.setXy(x, y, '◙'); | |
2620 | + } else */ | |
2621 | + if (obj.color) { | |
2609 | 2622 | THIEF.html.setXy(x, y, '<span style="color:' + obj.color + ';">' + obj.symbol + '</span>'); |
2610 | 2623 | } else { |
2611 | 2624 | THIEF.html.setXy(x, y, obj.symbol); |
@@ -2645,10 +2658,10 @@ | ||
2645 | 2658 | } |
2646 | 2659 | |
2647 | 2660 | |
2648 | - if(document.getElementById(THIEF.conf.id + 'Message' + (THIEF.conf.messageLines - 1)).innerHTML !== ' '){ | |
2661 | + if (document.getElementById(THIEF.conf.id + 'Message' + (THIEF.conf.messageLines - 1)).innerHTML !== ' ') { | |
2649 | 2662 | var prev; |
2650 | - for(var i=0; i<THIEF.conf.messageLines-1; i++){ | |
2651 | - prev = document.getElementById(THIEF.conf.id + 'Message' + (i+1) ).innerHTML || ' '; | |
2663 | + for (var i = 0; i < THIEF.conf.messageLines - 1; i++) { | |
2664 | + prev = document.getElementById(THIEF.conf.id + 'Message' + (i + 1)).innerHTML || ' '; | |
2652 | 2665 | document.getElementById(THIEF.conf.id + 'Message' + i).innerHTML = prev; |
2653 | 2666 | } |
2654 | 2667 | } |
@@ -2678,7 +2691,7 @@ | ||
2678 | 2691 | return function(text) { |
2679 | 2692 | |
2680 | 2693 | if (THIEF.conf.debugmode) { |
2681 | - if(typeof text === 'string'){ | |
2694 | + if (typeof text === 'string') { | |
2682 | 2695 | // 文字列が ... から開始する場合にはインデントを減らす |
2683 | 2696 | if (text.match(/^\.\.\./) && indent.length > 0) { |
2684 | 2697 | indent = indent.slice(24); |
@@ -2694,7 +2707,7 @@ | ||
2694 | 2707 | } else { |
2695 | 2708 | |
2696 | 2709 | var line = ''; |
2697 | - for(var i=0; i<hist.length; i++){ | |
2710 | + for (var i = 0; i < hist.length; i++) { | |
2698 | 2711 | line += hist[i] + '<br>\n'; |
2699 | 2712 | } |
2700 | 2713 | document.getElementById(THIEF.conf.id + 'Debug').innerHTML = line; |
@@ -2705,28 +2718,27 @@ | ||
2705 | 2718 | } |
2706 | 2719 | |
2707 | 2720 | /* |
2708 | - if(THIEF.conf.debugMessageClear){ | |
2709 | - document.getElementById(THIEF.conf.id + 'Debug').scrollTop = 0; | |
2710 | - } | |
2711 | - */ | |
2712 | - | |
2721 | + if(THIEF.conf.debugMessageClear){ | |
2722 | + document.getElementById(THIEF.conf.id + 'Debug').scrollTop = 0; | |
2723 | + } | |
2724 | + */ | |
2725 | + | |
2713 | 2726 | //document.getElementById(THIEF.conf.id + 'Debug').scrollTop = 65535; |
2714 | 2727 | //document.getElementById(THIEF.conf.id + 'Debug').offsetTop = 65535; |
2715 | 2728 | |
2716 | 2729 | |
2717 | - | |
2718 | 2730 | } |
2719 | 2731 | }; |
2720 | 2732 | }(); |
2721 | 2733 | |
2722 | 2734 | /* |
2723 | -THIEF.html.clearDebugMessage = function() { | |
2724 | - if (THIEF.conf.debugmode && THIEF.conf.debugMessageClear ) { | |
2725 | - document.getElementById(THIEF.conf.id + 'Debug').scrollTop = 0; | |
2726 | - //document.getElementById(THIEF.conf.id + 'Debug').innerHTML = ''; | |
2727 | - } | |
2728 | -}; | |
2729 | -*/ | |
2735 | + THIEF.html.clearDebugMessage = function() { | |
2736 | + if (THIEF.conf.debugmode && THIEF.conf.debugMessageClear ) { | |
2737 | + document.getElementById(THIEF.conf.id + 'Debug').scrollTop = 0; | |
2738 | + //document.getElementById(THIEF.conf.id + 'Debug').innerHTML = ''; | |
2739 | + } | |
2740 | + }; | |
2741 | + */ | |
2730 | 2742 | |
2731 | 2743 | THIEF.html.showCommandHelp = function() { |
2732 | 2744 | var help = ''; |
@@ -2734,7 +2746,7 @@ | ||
2734 | 2746 | help += '<tr><th colspan=3>Command Help</th></tr>\n'; |
2735 | 2747 | var com = []; |
2736 | 2748 | for (var name in THIEF.Data.Keymap) { |
2737 | - if(typeof THIEF.Data.Keymap[name].txt !== 'undefined'){ | |
2749 | + if (typeof THIEF.Data.Keymap[name].txt !== 'undefined') { | |
2738 | 2750 | com.push(name); |
2739 | 2751 | } |
2740 | 2752 | } |
@@ -2915,50 +2927,50 @@ | ||
2915 | 2927 | |
2916 | 2928 | /* Date オブジェクトのついて |
2917 | 2929 | |
2918 | -Data クラスはプリセットされたデータセットです。 | |
2919 | -配下には以下の三つの階層があります。 | |
2930 | + Data クラスはプリセットされたデータセットです。 | |
2931 | + 配下には以下の三つの階層があります。 | |
2920 | 2932 | |
2921 | -Data.Obj | |
2922 | - モンスターやアイテムの管理用 | |
2923 | -Data.Event | |
2924 | - イベントやシナリオの管理用 | |
2925 | -Data.Text | |
2926 | - ローカライズの管理用 | |
2927 | -Data.Prop | |
2928 | - 特殊変数の管理用 | |
2933 | + Data.Obj | |
2934 | + モンスターやアイテムの管理用 | |
2935 | + Data.Event | |
2936 | + イベントやシナリオの管理用 | |
2937 | + Data.Text | |
2938 | + ローカライズの管理用 | |
2939 | + Data.Prop | |
2940 | + 特殊変数の管理用 | |
2929 | 2941 | |
2930 | -Data.Obj 配下の $ から始まるオブジェクトは、テンプレートとして扱われます。 | |
2931 | - ※ スポーンの対象にならない・一覧に表示されない、など | |
2942 | + Data.Obj 配下の $ から始まるオブジェクトは、テンプレートとして扱われます。 | |
2943 | + ※ スポーンの対象にならない・一覧に表示されない、など | |
2932 | 2944 | |
2933 | -Date.Obj 配下に格納されるオブジェクトは、 | |
2934 | -自動的に THIEF.func.command, THIEF.func.method 内のメソッドを継承し、その対象になります。 | |
2935 | -その為、すべてのオブジェクトが eat や wear メソッドの対象になります。 | |
2936 | - ※ 各コマンド名に -able をつけたプロパティ (eatable, wearable) の | |
2937 | - Boolean値 (true/false) に応じて動作します。 | |
2945 | + Date.Obj 配下に格納されるオブジェクトは、 | |
2946 | + 自動的に THIEF.func.command, THIEF.func.method 内のメソッドを継承し、その対象になります。 | |
2947 | + その為、すべてのオブジェクトが eat や wear メソッドの対象になります。 | |
2948 | + ※ 各コマンド名に -able をつけたプロパティ (eatable, wearable) の | |
2949 | + Boolean値 (true/false) に応じて動作します。 | |
2938 | 2950 | |
2939 | -オブジェクト内に inheritance プロパティがあると、 | |
2940 | -そのオブジェクトも継承します。 | |
2941 | -inheritance は文字列で指定してください。 | |
2942 | - ※ inheritance : 'Human' | |
2943 | -何もない場合は、Date.Obj.$を継承します。 | |
2951 | + オブジェクト内に inheritance プロパティがあると、 | |
2952 | + そのオブジェクトも継承します。 | |
2953 | + inheritance は文字列で指定してください。 | |
2954 | + ※ inheritance : 'Human' | |
2955 | + 何もない場合は、Date.Obj.$を継承します。 | |
2944 | 2956 | |
2945 | -プロパティは以下の順番で参照されます。 | |
2946 | - ※ Object -> THIEF.func.command -> THIEF.func.method -> Date.Obj.$ -> Date.Obj.Human -> this | |
2957 | + プロパティは以下の順番で参照されます。 | |
2958 | + ※ Object -> THIEF.func.command -> THIEF.func.method -> Date.Obj.$ -> Date.Obj.Human -> this | |
2947 | 2959 | |
2948 | -現段階では、多段的な階層はサポートしていません。 | |
2949 | -今後もするつもりはありません。 | |
2950 | - ※ Date.Monster.Humanoid.Elf | |
2960 | + 現段階では、多段的な階層はサポートしていません。 | |
2961 | + 今後もするつもりはありません。 | |
2962 | + ※ Date.Monster.Humanoid.Elf | |
2951 | 2963 | |
2952 | -$ (テンプレート) 以外のオブジェクトも、実質的にはテンプレートとして扱われます。 | |
2953 | -オブジェクトの使用時にマスターオブジェクトが作成され、 | |
2954 | -以降はそれをクローニングしてスポーン処理などを行います。 | |
2964 | + $ (テンプレート) 以外のオブジェクトも、実質的にはテンプレートとして扱われます。 | |
2965 | + オブジェクトの使用時にマスターオブジェクトが作成され、 | |
2966 | + 以降はそれをクローニングしてスポーン処理などを行います。 | |
2955 | 2967 | |
2956 | -そのため、起動後に Date 内のオブジェクトを修正した場合、 | |
2957 | -その結果が新しいインスタンスには反映されません。 | |
2968 | + そのため、起動後に Date 内のオブジェクトを修正した場合、 | |
2969 | + その結果が新しいインスタンスには反映されません。 | |
2958 | 2970 | |
2959 | -Data.Obj 配下のオブジェクトのプロパティ値が _ から始まる場合、 | |
2960 | -数式として処理されます。 | |
2961 | - str : '_3d6' | |
2971 | + Data.Obj 配下のオブジェクトのプロパティ値が _ から始まる場合、 | |
2972 | + 数式として処理されます。 | |
2973 | + str : '_3d6' | |
2962 | 2974 | |
2963 | 2975 | */ |
2964 | 2976 |
@@ -2968,7 +2980,7 @@ | ||
2968 | 2980 | THIEF.Data.Prop = { // 特殊変数登録用 |
2969 | 2981 | displayName : function() { |
2970 | 2982 | var text = ''; |
2971 | - if(this.equiped){ | |
2983 | + if (this.equiped) { | |
2972 | 2984 | text += '[E] ' |
2973 | 2985 | } |
2974 | 2986 | text += this.get(THIEF.PROP.name) + '(<span style="color:' + this.get(THIEF.PROP.color) + '">' + this.get(THIEF.PROP.symbol) + '</span>)'; |
@@ -2979,19 +2991,19 @@ | ||
2979 | 2991 | var val = 0; |
2980 | 2992 | |
2981 | 2993 | // 体力に応じたダメージボーナス |
2982 | - if(typeof this.con === 'undefined') { | |
2994 | + if (typeof this.con === 'undefined') { | |
2983 | 2995 | //val += 0; |
2984 | 2996 | } else if (this.con >= 18) { |
2985 | 2997 | val += (this.con / 6); |
2986 | - } else if (this.con >= 17 ) { | |
2998 | + } else if (this.con >= 17) { | |
2987 | 2999 | val += 2; |
2988 | - } else if (this.con >= 15 ) { | |
3000 | + } else if (this.con >= 15) { | |
2989 | 3001 | val += 1; |
2990 | - } else if (this.con >=7 ) { | |
3002 | + } else if (this.con >= 7) { | |
2991 | 3003 | //val += 0; |
2992 | - } else if (this.con >=4 ) { | |
3004 | + } else if (this.con >= 4) { | |
2993 | 3005 | val += -1; |
2994 | - } else if (this.con >=3 ) { | |
3006 | + } else if (this.con >= 3) { | |
2995 | 3007 | val += -2; |
2996 | 3008 | } else if (this.con < 3) { |
2997 | 3009 | val += -3; |
@@ -2998,9 +3010,9 @@ | ||
2998 | 3010 | } |
2999 | 3011 | |
3000 | 3012 | // 腕力、サイズに応じたダメージボーナス |
3001 | - if(typeof this.str === 'undefined'){ | |
3013 | + if (typeof this.str === 'undefined') { | |
3002 | 3014 | //val += 0; |
3003 | - } else if (typeof this.siz === 'undefined'){ | |
3015 | + } else if (typeof this.siz === 'undefined') { | |
3004 | 3016 | // STR のみ定義されている場合 |
3005 | 3017 | if (this.str >= 25) { |
3006 | 3018 | val += (this.str / 2.27); |
@@ -3020,19 +3032,19 @@ | ||
3020 | 3032 | } else { |
3021 | 3033 | // STR と SIZ の両方が定義されている場合 |
3022 | 3034 | var num = this.str + this.siz; |
3023 | - if(num >= 57){ | |
3024 | - val += Math.dice( 2 + Math.floor((num-41)/16), 6); | |
3025 | - } else if(num >= 41){ | |
3035 | + if (num >= 57) { | |
3036 | + val += Math.dice(2 + Math.floor((num - 41) / 16), 6); | |
3037 | + } else if (num >= 41) { | |
3026 | 3038 | val += Math.dice(2, 6); |
3027 | - } else if(num >= 33){ | |
3039 | + } else if (num >= 33) { | |
3028 | 3040 | val += Math.dice(1, 6); |
3029 | - } else if(num >= 25){ | |
3041 | + } else if (num >= 25) { | |
3030 | 3042 | val += Math.dice(1, 4); |
3031 | - } else if(num >= 17){ | |
3043 | + } else if (num >= 17) { | |
3032 | 3044 | //val += 0; |
3033 | - } else if(num >= 13){ | |
3045 | + } else if (num >= 13) { | |
3034 | 3046 | val += -Math.dice(1, 4); |
3035 | - } else if(num >= 0){ | |
3047 | + } else if (num >= 0) { | |
3036 | 3048 | val += -Math.dice(1, 6); |
3037 | 3049 | } |
3038 | 3050 | } |
@@ -3045,9 +3057,9 @@ | ||
3045 | 3057 | |
3046 | 3058 | armorPoint : function () { |
3047 | 3059 | var val = 0; |
3048 | - if(typeof this.slot !== 'undefined'){ | |
3049 | - for(var slotName in this.slot){ | |
3050 | - if(typeof this.slot[slotName].ac === 'number') { | |
3060 | + if (typeof this.slot !== 'undefined') { | |
3061 | + for (var slotName in this.slot) { | |
3062 | + if (typeof this.slot[slotName].ac === 'number') { | |
3051 | 3063 | val += this.slot[slotName].ac; |
3052 | 3064 | } |
3053 | 3065 | } |
@@ -3381,14 +3393,15 @@ | ||
3381 | 3393 | */ |
3382 | 3394 | |
3383 | 3395 | |
3396 | +//noinspection JSUnusedGlobalSymbols | |
3384 | 3397 | THIEF.Data.Keymap = { |
3385 | 3398 | $ : { // help |
3386 | 3399 | ja : '' + |
3387 | - 'y k u' + ' ' + 'yuhjklbn: 指定方向に一歩歩く' + '<br>\n' + | |
3400 | + 'y k u' + ' ' + 'yuhjklbn: 指定方向に一歩歩く' + '<br>\n' + | |
3388 | 3401 | ' ⃥|/ ' + ' ' + '←↑↓→: 同' + '<br>\n' + |
3389 | - 'h-.-k' + ' ' + 'Home,End,PageUp,PageDown: 斜め方向に一歩歩く' + '<br>\n' + | |
3402 | + 'h-.-k' + ' ' + 'Home,End,PageUp,PageDown: 斜め方向に一歩歩く' + '<br>\n' + | |
3390 | 3403 | ' /|⃥ ' + ' ' + '.: 何もしない' + '<br>\n' + |
3391 | - 'b j n' + ' ' + '' + '<br>\n' | |
3404 | + 'b j n' + ' ' + '' + '<br>\n' | |
3392 | 3405 | }, |
3393 | 3406 | moveUp1 : { |
3394 | 3407 | cmd : THIEF.func.command.goUp, |
@@ -3482,7 +3495,7 @@ | ||
3482 | 3495 | en : 'show messages history' |
3483 | 3496 | } |
3484 | 3497 | }, |
3485 | - RrefreshScreen : { | |
3498 | + RrefreshScreen : { | |
3486 | 3499 | cmd : THIEF.func.command.refreshHTML, |
3487 | 3500 | key : THIEF.KEY.R, |
3488 | 3501 | txt : { |
@@ -3516,7 +3529,6 @@ | ||
3516 | 3529 | } |
3517 | 3530 | }; |
3518 | 3531 | |
3519 | -// TODO | |
3520 | 3532 | THIEF.Data.Text = { |
3521 | 3533 | attack : { |
3522 | 3534 | // 1 : damage |
@@ -3525,7 +3537,7 @@ | ||
3525 | 3537 | // ja : [ |
3526 | 3538 | // '${3} は ${2} に ${1} のダメージを与えた。', |
3527 | 3539 | // '${2} は ${1} のダメージを受けた。' |
3528 | - // ], | |
3540 | + // ], | |
3529 | 3541 | ja : '${3} は ${2} に ${1} のダメージを与えた。', |
3530 | 3542 | en : '${2} Hit decreased by ${1}.' |
3531 | 3543 | }, |
@@ -3596,7 +3608,7 @@ | ||
3596 | 3608 | ja : '"${1}" というコマンドは存在しません。', |
3597 | 3609 | en : '"${1}" command not found.' |
3598 | 3610 | }, |
3599 | - | |
3611 | + | |
3600 | 3612 | decay : { |
3601 | 3613 | // 1 : subject |
3602 | 3614 | ja : '${1} は腐りきった。', |
@@ -3626,4 +3638,68 @@ | ||
3626 | 3638 | } |
3627 | 3639 | }; |
3628 | 3640 | |
3629 | -THIEF.Data.Event = {}; // Event & Scenario | |
3641 | +/* | |
3642 | + | |
3643 | +// 独自追加パラメータ | |
3644 | +Height: その(配下の)マップの縦幅 | |
3645 | +Width: その(配下の)マップの横幅 | |
3646 | + | |
3647 | +// とりあえず NetHack Wiki から引っ張ってきた変数一覧 | |
3648 | +http://nethackwiki.com/wiki/Dungeon.def_format | |
3649 | +ALIGNMENT | |
3650 | +BRANCH | |
3651 | +CHAINBRANCH | |
3652 | +CHAINLEVEL | |
3653 | +DESCRIPTION | |
3654 | +DUNGEON | |
3655 | +LEVALIGN | |
3656 | +LEVEL | |
3657 | +LEVELDESC | |
3658 | +PROTOFILE | |
3659 | +RNDLEVEL | |
3660 | + | |
3661 | +http://nethackwiki.com/wiki/Des-file_format | |
3662 | +ALTAR | |
3663 | +BRANCH | |
3664 | +CHANCE | |
3665 | +CONTAINER | |
3666 | +DOOR | |
3667 | +DRAWBRIDGE | |
3668 | +ENDMAP | |
3669 | +ENGRAVING | |
3670 | +FLAGS | |
3671 | +FOUNTAIN | |
3672 | +GEOMETRY | |
3673 | +GOLD | |
3674 | +INIT_MAP | |
3675 | +LADDER | |
3676 | +LEVEL | |
3677 | +MAP | |
3678 | +MAZE | |
3679 | +MAZEWALK | |
3680 | +MESSAGE | |
3681 | +MONSTER | |
3682 | +NAME | |
3683 | +NOMAP | |
3684 | +NON_DIGGABLE | |
3685 | +NON_PASSWALL | |
3686 | +OBJECT | |
3687 | +PORTAL | |
3688 | +RANDOM_CORRIDORS | |
3689 | +RANDOM_MONSTERS | |
3690 | +RANDOM_OBJECTS | |
3691 | +RANDOM_PLACES | |
3692 | +REGION | |
3693 | +ROOM | |
3694 | +SINK | |
3695 | +STAIR | |
3696 | +SUBROOM | |
3697 | +TELEPORT_REGION | |
3698 | +TRAP | |
3699 | +WALLIFY | |
3700 | + | |
3701 | +*/ | |
3702 | + | |
3703 | +THIEF.Data.Event = { | |
3704 | + | |
3705 | +}; |