• R/O
  • SSH
  • HTTPS

thief: Commit


Commit MetaInfo

Revision34 (tree)
Time2012-01-15 03:16:05
Authorseussnu

Log Message

0.0.7-alpha13
・ シナリオの分岐処理を追加中
・ 階段の昇降処理を追加

Change Summary

Incremental Difference

--- thief.js (revision 33)
+++ thief.js (revision 34)
@@ -1047,7 +1047,85 @@
10471047 return obj;
10481048 };
10491049
1050+THIEF.func.method.goTheStairs = function(trueIsUpFalseIsDown) {
1051+ var floor = THIEF.global.actLV.getInventoryXyObjects(this.x, this.y);
1052+ var stairs;
1053+ var flag = false;
1054+ // 足元に、階段があるか確認
1055+ for (var i = 0; i < floor.length; i++) {
1056+ if (trueIsUpFalseIsDown && floor[i].symbol === THIEF.Data.Obj.UpStairs.symbol ||
1057+ !trueIsUpFalseIsDown && floor[i].symbol === THIEF.Data.Obj.DownStairs.symbol) {
1058+ flag = true;
1059+ stairs = floor[i];
1060+ break;
1061+ }
1062+ }
10501063
1064+ if (flag) {
1065+ if (trueIsUpFalseIsDown) {
1066+ THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.goUpStairs, this.get(THIEF.PROP.displayName)));
1067+ } else {
1068+ THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.goDownStairs, this.get(THIEF.PROP.displayName)));
1069+ }
1070+ THIEF.util.createLevel(stairs.nextDun, stairs.nextLv);
1071+ THIEF.global.actLV.removeFromInventory(this);
1072+ var oldDG = THIEF.global.actDG;
1073+ var oldLV = THIEF.global.actDG.nowLV;
1074+
1075+ // 新しい階層をセット
1076+ THIEF.global.actDG = stairs.nextDun;
1077+ THIEF.global.actDG.nowLV = stairs.nextLv;
1078+ THIEF.global.actLV = stairs.nextDun[stairs.nextLv];
1079+
1080+ // 対になる階段が泣ければ作成する
1081+ if (!stairs.partner) {
1082+ // ブランチと、通常で場合分け
1083+ if (stairs.isBranch) {
1084+ // ブランチの場合は新規作成
1085+ var branchStairs;
1086+ if (trueIsUpFalseIsDown) {
1087+ branchStairs = THIEF.util.factory(THIEF.Data.Obj.DownStairs);
1088+ } else {
1089+ branchStairs = THIEF.util.factory(THIEF.Data.Obj.UpStairs);
1090+ }
1091+ branchStairs.point = THIEF.global.actLV.getInventoryRandomFreeSpace(branchStairs);
1092+ branchStairs.nextDun = oldDG;
1093+ branchStairs.nextLv = oldLV;
1094+ branchStairs.color = 'red';
1095+
1096+ // 互いに登録
1097+ stairs.partner = branchStairs;
1098+ branchStairs.partner = stairs;
1099+
1100+ THIEF.global.actLV.addToInventory(branchStairs, branchStairs.point.x, branchStairs.point.y);
1101+ } else {
1102+ // 通常の場合は既設にくっつける
1103+ // 互いに登録
1104+ if (trueIsUpFalseIsDown) {
1105+ stairs.partner = THIEF.global.actLV.downStairs;
1106+ THIEF.global.actLV.downStairs.partner = stairs;
1107+ } else {
1108+ stairs.partner = THIEF.global.actLV.upStairs;
1109+ THIEF.global.actLV.upStairs.partner = stairs;
1110+ }
1111+ }
1112+ }
1113+
1114+ THIEF.global.actLV.addToInventory(this, stairs.partner.point.x, stairs.partner.point.y);
1115+ THIEF.html.refresh();
1116+ THIEF.util.updateStatus();
1117+
1118+ } else {
1119+ if (trueIsUpFalseIsDown) {
1120+ THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.doesNotGoUpStairs));
1121+ } else {
1122+ THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.doesNotGoDownStairs));
1123+ }
1124+ }
1125+
1126+ return flag;
1127+};
1128+
10511129 THIEF.func.command = {}; // マニュアルコマンドで実行して良いもの
10521130 THIEF.func.command.goUp = function() {
10531131 return this.move(0, -1);
@@ -1462,101 +1540,12 @@
14621540 return false;
14631541 };
14641542
1465-// TODO
14661543 THIEF.func.command.goUpTheStairs = function() {
1467- var floor = THIEF.global.actLV.getInventoryXyObjects(this.x, this.y);
1468- var stairs;
1469- var flag = false;
1470- for (var i = 0; i < floor.length; i++) {
1471- if (floor[i].symbol === THIEF.Data.Obj.UpStairs.symbol) {
1472- flag = true;
1473- stairs = floor[i];
1474- break;
1475- }
1476- }
1477-
1478- if (flag) {
1479- THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.goUpStairs, this.get(THIEF.PROP.displayName)));
1480- THIEF.util.createLevel(stairs.nextDun, stairs.nextLv);
1481- THIEF.global.actLV.removeFromInventory(this);
1482- var oldDG = THIEF.global.actDG;
1483- var oldLV = THIEF.global.actDG.nowLV;
1484- THIEF.global.actDG = stairs.nextDun;
1485- THIEF.global.actDG.nowLV = stairs.nextLv;
1486- THIEF.global.actLV = stairs.nextDun[stairs.nextLv];
1487- var point;
1488- if (stairs.isBranch) {
1489- if (stairs.created) {
1490- point = THIEF.global.actLV.branchDirPoint;
1491- } else {
1492- var branchStairs = THIEF.util.factory(THIEF.Data.Obj.DownStairs);
1493- point = THIEF.global.actLV.getInventoryRandomFreeSpace(branchStairs);
1494- branchStairs.nextDun = oldDG;
1495- branchStairs.nextLv = oldLV;
1496- branchStairs.branchDirPoint = point;
1497- branchStairs.color = 'red';
1498- branchStairs.created = true;
1499- stairs.created = true;
1500- THIEF.global.actLV.addToInventory(branchStairs, point.x, point.y);
1501- }
1502- } else {
1503- point = THIEF.global.actLV.downStairsPoint;
1504- }
1505- THIEF.global.actLV.addToInventory(this, point.x, point.y);
1506- THIEF.html.refresh();
1507- } else {
1508- THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.doesNotGoUpStairs));
1509- }
1510-
1511- return flag;
1544+ return THIEF.func.method.goTheStairs.call(this, true);
15121545 };
15131546
15141547 THIEF.func.command.goDownTheStairs = function() {
1515- var floor = THIEF.global.actLV.getInventoryXyObjects(this.x, this.y);
1516- var stairs;
1517- var flag = false;
1518- for (var i = 0; i < floor.length; i++) {
1519- if (floor[i].symbol === THIEF.Data.Obj.DownStairs.symbol) {
1520- flag = true;
1521- stairs = floor[i];
1522- break;
1523- }
1524- }
1525-
1526- if (flag) {
1527- THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.goDownStairs, this.get(THIEF.PROP.displayName)));
1528- THIEF.util.createLevel(stairs.nextDun, stairs.nextLv);
1529- THIEF.global.actLV.removeFromInventory(this);
1530- var oldDG = THIEF.global.actDG;
1531- var oldLV = THIEF.global.actDG.nowLV;
1532- THIEF.global.actDG = stairs.nextDun;
1533- THIEF.global.actDG.nowLV = stairs.nextLv;
1534- THIEF.global.actLV = stairs.nextDun[stairs.nextLv];
1535- var point;
1536- if (stairs.isBranch) {
1537- if (stairs.created) {
1538- point = THIEF.global.actLV.branchDirPoint;
1539- } else {
1540- var branchStairs = THIEF.util.factory(THIEF.Data.Obj.UpStairs);
1541- point = THIEF.global.actLV.getInventoryRandomFreeSpace(branchStairs);
1542- branchStairs.nextDun = oldDG;
1543- branchStairs.nextLv = oldLV;
1544- branchStairs.branchDirPoint = point;
1545- branchStairs.color = 'red';
1546- branchStairs.created = true;
1547- stairs.created = true;
1548- THIEF.global.actLV.addToInventory(branchStairs, point.x, point.y);
1549- }
1550- } else {
1551- point = THIEF.global.actLV.upStairsPoint;
1552- }
1553- THIEF.global.actLV.addToInventory(this, point.x, point.y);
1554- THIEF.html.refresh();
1555- } else {
1556- THIEF.html.addMessage(THIEF.util.getText(THIEF.Data.Text.doesNotGoDownStairs));
1557- }
1558-
1559- return flag;
1548+ return THIEF.func.method.goTheStairs.call(this, false);
15601549 };
15611550
15621551 THIEF.util = {};
@@ -1948,6 +1937,7 @@
19481937 };
19491938 }();
19501939
1940+// TODO
19511941 THIEF.util.loadScenario = function () {
19521942 THIEF.html.addDebugMessage('シナリオ読み込み開始...');
19531943 THIEF.util.createDungeon(THIEF.Data.Scenario[THIEF.Data.Scenario.$.root]);
@@ -2053,7 +2043,7 @@
20532043
20542044 // 分岐系テンプレートの読み込み
20552045 if (dun[lvNum].branch) {
2056- template.branch = dun[lvNum].branch;
2046+ template.branchDun = THIEF.Data.Scenario[dun[lvNum].branch];
20572047 template.branchDir = dun[lvNum].branchDir;
20582048 if (typeof template.branchDir === 'undefined') {
20592049 alert('分岐への移動方法 (branchDir) が指定されて居ません.');
@@ -2065,7 +2055,6 @@
20652055 }
20662056
20672057
2068- // TODO
20692058 // テンプレートに基づいて処理を実行
20702059 // for (name in obj) は、オンオフの処理が後々面倒になりそうなので、
20712060 // ここで逐次処理にする
@@ -2079,15 +2068,17 @@
20792068 level.inventory = THIEF.util.createMap(level[THIEF.PROP.inventoryWidth], level[THIEF.PROP.inventoryHeight]);
20802069 }
20812070
2071+
20822072 if (template.upStairs) {
20832073
20842074 } else {
20852075 if (lvNum > 1) {
20862076 var upStairs = THIEF.util.factory(THIEF.Data.Obj.UpStairs);
2087- upStairs.nextDun = THIEF.global.actDG;
2077+ upStairs.nextDun = dun;
20882078 upStairs.nextLv = lvNum - 1;
2089- level.upStairsPoint = level.getInventoryRandomFreeSpace(upStairs);
2090- level.addToInventory(upStairs, level.upStairsPoint.x, level.upStairsPoint.y);
2079+ upStairs.point = level.getInventoryRandomFreeSpace(upStairs);
2080+ level.addToInventory(upStairs, upStairs.point.x, upStairs.point.y);
2081+ level.upStairs = upStairs;
20912082 }
20922083 }
20932084
@@ -2097,35 +2088,38 @@
20972088 } else {
20982089 if (lvNum < THIEF.global.actDG.levelNum) {
20992090 var downStairs = THIEF.util.factory(THIEF.Data.Obj.DownStairs);
2100- downStairs.nextDun = THIEF.global.actDG;
2091+ downStairs.nextDun = dun;
21012092 downStairs.nextLv = lvNum + 1;
2102- level.downStairsPoint = level.getInventoryRandomFreeSpace(downStairs);
2103- level.addToInventory(downStairs, level.downStairsPoint.x, level.downStairsPoint.y);
2093+ downStairs.point = level.getInventoryRandomFreeSpace(downStairs);
2094+ level.addToInventory(downStairs, downStairs.point.x, downStairs.point.y);
2095+ level.downStairs = downStairs;
21042096 }
21052097 }
21062098
2107- // TODO 階段移動後に出現する場所を、階段自体の変数に持たせること
2108- if (template.branch) {
2109- var branchDir;
2099+ if (template.branchDun) {
2100+ var branchWay;
21102101 switch (template.branchDir) {
21112102 case 'up':
21122103 case '&lt;':
2113- branchDir = THIEF.util.factory(THIEF.Data.Obj.UpStairs);
2114- branchDir.nextDun = THIEF.Data.Scenario[template.branch];
2115- branchDir.nextLv = THIEF.Data.Scenario[template.branch].startLevel || 1;
2116- // 分岐先に自分を登録
2117- // TODO 現状では branch 変数にはダンジョン"名"を入れておく必要がある
2118- //branchDir.nextDun[branchDir.nextLv].branch = dun;
2119- //branchDir.nextDun[branchDir.nextLv].branchDir = 'down';
2104+ branchWay = THIEF.util.factory(THIEF.Data.Obj.UpStairs);
2105+ branchWay.nextDun = template.branchDun;
2106+ branchWay.nextLv = template.branchDun.startLevel || 1;
2107+ if (typeof branchWay.nextDun[branchWay.nextLv] === 'undefined') {
2108+ branchWay.nextDun[branchWay.nextLv] = {};
2109+ }
2110+ branchWay.nextDun[branchWay.nextLv].branchDun = dun;
2111+ branchWay.nextDun[branchWay.nextLv].branchDir = 'down';
21202112 break;
21212113 case 'down':
21222114 case '&gt;':
2123- branchDir = THIEF.util.factory(THIEF.Data.Obj.DownStairs);
2124- branchDir.nextDun = THIEF.Data.Scenario[template.branch];
2125- branchDir.nextLv = THIEF.Data.Scenario[template.branch].startLevel || 1;
2126- // 分岐先に自分を登録
2127- //branchDir.nextDun[branchDir.nextLv].branch = dun;
2128- //branchDir.nextDun[branchDir.nextLv].branchDir = 'up';
2115+ branchWay = THIEF.util.factory(THIEF.Data.Obj.DownStairs);
2116+ branchWay.nextDun = template.branchDun;
2117+ branchWay.nextLv = template.branchDun.startLevel || 1;
2118+ if (typeof branchWay.nextDun[branchWay.nextLv] === 'undefined') {
2119+ branchWay.nextDun[branchWay.nextLv] = {};
2120+ }
2121+ branchWay.nextDun[branchWay.nextLv].branchDun = dun;
2122+ branchWay.nextDun[branchWay.nextLv].branchDir = 'up';
21292123 break;
21302124 case 'teleport':
21312125 default:
@@ -2133,13 +2127,13 @@
21332127 }
21342128
21352129 if (template.branchDirPoint) {
2136- level.branchDirPoint = template.branchDirPoint;
2130+ branchWay.point = template.branchDirPoint;
21372131 } else {
2138- level.branchDirPoint = level.getInventoryRandomFreeSpace(branchDir)
2132+ branchWay.point = level.getInventoryRandomFreeSpace(branchWay)
21392133 }
2140- branchDir.color = 'red';
2141- branchDir.isBranch = true;
2142- level.addToInventory(branchDir, level.branchDirPoint.x, level.branchDirPoint.y);
2134+ branchWay.color = 'red';
2135+ branchWay.isBranch = true;
2136+ level.addToInventory(branchWay, branchWay.point.x, branchWay.point.y);
21432137 }
21442138
21452139 if (template.safety) {
@@ -4105,10 +4099,7 @@
41054099 name : THIEF.Data.Text.sceSideRoadName,
41064100 levelNum : 3,
41074101 width : 60,
4108- height : 10,
4109- hierarchy : [
4110- {level : 'SmallRoom', base : 1}
4111- ]
4102+ height : 10
41124103 },
41134104
41144105
Show on old repository browser