• R/O
  • SSH
  • HTTPS

thief: Commit


Commit MetaInfo

Revision32 (tree)
Time2012-01-10 23:52:37
Authorseussnu

Log Message

0.0.7-alpha11
・ シナリオの分岐処理を追加中
・ 細々とミスフィックス

Change Summary

Incremental Difference

--- thief.js (revision 31)
+++ thief.js (revision 32)
@@ -496,7 +496,7 @@
496496 if (this.inventory && this.inventory[targetX] && this.inventory[targetX][targetY]) {
497497 if (this.inventory[targetX][targetY].length <= invDepth) {
498498 var lastObj = this.inventory[targetX][targetY].getLast();
499- 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) */) {
499+ if (typeof lastObj === 'undefined' || lastObj.type !== THIEF.Data.Obj.$Wall.type && (obj.get(THIEF.PROP.stackable) || lastObj.get(THIEF.PROP.stackable)) /* || !lastObj.get(THIEF.PARAM.mergeable) */) {
500500 if (lastObj) {
501501 THIEF.html.addDebugMessage('[' + targetX + ', ' + targetY + ']にある' + lastObj.get(THIEF.PROP.displayName) + 'には重ねられる。');
502502 } else {
@@ -678,36 +678,29 @@
678678
679679 }();
680680
681-// items 配列を渡してカリー化(?)
681+// 配列を渡してカリー化(?)
682682 THIEF.func.method.selecter = function(objs, exec, immediately, abc) {
683683
684684 var key = THIEF.KEY;
685- var items = [];
686685 var selected = [];
687686 var targets = [];
688687 var i, j;
689688
690689 THIEF.html.addDebugMessage('セレクターを生成');
691- for (i = 0; i < objs.length; i++) {
692- THIEF.html.addDebugMessage('セレクターターゲット:' + objs[i].get(THIEF.PROP.displayName));
693- if (objs[i] !== this && objs[i].portable && objs[i].get(THIEF.PROP.displayName)) {
694- items.push(objs[i]);
695- }
696- }
697690
698691 // root_abc
699692 var alphabetIndex = key.a;
700693
701- // アイテム出力
694+ // 一覧出力
702695 for (i = 0; i < THIEF.conf.itemSort.length; i++) {
703696
704697 //アイテムがあるか確認
705698 var first = true;
706- for (j = 0; j < items.length; j++) {
707- if (THIEF.conf.itemSort[i] === items[j].symbol) {
699+ for (j = 0; j < objs.length; j++) {
700+ if (THIEF.conf.itemSort[i] === objs[j].symbol) {
708701 if (first) {
709702 first = false;
710- THIEF.html.addInfomation('<span style="color:' + THIEF.conf.bgColor + '; background:' + THIEF.conf.textColor + '">' + items[j].get(THIEF.PROP.symbolName) + '</span>');
703+ THIEF.html.addInfomation('<span style="color:' + THIEF.conf.bgColor + '; background:' + THIEF.conf.textColor + '">' + objs[j].get(THIEF.PROP.symbolName) + '</span>');
711704 }
712705
713706 var alphabet;
@@ -715,16 +708,16 @@
715708 alphabet = String.fromCharCode(alphabetIndex);
716709 alphabetIndex++;
717710 } else {
718- alphabet = items[j].alphabet || this.getInventoryNonExistAlphabet();
711+ alphabet = objs[j].alphabet || this.getInventoryNonExistAlphabet();
719712 if (alphabet === null) {
720713 // ページ切り替え
721714 break;
722715 }
723- items[j].alphabet = alphabet;
716+ objs[j].alphabet = alphabet;
724717 }
725718
726- THIEF.html.addInfomation(alphabet + '<span id="' + THIEF.conf.id + '_' + alphabet + '">&nbsp;-&nbsp;</span>' + items[j].get(THIEF.PROP.displayName));
727- targets[alphabet] = items[j];
719+ THIEF.html.addInfomation(alphabet + '<span id="' + THIEF.conf.id + '_' + alphabet + '">&nbsp;-&nbsp;</span>' + objs[j].get(THIEF.PROP.displayName));
720+ targets[alphabet] = objs[j];
728721 }
729722 }
730723 }
@@ -812,41 +805,6 @@
812805 var diffX = THIEF.global.adventurer.x - this.x;
813806 var diffY = THIEF.global.adventurer.y - this.y;
814807
815- /*
816- var rad = ((Math.atan2(diffY, diffX) * 180.0 / Math.PI) + 360.0) % 360.0;
817-
818- if (typeof rad !== 'number') {
819-
820- } else {
821- if (337.5 < rad || (0 <= rad && rad < 22.5)) {
822- dx = 1;
823- dy = 0;
824- } else if (22.5 <= rad && rad <= 67.5) {
825- dx = 1;
826- dy = 1;
827- } else if (67.5 < rad && rad < 112.5) {
828- dx = 0;
829- dy = 1;
830- } else if (112.5 <= rad && rad <= 157.5) {
831- dx = -1;
832- dy = 1;
833- } else if (157.5 < rad && rad < 202.5) {
834- dx = -1;
835- dy = 0;
836- } else if (202.5 <= rad && rad <= 247.5) {
837- dx = -1;
838- dy = -1;
839- } else if (247.5 < rad && rad < 292.5) {
840- dx = 0;
841- dy = -1;
842- } else if (292.5 <= rad && rad <= 337.5) {
843- dx = 1;
844- dy = -1;
845- }
846- }
847- */
848-
849-
850808 if (diffX > 0) {
851809 dx = 1;
852810 } else if (diffX < 0) {
@@ -859,7 +817,6 @@
859817 dy = -1;
860818 }
861819
862-
863820 this.move(dx, dy);
864821
865822 THIEF.html.addDebugMessage('...CPU行動完了');
@@ -1134,10 +1091,17 @@
11341091 };
11351092
11361093 THIEF.func.command.pickup = function() {
1137- var objs = THIEF.global.actLV.getInventoryXyObjects(this.x, this.y);
1094+ var tmp = THIEF.global.actLV.getInventoryXyObjects(this.x, this.y);
11381095 var finish = true;
1139- // メソッド書き換え
1140- if (objs.length > 2) { // 自分と床以外になにかあれば(?)
1096+ var objs = [];
1097+
1098+ for (var i = 0; i < tmp.length; i++) {
1099+ if (tmp[i].portable) {
1100+ objs.push(tmp[i]);
1101+ }
1102+ }
1103+
1104+ if (objs.length > 0) {
11411105 var from = THIEF.global.actLV;
11421106 var to = this;
11431107 var exec = function(selected) {
@@ -1651,7 +1615,7 @@
16511615 THIEF.html.addDebugMessage('...通知を完了');
16521616
16531617 // 各レベルに実施させること
1654- if (Math.random() > 0.9) {
1618+ if (!THIEF.global.actLV.safety && Math.random() > 0.9) {
16551619 THIEF.global.actLV.spawn(THIEF.util.factory(THIEF.Data.Obj.DebugDaemon));
16561620 }
16571621 } else {
@@ -2051,32 +2015,35 @@
20512015
20522016 // 分岐系テンプレートの読み込み
20532017 if (dun[lvNum].branch) {
2054- // 特殊分岐実装予定
2018+ template.branch = dun[lvNum].branch;
2019+ template.branchDir = dun[lvNum].branchDir;
2020+ if (typeof template.branchDir === 'undefined') {
2021+ alert('分岐への移動方法 (branchDir) が指定されて居ません.');
2022+ }
2023+ template.branchDirPoint = dun[lvNum].branchDirPoint;
20552024 }
20562025
2057-
20582026 THIEF.html.addDebugMessage('...展開完了。');
2059- } else {
2060- // テンプレートがなければ、とりあえずマップサイズのみ指定
2061- template.width = level[THIEF.PROP.inventoryWidth];
2062- template.height = level[THIEF.PROP.inventoryHeight];
20632027 }
20642028
20652029
2030+ // TODO
20662031 // テンプレートに基づいて処理を実行
20672032 // for (name in obj) は、オンオフの処理が後々面倒になりそうなので、
20682033 // ここで逐次処理にする
2034+ var stairs;
2035+ var dirPoint;
2036+
20692037 if (template.map) {
20702038 level.inventory = THIEF.util.mapParser(template.map);
20712039 level[THIEF.PROP.inventoryWidth] = level.inventory.length;
20722040 level[THIEF.PROP.inventoryHeight] = level.inventory[0].length;
2041+ } else if (template.width && template.height) {
2042+ level.inventory = THIEF.util.createMap(template.width, template.height);
20732043 } else {
20742044 level.inventory = THIEF.util.createMap(level[THIEF.PROP.inventoryWidth], level[THIEF.PROP.inventoryHeight]);
20752045 }
20762046
2077- var stairs;
2078- var point;
2079-
20802047 if (template.upStairs) {
20812048
20822049 } else {
@@ -2084,9 +2051,8 @@
20842051 stairs = THIEF.util.factory(THIEF.Data.Obj.UpStairs);
20852052 stairs.nextDun = THIEF.global.actDG;
20862053 stairs.nextLv = lvNum - 1;
2087- point = level.getInventoryRandomFreeSpace(stairs);
2088- level.addToInventory(stairs, point.x, point.y);
2089- level.upStairsPoint = point;
2054+ level.upStairsPoint = level.getInventoryRandomFreeSpace(stairs);
2055+ level.addToInventory(stairs, level.upStairsPoint.x, level.upStairsPoint.y);
20902056 }
20912057 }
20922058
@@ -2093,16 +2059,52 @@
20932059 if (template.downStairs) {
20942060
20952061 } else {
2096- if (lvNum <= THIEF.global.actDG.levelNum) {
2062+ if (lvNum < THIEF.global.actDG.levelNum) {
20972063 stairs = THIEF.util.factory(THIEF.Data.Obj.DownStairs);
20982064 stairs.nextDun = THIEF.global.actDG;
20992065 stairs.nextLv = lvNum + 1;
2100- point = level.getInventoryRandomFreeSpace(stairs);
2101- level.addToInventory(stairs, point.x, point.y);
2102- level.downStairsPoint = point;
2066+ level.downStairsPoint = level.getInventoryRandomFreeSpace(stairs);
2067+ level.addToInventory(stairs, level.downStairsPoint.x, level.downStairsPoint.y);
21032068 }
21042069 }
21052070
2071+ if (template.safety) {
2072+ level.safety = template.safety;
2073+ }
2074+
2075+ if (template.branch) {
2076+ switch (template.branchDir) {
2077+ case 'up':
2078+ case '&lt;':
2079+ stairs = THIEF.util.factory(THIEF.Data.Obj.UpStairs);
2080+ stairs.nextDun = THIEF.Data.Scenario[template.branch];
2081+ stairs.nextLv = THIEF.Data.Scenario[template.branch].startLevel || 1;
2082+ // 分岐先に自分を登録
2083+ stairs.nextDun[stairs.nextLv].branch = dun;
2084+ stairs.nextDun[stairs.nextLv].branchDir = 'down';
2085+ break;
2086+ case 'donw':
2087+ case '&gt;':
2088+ stairs = THIEF.util.factory(THIEF.Data.Obj.DownStairs);
2089+ stairs.nextDun = THIEF.Data.Scenario[template.branch];
2090+ stairs.nextLv = THIEF.Data.Scenario[template.branch].startLevel || 1;
2091+ // 分岐先に自分を登録
2092+ stairs.nextDun[stairs.nextLv].branch = dun;
2093+ stairs.nextDun[stairs.nextLv].branchDir = 'up';
2094+ break;
2095+ case 'teleport':
2096+ default:
2097+ break;
2098+ }
2099+
2100+ if (template.branchDirPoint) {
2101+ level.branchDirPoint = template.branchDirPoint;
2102+ } else {
2103+ level.branchDirPoint = level.getInventoryRandomFreeSpace(stairs)
2104+ }
2105+ level.addToInventory(stairs, level.branchDirPoint.x, level.branchDirPoint.y);
2106+ }
2107+
21062108 level.created = true;
21072109 dun[lvNum] = level;
21082110
@@ -3356,6 +3358,14 @@
33563358 ja : '指定したコマンドを実行します',
33573359 en : 'execute command'
33583360 },
3361+ cmdGoUpStairs : {
3362+ ja : '階段を登る',
3363+ en : 'go up the stairs'
3364+ },
3365+ cmdGoDownStairs : {
3366+ ja : '階段を降りる',
3367+ en : 'go down the stairs'
3368+ },
33593369 objDefaultName : {
33603370 ja : '無名',
33613371 en : 'Nameless'
@@ -3954,11 +3964,14 @@
39543964 },
39553965 goUpStairs : {
39563966 cmd : THIEF.func.command.goUpTheStairs,
3957- key : THIEF.KEY.LT
3967+ key : THIEF.KEY.LT,
3968+ text : THIEF.Data.Text.cmdGoUpStairs
3969+
39583970 },
39593971 goDownStairs : {
39603972 cmd : THIEF.func.command.goDownTheStairs,
3961- key : THIEF.KEY.GT
3973+ key : THIEF.KEY.GT,
3974+ text : THIEF.Data.Text.cmdGoDownStairs
39623975 }
39633976 };
39643977
@@ -4041,10 +4054,9 @@
40414054 levelNum : 10,
40424055 startLevel : 2,
40434056 hierarchy : [
4044- {level : ['First', 'SmallRoom'], base : 2},
4045- {branch : 'SideRoad', base : 3, dir : 'down'},
4046- {level : 'SmallRoom', base : 4, range :3},
4047- {level : 'BigRoom', base : 7, chance : 50}
4057+ {level : ['First', 'SmallRoom', 'Safety'], base : 2},
4058+ {branch : 'SideRoad', base : 3, branchDir : 'down'},
4059+ {level : 'BigRoom', base : 4, range :3, chance : 50}
40484060 ]
40494061 },
40504062
@@ -4078,8 +4090,12 @@
40784090 },
40794091
40804092 BigRoom : {
4081- width : 200,
4082- height : 100
4093+ width : 120,
4094+ height : 40
4095+ },
4096+
4097+ Safety : {
4098+ safety : true
40834099 }
40844100
40854101 }
Show on old repository browser