• R/O
  • SSH
  • HTTPS

thief: Commit


Commit MetaInfo

Revision30 (tree)
Time2012-01-09 23:52:05
Authorseussnu

Log Message

0.0.7-alpha9
・ シナリオの読み込み処理を追加中
・ いくつかのコマンドのターン処理にミスがあったので修正
・ 階段の昇降処理を追加中

Change Summary

Incremental Difference

--- thief.js (revision 29)
+++ thief.js (revision 30)
@@ -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,
@@ -472,7 +472,8 @@
472472 if (this.inventory && this.inventory[targetX] && this.inventory[targetX][targetY]) {
473473 if (this.inventory[targetX][targetY].length <= invDepth) {
474474 var lastObj = this.inventory[targetX][targetY].getLast();
475- if (obj.get(THIEF.PROP.stackable) || typeof lastObj === 'undefined' || lastObj.get(THIEF.PROP.stackable) /* || !lastObj.get(THIEF.PARAM.mergeable) */) {
475+ // TODO
476+ if (lastObj.type !== THIEF.Data.Obj.$Wall.type && (obj.get(THIEF.PROP.stackable) || typeof lastObj === 'undefined' || lastObj.get(THIEF.PROP.stackable)) /* || !lastObj.get(THIEF.PARAM.mergeable) */) {
476477 if (lastObj) {
477478 THIEF.html.addDebugMessage('[' + targetX + ', ' + targetY + ']にある' + lastObj.get(THIEF.PROP.displayName) + 'には重ねられる。');
478479 } else {
@@ -845,6 +846,7 @@
845846
846847 THIEF.func.method.move = function(dx, dy) {
847848
849+ var result;
848850 THIEF.html.addDebugMessage('移動処理 move(' + dx + ', ' + dy + ') を開始...');
849851
850852 THIEF.html.addDebugMessage(THIEF.global.actLV.get(THIEF.PROP.displayName) + 'のインベントリ座標[' + (this.x + dx) + ', ' + (this.y + dy) + ']を調査を行う。');
@@ -868,19 +870,22 @@
868870 THIEF.html.refreshXy(this.x, this.y);
869871
870872 this.ct -= 60;
873+ result = true;
871874
872875 } else {
873876 if (target.get(THIEF.PROP.active)) {
874877 THIEF.html.addDebugMessage('active なものが対象なので攻撃してみる。');
875878 target.attackedBy(this);
879+ result = true;
876880 } else {
877881 THIEF.html.addDebugMessage('インベントリ座標[' + (this.x + dx) + ', ' + (this.y + dy) + '] には移動できない。');
882+ result = false;
878883 }
879884 }
880885
881886 THIEF.html.addDebugMessage('...移動処理を完了。');
882887
883- return true;
888+ return result;
884889 };
885890
886891 THIEF.func.method.inputWait = function () {
@@ -1016,7 +1021,7 @@
10161021
10171022 THIEF.func.method.manual = function() {
10181023
1019- var finish = true;
1024+ var finish;
10201025 var code = THIEF.global.keycode;
10211026
10221027 if (code === 0) {
@@ -1034,6 +1039,9 @@
10341039 }
10351040
10361041 if (typeof finish === 'undefined') {
1042+ if(code !== THIEF.KEY.Esc){
1043+ THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.commandNotFound, String.fromCharCode(code)));
1044+ }
10371045 finish = false;
10381046 }
10391047 THIEF.html.addDebugMessage('...' + String.fromCharCode(code) + '(' + code + ')の入力に対する処理を完了。(return : ' + finish + ')');
@@ -1382,6 +1390,7 @@
13821390 return finish;
13831391 };
13841392
1393+ return false;
13851394 };
13861395
13871396 THIEF.func.command.equip = function () {
@@ -1448,11 +1457,43 @@
14481457 } else {
14491458 THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.inventoryIsEmpty));
14501459 }
1460+
1461+ return false;
14511462 };
14521463
1464+// TODO
1465+THIEF.func.command.goUpTheStairs = function(){
1466+ var floor = THIEF.global.actLV.getInventoryXyObjects(this.x, this.y);
1467+ var stairs;
1468+ var flag = false;
1469+ for(var i=0; i<floor.length; i++){
1470+ if(floor[i].symbol === THIEF.Data.Obj.UpStairs.symbol){
1471+ flag = true;
1472+ stairs = floor[i];
1473+ break;
1474+ }
1475+ }
1476+
1477+ if(flag){
1478+ THIEF.html.addMessage(THIEF.Data.Text.goUpStairs);
1479+ THIEF.util.createLevel(stairs.nextDun, stairs.nextLv);
1480+ THIEF.global.actLV.removeFromInventory(this);
1481+ THIEF.global.actDG = stairs.nextDun;
1482+ THIEF.global.actLV = stairs.nextLv;
1483+ THIEF.global.actLV.addToInventory(this);
1484+ } else {
1485+ THIEF.html.addMessage(THIEF.Data.Text.doesNotGoUpStairs);
1486+ }
1487+
1488+ return flag;
1489+};
1490+
1491+THIEF.func.command.goDownTheStairs = function(){
1492+
1493+};
1494+
14531495 THIEF.util = {};
14541496
1455-// TODO
14561497 THIEF.util.init = function() {
14571498
14581499 THIEF.html.addDebugMessage('<em>初期化(ターン0)を開始</em>...');
@@ -1464,16 +1505,8 @@
14641505
14651506 //THIEF.conf.language = 'en';
14661507
1467- // 初期レベルの生成
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;
1508+ // シナリオの読み込み
1509+ THIEF.util.loadScenario();
14771510
14781511 // HTML タグ初期化
14791512 THIEF.html.init();
@@ -1498,6 +1531,8 @@
14981531
14991532
15001533 THIEF.util.test = function() {
1534+
1535+
15011536 THIEF.global.adventurer = THIEF.util.factory(THIEF.Data.Obj.Human);
15021537 THIEF.global.adventurer.color = 'red';
15031538 THIEF.global.adventurer.next = THIEF.global.adventurer.inputWait;
@@ -1528,9 +1563,6 @@
15281563 THIEF.util.spawn(THIEF.Data.Obj.DebugHighArmor);
15291564 THIEF.util.spawn(THIEF.Data.Obj.DebugHighDagger);
15301565
1531-
1532- THIEF.util.loadScenario();
1533-
15341566 };
15351567
15361568 THIEF.util.next = function () {
@@ -1708,7 +1740,7 @@
17081740 //THIEF.html.addDebugMessage('オブジェクトの生成処理を開始...');
17091741 //THIEF.html.addDebugMessage('マスターの有無を確認...');
17101742
1711- if (typeof obj.uniqNumber === 'undefined') {
1743+ if (typeof obj !== 'undefined' && typeof obj.uniqNumber === 'undefined') {
17121744 THIEF.html.addDebugMessage('要求オブジェクトのマスタが存在しないので作成開始...');
17131745
17141746 var inh = obj.inheritance || '$';
@@ -1858,6 +1890,9 @@
18581890
18591891 THIEF.html.addDebugMessage('開始レベルを作成開始...');
18601892 THIEF.util.createLevel(THIEF.global.actDG, THIEF.global.actDG.nowLV);
1893+
1894+ THIEF.global.actLV = THIEF.global.actDG[THIEF.global.actDG.nowLV];
1895+
18611896 THIEF.html.addDebugMessage('...開始レベルを作成完了');
18621897 THIEF.html.addDebugMessage('...シナリオ読み込み完了');
18631898 };
@@ -1929,10 +1964,11 @@
19291964
19301965 if (dun[lvNum]) {
19311966 THIEF.html.addDebugMessage('個別シナリオのテンプレート展開...');
1967+ var template = {};
1968+
1969+ // レベル系テンプレートの読み込み
19321970 if (dun[lvNum].level) {
1933- var template;
19341971 if (dun[lvNum].level instanceof Array) {
1935- template = {};
19361972 THIEF.html.addDebugMessage('複数のテンプレートがしていされているため逐次的に書式コピー');
19371973 for (var i = 0; i < dun[lvNum].level.length; i++) {
19381974 for (var name in THIEF.Data.Scenario.$Template[dun[lvNum].level[i]]) {
@@ -1942,26 +1978,49 @@
19421978 } else {
19431979 template = dun[lvNum].level;
19441980 }
1981+ }
19451982
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- }
1983+ // 分岐系テンプレートの読み込み
1984+ if (dun[lvNum].branch) {
1985+ // 特殊分岐実装予定
1986+ }
19581987
1988+ // テンプレートに基づいて処理を実行
1989+ // for (name in obj) は、オンオフの処理が後々面倒になりそうなので、
1990+ // ここで逐次処理にする
1991+ if(template.map) {
1992+ level.inventory = THIEF.util.mapParser(template.map);
1993+ level[THIEF.PROP.inventoryWidth] = level.inventory.length;
1994+ level[THIEF.PROP.inventoryHeight] = level.inventory[0].length;
19591995 } else {
1960- // 特殊分岐実装予定
1996+ level.inventory = THIEF.util.createMap(level[THIEF.PROP.inventoryWidth], level[THIEF.PROP.inventoryHeight]);
19611997 }
19621998
1999+ var stairs;
2000+ var point;
2001+ if(template.upStairs){
2002+
2003+ } else {
2004+ stairs = THIEF.util.factory(THIEF.Data.Obj.UpStairs);
2005+ stairs.nextDun = THIEF.global.actDG;
2006+ stairs.nextLv = THIEF.global.actDG.nowLV +1;
2007+ point = level.getInventoryFreeSpace(stairs);
2008+ level.addToInventory(stairs, point.x, point.y);
2009+ }
2010+
2011+ if(template.downStairs){
2012+
2013+ } else {
2014+ stairs = THIEF.util.factory(THIEF.Data.Obj.DownStairs);
2015+ stairs.nextDun = THIEF.global.actDG;
2016+ stairs.nextLv = THIEF.global.actDG.nowLV -1;
2017+ point = level.getInventoryFreeSpace(stairs);
2018+ level.addToInventory(stairs, point.x, point.y);
2019+ }
2020+
19632021 THIEF.html.addDebugMessage('...展開完了。');
19642022 } else {
2023+ // 個別シナリオがないのであれば自動生成
19652024 level.inventory = THIEF.util.createMap(level[THIEF.PROP.inventoryWidth], level[THIEF.PROP.inventoryHeight]);
19662025 }
19672026
@@ -1969,6 +2028,8 @@
19692028
19702029 }
19712030
2031+ dun[lvNum] = level;
2032+
19722033 THIEF.html.addDebugMessage('...レベルの作成を完了');
19732034 };
19742035
@@ -2333,6 +2394,52 @@
23332394 return map;
23342395 };
23352396
2397+THIEF.util.mapParser = function(fmt){
2398+ var width = fmt[0].length;
2399+ var height = fmt.length;
2400+ var map = [];
2401+
2402+ for(var h=0; h<height; h++){
2403+ for(var w=0; w<width; w++){
2404+ switch (fmt[h].charAt(w)) {
2405+ case '.':
2406+ if(typeof map[w] === 'undefined'){
2407+ map[w] = [];
2408+ }
2409+ if(typeof map[w][h] === 'undefined'){
2410+ map[w][h] = [];
2411+ }
2412+ map[w][h].push(THIEF.util.factory(THIEF.Data.Obj.LitFloor));
2413+ break;
2414+ default:
2415+ THIEF.html.addDebugMessage( map[h].charAt(w) + 'はまだ対応していない。');
2416+ break;
2417+ }
2418+ }
2419+ }
2420+
2421+
2422+ // 外枠を追加
2423+ var left = [];
2424+ var right = [];
2425+ for(var i=0; i<height; i++){
2426+ left[i] = [];
2427+ right[i] = [];
2428+ left[i].push(THIEF.util.factory(THIEF.Data.Obj.NonDiggableWall));
2429+ right[i].push(THIEF.util.factory(THIEF.Data.Obj.NonDiggableWall));
2430+ }
2431+ map.unshift(left);
2432+ map.push(right);
2433+
2434+ for(var j=0; j<map.length; j++){
2435+ map[j].unshift([]);
2436+ map[j].push([]);
2437+ map[j][0].push(THIEF.util.factory(THIEF.Data.Obj.NonDiggableWall));
2438+ map[j][height+1].push(THIEF.util.factory(THIEF.Data.Obj.NonDiggableWall));
2439+ }
2440+ return map;
2441+};
2442+
23362443 THIEF.util.spawn = function (obj) {
23372444 THIEF.html.addDebugMessage('湧き処理を開始...');
23382445
@@ -2700,15 +2807,15 @@
27002807
27012808
27022809 THIEF.html.refreshXy = function(x, y) {
2703- var obj = THIEF.global.actLV.inventory[x][y].getLast();
2704- /*
2705- if(typeof obj === 'undefined') {
2706- THIEF.html.setXy(x, y, '&#x25D9;');
2707- } else */
2708- if (obj.color) {
2709- THIEF.html.setXy(x, y, '<span style="color:' + obj.color + ';">' + obj.symbol + '</span>');
2810+ if(THIEF.global.actLV.inventory[x] && THIEF.global.actLV.inventory[x][y]){
2811+ var obj = THIEF.global.actLV.inventory[x][y].getLast();
2812+ if (obj.color) {
2813+ THIEF.html.setXy(x, y, '<span style="color:' + obj.color + ';">' + obj.symbol + '</span>');
2814+ } else {
2815+ THIEF.html.setXy(x, y, obj.symbol);
2816+ }
27102817 } else {
2711- THIEF.html.setXy(x, y, obj.symbol);
2818+ THIEF.html.setXy(x, y, '&nbsp;'); //&#x2591; &#x2573;
27122819 }
27132820 };
27142821
@@ -3130,8 +3237,8 @@
31303237 },
31313238 commandNotFound : {
31323239 // 1 : command name
3133- ja : '"${1}" というコマンドは存在しません。',
3134- en : '"${1}" command not found.'
3240+ ja : '"${1}" コマンド?',
3241+ en : '"${1}" command?'
31353242 },
31363243 decay : {
31373244 // 1 : subject
@@ -3157,6 +3264,24 @@
31573264 ja : '${1} は既に装備している。',
31583265 en : 'Already, ${2} equiped ${1}.'
31593266 },
3267+ goUpStairs : {
3268+ // 1 : Subject
3269+ ja : '${1}は階段を登った',
3270+ en : '${1} go up the stairs.'
3271+ },
3272+ doesNotGoUpStairs : {
3273+ ja : '上り階段が見当たらない',
3274+ en : 'You can not found the up stairs.'
3275+ },
3276+ goDownStairs : {
3277+ // 1 : Subject
3278+ ja : '${1}は階段を降った',
3279+ en : '${1} go down the stairs.'
3280+ },
3281+ doesNotGoDownStairs : {
3282+ ja : '下り階段が見当たらない',
3283+ en : 'You can not found the sown stairs.'
3284+ },
31603285 startGame : {
31613286 ja : '冒険を開始します。',
31623287 en : 'Start Game'
@@ -3258,7 +3383,7 @@
32583383 en : 'Debugging High Armor'
32593384 },
32603385 objDoorName : {
3261- ja : ' 扉',
3386+ ja : '扉',
32623387 en : 'Door'
32633388 },
32643389 objHiddenWallName : {
@@ -3270,9 +3395,17 @@
32703395 en : 'Unbreakable Wall'
32713396 },
32723397 objNormalWallName : {
3273- ja : ' 壁',
3398+ ja : '壁',
32743399 en : 'Wall'
32753400 },
3401+ objUpStairsName : {
3402+ ja : '上り階段',
3403+ en : 'Up Stairs'
3404+ },
3405+ objDownStairsName : {
3406+ ja : '下り階段',
3407+ en : 'Down Stairs'
3408+ },
32763409 sceTheDungeonName : {
32773410 ja : '迷宮',
32783411 en : 'The Dungeon'
@@ -3468,6 +3601,18 @@
34683601 name : THIEF.Data.Text.objDarkFloorName
34693602 };
34703603
3604+THIEF.Data.Obj.UpStairs = {
3605+ inheritance : '$Floor',
3606+ symbol : '&lt;',
3607+ name : THIEF.Data.Text.objUpStairsName
3608+};
3609+
3610+THIEF.Data.Obj.DownStairs = {
3611+ inheritance : '$Floor',
3612+ symbol : '&gt;',
3613+ name : THIEF.Data.Text.objDownStairsName
3614+};
3615+
34713616 THIEF.Data.Obj.$Wall = {
34723617 symbol : '&#x2593;', // 濃いドット模様
34733618 type : 'wall'
@@ -3886,6 +4031,7 @@
38864031 width : 200,
38874032 height : 100
38884033 }
4034+
38894035 }
38904036
38914037 };
Show on old repository browser