• R/O
  • SSH
  • HTTPS

thief: Commit


Commit MetaInfo

Revision29 (tree)
Time2012-01-08 23:24:25
Authorseussnu

Log Message

0.0.7-alpha8
・ シナリオの読み込み処理を追加中

Change Summary

Incremental Difference

--- thief.js (revision 28)
+++ thief.js (revision 29)
@@ -8,13 +8,13 @@
88 modification, are permitted provided that the following conditions are met:
99
1010 * Redistributions of source code must retain the above copyright notice,
11- this list of conditions and the following disclaimer.
11+ this list of conditions and the following disclaimer.
1212 * Redistributions in binary form must reproduce the above copyright notice,
13- this list of conditions and the following disclaimer in the documentation
14- and/or other materials provided with the distribution.
13+ this list of conditions and the following disclaimer in the documentation
14+ and/or other materials provided with the distribution.
1515 * Neither the name of the H.AltProject nor the names of its contributors
16- may be used to endorse or promote products derived from this software
17- without specific prior written permission.
16+ may be used to endorse or promote products derived from this software
17+ without specific prior written permission.
1818
1919 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2020 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
@@ -72,6 +72,7 @@
7272
7373 global : {
7474 actLV : null,
75+ actDG : null,
7576 turn : 0,
7677 keycode : NaN,
7778 hist : [],
@@ -589,12 +590,14 @@
589590
590591 THIEF.func.method.delInventoryXyObject = function(x, y, o) {
591592 this.inventory[x][y].remove(o);
592- if (this.mapRefreshPointList) {
593- this.mapRefreshPointList.push({
594- x: x,
595- y: y
596- });
597- }
593+ /*
594+ if (this.mapRefreshPointList) {
595+ this.mapRefreshPointList.push({
596+ x: x,
597+ y: y
598+ });
599+ }
600+ */
598601 };
599602
600603 // ループ処理を加えること
@@ -1448,6 +1451,8 @@
14481451 };
14491452
14501453 THIEF.util = {};
1454+
1455+// TODO
14511456 THIEF.util.init = function() {
14521457
14531458 THIEF.html.addDebugMessage('<em>初期化(ターン0)を開始</em>...');
@@ -1460,7 +1465,15 @@
14601465 //THIEF.conf.language = 'en';
14611466
14621467 // 初期レベルの生成
1463- THIEF.global.actLV = THIEF.util.createLevel();
1468+ var lv = THIEF.util.factory(THIEF.Data.Obj.$Level);
1469+ //lv.mapRefreshPointList = [];
1470+ lv.inventory = THIEF.util.createMap(THIEF.conf.mapWidth, THIEF.conf.mapHeight);
1471+ lv[THIEF.PROP.name] = {ja:'テストレベル', en:'Practice'};
1472+ lv[THIEF.PROP.inventoryWidth] = THIEF.conf.mapWidth;
1473+ lv[THIEF.PROP.inventoryHeight] = THIEF.conf.mapHeight;
1474+ lv[THIEF.PROP.inventoryDepth] = THIEF.conf.mapDepth;
1475+ lv.inventoryCellSize = 1;
1476+ THIEF.global.actLV = lv;
14641477
14651478 // HTML タグ初期化
14661479 THIEF.html.init();
@@ -1470,6 +1483,8 @@
14701483
14711484 // テスト用コードの実行
14721485 THIEF.util.test();
1486+
1487+
14731488 THIEF.html.refresh();
14741489
14751490 // 1 ターン目開始
@@ -1481,6 +1496,7 @@
14811496
14821497 };
14831498
1499+
14841500 THIEF.util.test = function() {
14851501 THIEF.global.adventurer = THIEF.util.factory(THIEF.Data.Obj.Human);
14861502 THIEF.global.adventurer.color = 'red';
@@ -1834,37 +1850,126 @@
18341850 };
18351851 }();
18361852
1837-// TODO
18381853 THIEF.util.loadScenario = function () {
1839- //for (var name in THIEF.Data.Scenario[THIEF.Data.Scenario.$.start]) {
18401854 THIEF.html.addDebugMessage('シナリオ読み込み開始...');
1841- var start = THIEF.Data.Scenario[THIEF.Data.Scenario.$.start];
1842- for (var i = 0; i < start.hierarchy.length; i++) {
1843- if (typeof start.hierarchy[i].level === 'undefined') {
1844- THIEF.html.addDebugMessage(start.hierarchy[i].base + ' に分岐レベル作成');
1845- } else {
1846- THIEF.html.addDebugMessage(start.hierarchy[i].base + ' に特殊レベル作成');
1855+ THIEF.util.createDungeon(THIEF.Data.Scenario[THIEF.Data.Scenario.$.root]);
18471856
1848- }
1849- }
1857+ THIEF.global.actDG = THIEF.Data.Scenario[THIEF.Data.Scenario.$.root];
1858+
1859+ THIEF.html.addDebugMessage('開始レベルを作成開始...');
1860+ THIEF.util.createLevel(THIEF.global.actDG, THIEF.global.actDG.nowLV);
1861+ THIEF.html.addDebugMessage('...開始レベルを作成完了');
18501862 THIEF.html.addDebugMessage('...シナリオ読み込み完了');
18511863 };
18521864
1853-THIEF.util.createDungeon = function () {
1865+THIEF.util.createDungeon = function (dun) {
1866+ THIEF.html.addDebugMessage('ダンジョン(' + THIEF.func.method.get.call(dun, THIEF.PROP.name) + ')を作成...');
18541867
1868+ // 開始レベルは 1
1869+ dun.nowLV = dun.startLevel || 1;
1870+
1871+ if (dun.hierarchy) {
1872+ for (var i = 0; i < dun.hierarchy.length; i++) {
1873+ var base = dun.hierarchy[i].base;
1874+ var range = dun.hierarchy[i].range || 0;
1875+ var chance = dun.hierarchy[i].chance || 100;
1876+
1877+ if (chance > Math.random() * 100) {
1878+
1879+ // シナリオの場所決定
1880+ var rand = 0;
1881+ for (var j = 0; j < range * 2; j++) {
1882+ rand = Math.round(Math.random() * range - 0.5);
1883+ if (typeof dun[base + rand] === 'undefined') {
1884+ break;
1885+ }
1886+
1887+ if (j === range * 2 - 1) {
1888+ for (var k = 0; k < range; k++) {
1889+ if (typeof dun[base + k] === 'undefined') {
1890+ rand = k;
1891+ break;
1892+ }
1893+ }
1894+ }
1895+ }
1896+ if (typeof dun[base + rand] === 'undefined') {
1897+ THIEF.html.addDebugMessage('第 ' + (base + rand) + ' レベルに個別シナリオを格納');
1898+ dun[base + rand] = dun.hierarchy[i];
1899+
1900+ if (dun.hierarchy[i].branch) {
1901+ THIEF.util.createDungeon(THIEF.Data.Scenario[dun.hierarchy[i].branch]);
1902+ }
1903+
1904+ } else {
1905+ THIEF.html.addDebugMessage('base + range の範囲内に開いているレベルがありません。');
1906+ }
1907+
1908+ if (dun.hierarchy.branch && dun.hierarchy.map) {
1909+ // 未実装
1910+ }
1911+
1912+ } else {
1913+ THIEF.html.addDebugMessage(dun.hierarchy[i].level + ' or ' + dun.hierarchy[i].branch + ' は作成しません。');
1914+ }
1915+ }
1916+ }
1917+ THIEF.html.addDebugMessage('...ダンジョンの作成を完了');
18551918 };
18561919
1857-THIEF.util.createLevel = function() {
1920+// TODO
1921+THIEF.util.createLevel = function(dun, lvNum) {
1922+ THIEF.html.addDebugMessage(THIEF.func.method.get.call(dun, THIEF.PROP.name) + 'の第 ' + lvNum + ' レベルを作成...');
18581923
1859- var lv = THIEF.util.factory(THIEF.Data.Obj.$Level);
1860- lv.mapRefreshPointList = [];
1861- lv.inventory = THIEF.util.createMap(THIEF.conf.mapWidth, THIEF.conf.mapHeight);
1862- lv[THIEF.PROP.name] = {ja:'テストレベル', en:'Practice'};
1863- lv[THIEF.PROP.inventoryWidth] = THIEF.conf.mapWidth;
1864- lv[THIEF.PROP.inventoryHeight] = THIEF.conf.mapHeight;
1865- lv[THIEF.PROP.inventoryDepth] = THIEF.conf.mapDepth;
1866- lv.inventoryCellSize = 1;
1867- return lv;
1924+ var level = THIEF.util.factory(THIEF.Data.Obj.$Level);
1925+ level[THIEF.PROP.inventoryWidth] = dun.width || THIEF.Data.Scenario.$.width || 60;
1926+ level[THIEF.PROP.inventoryHeight] = dun.height || THIEF.Data.Scenario.$.height || 20;
1927+ level[THIEF.PROP.inventoryDepth] = dun.depth || THIEF.Data.Scenario.$.depth || 256;
1928+ level.inventoryCellSize = 1;
1929+
1930+ if (dun[lvNum]) {
1931+ THIEF.html.addDebugMessage('個別シナリオのテンプレート展開...');
1932+ if (dun[lvNum].level) {
1933+ var template;
1934+ if (dun[lvNum].level instanceof Array) {
1935+ template = {};
1936+ THIEF.html.addDebugMessage('複数のテンプレートがしていされているため逐次的に書式コピー');
1937+ for (var i = 0; i < dun[lvNum].level.length; i++) {
1938+ for (var name in THIEF.Data.Scenario.$Template[dun[lvNum].level[i]]) {
1939+ template[name] = THIEF.Data.Scenario.$Template[dun[lvNum].level[i]][name]
1940+ }
1941+ }
1942+ } else {
1943+ template = dun[lvNum].level;
1944+ }
1945+
1946+ // テンプレートに基づいて処理を実行
1947+ for (var temp in template) {
1948+ THIEF.html.addDebugMessage(temp + '.');
1949+ switch (temp) {
1950+ case 'map' :
1951+ break;
1952+ case 'messages':
1953+ break;
1954+ default:
1955+ break;
1956+ }
1957+ }
1958+
1959+ } else {
1960+ // 特殊分岐実装予定
1961+ }
1962+
1963+ THIEF.html.addDebugMessage('...展開完了。');
1964+ } else {
1965+ level.inventory = THIEF.util.createMap(level[THIEF.PROP.inventoryWidth], level[THIEF.PROP.inventoryHeight]);
1966+ }
1967+
1968+ if (dun[lvNum].branch) {
1969+
1970+ }
1971+
1972+ THIEF.html.addDebugMessage('...レベルの作成を完了');
18681973 };
18691974
18701975 THIEF.util.createMap = function(width, height) {
@@ -2506,9 +2611,9 @@
25062611
25072612 // 書式選択
25082613 // 選択した言語に、複数の書式があるか確認
2509- if (text.constructor === Array) {
2614+ if (text instanceof Array) {
25102615 var num = Math.floor(Math.random() * text.length);
2511- THIEF.html.addDebugMessage(text.length + ' 個の選択肢から ' + num + ' 番目のテキストを選択');
2616+ THIEF.html.addDebugMessage(text.length + ' 個の選択肢から ' + (num + 1) + ' 番目のテキストを選択');
25122617 text = text[num];
25132618 }
25142619
@@ -2964,11 +3069,11 @@
29643069 // 1 : damage
29653070 // 2 : subject
29663071 // 3 : from
2967-// ja : [
2968-// '${3} は ${2} に ${1} のダメージを与えた。',
2969-// '${2} は ${1} のダメージを受けた。'
2970- // ],
2971- ja : '${3} は ${2} に ${1} のダメージを与えた。',
3072+ ja : [
3073+ '${3} は ${2} に ${1} のダメージを与えた。',
3074+ '${2} は ${1} のダメージを受けた。'
3075+ ],
3076+ //ja : '${3} は ${2} に ${1} のダメージを与えた。',
29723077 en : '${2} Hit decreased by ${1}.'
29733078 },
29743079 defence : {
@@ -3552,9 +3657,9 @@
35523657 $ : { // help
35533658 ja : '' +
35543659 'y&nbsp;k&nbsp;u' + '&nbsp;&nbsp;&nbsp;&nbsp;' + 'yuhjklbn: 指定方向に一歩歩く' + '<br>\n' +
3555- '&nbsp;&#x20E5;|/&nbsp;' + '&nbsp;&nbsp;&nbsp;&nbsp;' + '←↑↓→: 同' + '<br>\n' +
3660+ '&nbsp;&#x2572;|&#x2571;&nbsp;' + '&nbsp;&nbsp;&nbsp;&nbsp;' + '←↑↓→: 同' + '<br>\n' +
35563661 'h-.-k' + '&nbsp;&nbsp;&nbsp;&nbsp;' + 'Home,End,PageUp,PageDown: 斜め方向に一歩歩く' + '<br>\n' +
3557- '&nbsp;/|&#x20E5;&nbsp;' + '&nbsp;&nbsp;&nbsp;&nbsp;' + '.: 何もしない' + '<br>\n' +
3662+ '&nbsp;&#x2571;|&#x2572;&nbsp;' + '&nbsp;&nbsp;&nbsp;&nbsp;' + '.: 何もしない' + '<br>\n' +
35583663 'b&nbsp;j&nbsp;n' + '&nbsp;&nbsp;&nbsp;&nbsp;' + '' + '<br>\n'
35593664 },
35603665 moveUp1 : {
@@ -3730,7 +3835,10 @@
37303835 THIEF.Data.Scenario = {
37313836
37323837 $ : {
3733- start : 'TheDungeon'
3838+ root : 'TheDungeon',
3839+ width : 60,
3840+ height : 20,
3841+ depth : 256
37343842 },
37353843
37363844 TheDungeon : {
@@ -3738,10 +3846,10 @@
37383846 levelNum : 10,
37393847 startLevel : 2,
37403848 hierarchy : [
3741- {level : ['First', 'SmallRoom'], base : 2 },
3849+ {level : ['First', 'SmallRoom'], base : 2},
37423850 {branch : 'SideRoad', base : 3, dir : 'down'},
3743- {level : 'SmallRoom', base : 4, range :2, chance : 75},
3744- {level : 'BigRoom', base : 7 }
3851+ {level : 'SmallRoom', base : 4, range :3},
3852+ {level : 'BigRoom', base : 7, chance : 50}
37453853 ]
37463854 },
37473855
@@ -3749,7 +3857,10 @@
37493857 name : THIEF.Data.Text.sceSideRoadName,
37503858 levelNum : 3,
37513859 width : 60,
3752- height : 10
3860+ height : 10,
3861+ hierarchy : [
3862+ {level : 'SmallRoom', base : 1}
3863+ ]
37533864 },
37543865
37553866
Show on old repository browser