• R/O
  • SSH
  • HTTPS

thief: Commit


Commit MetaInfo

Revision18 (tree)
Time2011-11-07 00:18:43
Authorseussnu

Log Message

0.0.6-alpha6
・装備処理を修正
・データ構造を大幅に見直し
・マップ生成を修正中

Change Summary

Incremental Difference

--- thief.js (revision 17)
+++ thief.js (revision 18)
@@ -30,7 +30,6 @@
3030 */
3131
3232 var THIEF = {
33-
3433 conf : {
3534 id : 'Thief', // was used "HTML's id", and "System tag".
3635 fontFace : 'monospace, sans-serif',
@@ -94,7 +93,10 @@
9493 Up : 38, // &
9594 Right : 39, // '
9695 Down : 40, //
96+ Comma : ','.charCodeAt(0),
97+ Period : '.'.charCodeAt(0),
9798 Minus : '-'.charCodeAt(0),
99+ Sharp : '#'.charCodeAt(0),
98100 A : 'A'.charCodeAt(0), // A 65
99101 B : 'B'.charCodeAt(0),
100102 C : 'C'.charCodeAt(0),
@@ -333,51 +335,757 @@
333335 // $xxx : Common
334336 // _xxx : DebugModeOnly
335337 //
336-THIEF.command = {};
337338
338-THIEF.command.goUp = function() {
339+THIEF.func = {};
340+THIEF.func.method = {};
341+THIEF.func.method.get = function (param) {
342+ var val;
343+ if (typeof this[param] === 'function') {
344+ val = this[param]();
345+ } else if (this[param]) {
346+ if (this[param][THIEF.conf.language]) {
347+ val = this[param][THIEF.conf.language];
348+ } else {
349+ val = this[param];
350+ for (var i = 0; i < THIEF.conf.languagePriolity.length; i++) {
351+ if (this[param][THIEF.conf.languagePriolity[i]]) {
352+ val = this[param][THIEF.conf.languagePriolity[i]];
353+ break;
354+ }
355+ }
356+ }
357+ }
358+ return val;
359+};
360+THIEF.func.method.removeFromInventory = function(obj) {
361+ var objX = obj.x;
362+ var objY = obj.y;
363+ THIEF.html.addDebugMessage(obj.get(THIEF.PARAM.displayName) + 'を' + this.get(THIEF.PARAM.displayName) + 'のインベントリ座標[' + obj.x + ', ' + obj.y + ']から除外...');
364+ var shapeX = Math.ceil(obj.get(THIEF.PARAM.shapeWidth) / this.get(THIEF.PARAM.inventoryCellSize)) || 1;
365+ var shapeY = Math.ceil(obj.get(THIEF.PARAM.shapeHeight) / this.get(THIEF.PARAM.inventoryCellSize)) || 1;
366+
367+ if (obj.myOwner === this) {
368+ obj.myOwner = null;
369+ obj.x = undefined;
370+ obj.y = undefined;
371+ for (var i = 0; i < shapeX; i++) {
372+ for (var j = 0; j < shapeY; j++) {
373+ THIEF.html.addDebugMessage('座標[' + (objX + i) + ', ' + (objY + j) + ']から除外');
374+ this.inventory[objX + i][objY + j].remove(obj);
375+ THIEF.html.refreshXy(objX + i, objY + j);
376+ }
377+ }
378+ }
379+ THIEF.html.addDebugMessage('...' + obj.get(THIEF.PARAM.displayName) + 'を' + this.get(THIEF.PARAM.displayName) + 'のインベントリ座標[' + objX + ', ' + objY + ']から除外完了。');
380+
381+ return true;
382+};
383+THIEF.func.method.addToInventory = function(obj, x, y) {
384+
385+ var result = false;
386+
387+ THIEF.html.addDebugMessage(obj.get(THIEF.PARAM.displayName) + 'を' + this.get(THIEF.PARAM.displayName) + 'のインベントリ座標[' + x + ', ' + y + ']に追加処理を開始...');
388+
389+ var target = this.getInventoryFreeSpace(obj, x, y);
390+ if (target.x >= 0 && target.y >= 0) {
391+ obj.x = target.x;
392+ obj.y = target.y;
393+ obj.myOwner = this;
394+ THIEF.html.addDebugMessage(target.x + ', ' + target.y + 'を基準に ' + target.width + 'x' + target.len + ' のサイズとして追加');
395+ for (var i = target.x; i < target.x + target.width; i++) {
396+ for (var j = target.y; j < target.y + target.len; j++) {
397+
398+ if (!this.inventory) {
399+ this.inventory = [];
400+ }
401+
402+ if (!this.inventory[i]) {
403+ this.inventory[i] = [];
404+ }
405+
406+ if (!this.inventory[i][j]) {
407+ this.inventory[i][j] = [];
408+ }
409+
410+ // Item の場合のみアルファベットを設定
411+ if(obj.isItem){
412+ THIEF.html.addDebugMessage(obj.get(THIEF.PARAM.displayName) + ' はアイテムなので、アルファベットの割り当てを行う...');
413+ var alphabets = this.getInventoryAlphabets();
414+ if (typeof obj.get(THIEF.PARAM.alphabet) === 'string' && alphabets.indexOf(obj.get(THIEF.PARAM.alphabet)) === -1) {
415+ // すでにアルファベットが登録済みで、かつ変更の必要は無い
416+ THIEF.html.addDebugMessage('すでに割りあたっているもの' + obj.get(THIEF.PARAM.alphabet) + 'が再利用可能。');
417+ } else {
418+ var alp = this.getInventoryNonExistAlphabet();
419+ if (typeof alp === 'undefined') {
420+ alert('アルファベット関係の使用制限バグ');
421+ } else {
422+ obj[THIEF.PARAM.alphabet] = alp;
423+ }
424+ THIEF.html.addDebugMessage('新たに ' + alp + ' を割り当てた。')
425+ }
426+ THIEF.html.addDebugMessage('...アルファベットの割り当て処理完了。');
427+ }
428+
429+ this.inventory[i][j].push(obj);
430+ THIEF.html.addDebugMessage('[' + i + ', ' + j + ']に' + obj.get(THIEF.PARAM.alphabet) + 'として追加');
431+ result = true;
432+ }
433+ }
434+ } else {
435+ THIEF.html.addDebugMessage('追加可能なスペースがない。');
436+ }
437+
438+ THIEF.html.addDebugMessage('...' + obj.get(THIEF.PARAM.displayName) + 'を' + this.get(THIEF.PARAM.displayName) + 'のインベントリ座標[' + x + ', ' + y + ']に追加処理を完了。(return : ' + result + ')');
439+
440+ return result;
441+};
442+
443+THIEF.func.method.getInventoryFreeSpace = function(obj, _x, _y) {
444+
445+ var invCellSize = this.get(THIEF.PARAM.inventoryCellSize) || 10;
446+ var invWidth = this.get(THIEF.PARAM.inventoryWidth) || 0;
447+ var invHeight = this.get(THIEF.PARAM.inventoryHeight) || 0;
448+ var invDepth = this.get(THIEF.PARAM.inventoryDepth) || 0;
449+ var objShapeWight = obj.get(THIEF.PARAM.shapeWidth) || Math.ceil(obj.get(THIEF.PARAM.siz) / 4) || 1;
450+ var objShapeHeight = obj.get(THIEF.PARAM.shapeHeight) || Math.ceil(obj.get(THIEF.PARAM.siz) / 4) || 1;
451+ var objInvShapeWight = Math.ceil(objShapeWight / invCellSize);
452+ var objInvShapeHeight = Math.ceil(objShapeHeight / invCellSize);
453+
454+ var resultAnc = {};
455+
456+ var startX = _x || 0;
457+ var startY = _y || 0;
458+ var once = (typeof _x === "number" || typeof _y === "number");
459+
460+ THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + 'のインベントリ(' + invHeight + ', ' + invWidth + ', ' + invDepth + ')の座標[' + _x + ', ' + _y + ']に' + obj.get(THIEF.PARAM.displayName) + '(' + objInvShapeWight + ', ' + objInvShapeHeight + ')として格納できるか確認を開始...');
461+
462+ var free;
463+
464+ outloop : for (var ancY = startY; ancY < invHeight; ancY++) {
465+ //alert(ancY + '行目を処理...');
466+ for (var ancX = startX; ancX < invWidth; ancX++) {
467+ //alert(ancX + ', ' + ancY);
468+ free = true;
469+
470+ //THIEF.html.addDebugMessage(ancX + ', ' + ancY + 'を確認...');
471+
472+ inloop : for (var targetY = ancY; targetY < ancY + objInvShapeHeight; targetY++) {
473+ for (var targetX = ancX + objInvShapeWight - 1; targetX >= ancX; targetX--) {
474+ if (this.inventory && this.inventory[targetX] && this.inventory[targetX][targetY]) {
475+ if (this.inventory[targetX][targetY].length <= invDepth) {
476+ var lastObj = this.inventory[targetX][targetY].getLast();
477+ if (obj.get(THIEF.PARAM.stackable) || typeof lastObj === 'undefined' || lastObj.get(THIEF.PARAM.stackable) /* || !lastObj.get(THIEF.PARAM.mergeable) */) {
478+ if (lastObj) {
479+ THIEF.html.addDebugMessage('[' + targetX + ', ' + targetY + ']にある' + lastObj.get(THIEF.PARAM.displayName) + 'には重ねられる。');
480+ } else {
481+ THIEF.html.addDebugMessage('[' + targetX + ', ' + targetY + ']には何も無いので重ねられる。');
482+ }
483+ } else {
484+ free = false;
485+ ancX = targetX;
486+ //THIEF.html.addDebugMessage(targetX + ', ' + targetY + 'にある' + lastObj.get(THIEF.PARAM.name) + 'には重ねられない');
487+ break inloop;
488+ }
489+ } else {
490+ free = false;
491+ ancX = targetX;
492+ //THIEF.html.addDebugMessage(targetX + ', ' + targetY + ' は高さが足りないからダメ');
493+ break inloop;
494+ }
495+
496+
497+ } else {
498+ THIEF.html.addDebugMessage(targetX + ', ' + targetY + ' は空');
499+ }
500+ }
501+ }
502+
503+ if (free) {
504+ resultAnc.x = ancX;
505+ resultAnc.y = ancY;
506+ resultAnc.width = objInvShapeWight;
507+ resultAnc.len = objInvShapeHeight;
508+ break outloop;
509+ }
510+ if (once) {
511+ break outloop;
512+ }
513+ }
514+ }
515+
516+ THIEF.html.addDebugMessage('...' + obj.get(THIEF.PARAM.displayName) + '(' + objInvShapeWight + ', ' + objInvShapeHeight + ')として格納できるか確認を完了。');
517+
518+ return resultAnc;
519+};
520+
521+THIEF.func.method.attackedBy = function(obj) {
522+
523+ THIEF.html.addDebugMessage(obj.get(THIEF.PARAM.displayName) + ' による ' + this.get(THIEF.PARAM.displayName) + ' への攻撃処理を開始...');
524+
525+ //my.slot[THIEF.PARAM.slot.hand] = selected[0];
526+ var val;
527+ if(typeof obj.slot === 'undefined' || typeof obj.slot[THIEF.PARAM.slot.hand] === 'undefined'){
528+ if(typeof obj.damage === 'undefined'){
529+ val = '1d2';
530+ } else {
531+ val = obj.damage;
532+ }
533+ } else {
534+ val = obj.slot[THIEF.PARAM.slot.hand].damage;
535+ }
536+
537+ var revP = THIEF.util.infixToRevP(val);
538+ var damage = THIEF.util.execRevP(revP);
539+
540+ THIEF.html.addDebugMessage('ベースダメージを ' + damage + 'とする。');
541+
542+ THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + ' HP : ' + this.get(THIEF.PARAM.hp) + ' -> ' + (this.get(THIEF.PARAM.hp) - damage) + 'とする。');
543+ this.hp -= damage;
544+ THIEF.Data.Text.$(THIEF.Data.Text.attack, damage, this.get(THIEF.PARAM.displayName), obj.get(THIEF.PARAM.displayName) );
545+
546+ obj.ct -= 100;
547+
548+ if (this.get(THIEF.PARAM.hp) <= 0) {
549+ THIEF.html.addDebugMessage('死亡処理を開始...');
550+ THIEF.Data.Text.$(THIEF.Data.Text.killBy, this.get(THIEF.PARAM.displayName), obj.get(THIEF.PARAM.displayName));
551+ THIEF.global.actLV.removeFromInventory(this);
552+ this.next = function() {
553+ return true
554+ };
555+ THIEF.html.addDebugMessage('...死亡処理を完了。')
556+ }
557+
558+ THIEF.html.addDebugMessage('...攻撃処理を完了。');
559+
560+ return true;
561+};
562+
563+THIEF.func.method.getInventoryXyObjects = function(x, y) {
564+ return this.inventory[x][y];
565+};
566+
567+THIEF.func.method.getInventoryXyLastObject = function(x, y) {
568+ var obj;
569+
570+ // 必ずしも inventory の配列を完全に持っているとは限らないので注意すること
571+ if (this.inventory && this.inventory[x] && this.inventory[x][y]) {
572+ obj = this.inventory[x][y].getLast();
573+ }
574+ return obj;
575+};
576+
577+THIEF.func.method.delInventoryObject = function(o) {
578+ this.delInventoryXyObject(o.x, o.y, o);
579+};
580+
581+
582+THIEF.func.method.delInventoryXyObject = function(x, y, o) {
583+ this.inventory[x][y].remove(o);
584+ if (this.mapRefreshPointList) {
585+ this.mapRefreshPointList.push({
586+ x: x,
587+ y: y
588+ });
589+ }
590+};
591+
592+// ループ処理を加えること
593+THIEF.func.method.getInventoryAlphabets = function() {
594+ var alphabets = [];
595+ if(this.inventory){
596+ for(var i=0; i<this.get(THIEF.PARAM.inventoryWidth); i++){
597+ if(this.inventory[i]){
598+ for(var j=0; j<this.get(THIEF.PARAM.inventoryHeight); j++){
599+ if(this.inventory[i][j]){
600+ for(var k=0; k<this.inventory[i][j].length; k++){
601+ var alphabet = this.inventory[i][j][k].get(THIEF.PARAM.alphabet);
602+ if(alphabet){
603+ alphabets.push(alphabet);
604+ }
605+ }
606+ }
607+ }
608+ }
609+ }
610+ }
611+
612+ return alphabets;
613+};
614+
615+THIEF.func.method.getInventoryNonExistAlphabet = function() {
616+ // 常にアルファベットの先頭が利用されないようにしている
617+ var key = THIEF.KEY;
618+ var index = key.a;
619+ return function() {
620+ var alphabets = this.getInventoryAlphabets();
621+
622+ var counter = 0;
623+ while (alphabets.indexOf(String.fromCharCode(index)) !== -1 && counter < 52) {
624+ counter++;
625+ index++;
626+ if (index === (key.z + 1)) {
627+ index = key.A;
628+ } else {
629+ if (index === (key.Z + 1)) {
630+ index = key.a;
631+ }
632+ }
633+ }
634+
635+ var alphabet;
636+ if (counter < 52) {
637+ alphabet = String.fromCharCode(index);
638+ index++;
639+ }
640+
641+ return alphabet;
642+ };
643+
644+}();
645+// items 配列を渡してカリー化(?)
646+THIEF.func.method.selecter = function(objs, exec, immediately, abc) {
647+
648+ var key = THIEF.KEY;
649+ var items = [];
650+ var selected = [];
651+ var targets = [];
652+ var i, j;
653+
654+ THIEF.html.addDebugMessage('セレクターを生成');
655+ for (i = 0; i < objs.length; i++) {
656+ THIEF.html.addDebugMessage('セレクターターゲット:' + objs[i].get(THIEF.PARAM.displayName));
657+ if (objs[i] !== this && objs[i].portable && objs[i].get(THIEF.PARAM.displayName)) {
658+ items.push(objs[i]);
659+ }
660+ }
661+
662+ // root_abc
663+ var alphabetIndex = key.a;
664+
665+ // アイテム出力
666+ for (i = 0; i < THIEF.conf.itemSort.length; i++) {
667+
668+ //アイテムがあるか確認
669+ var first = true;
670+ for (j = 0; j < items.length; j++) {
671+ if (THIEF.conf.itemSort[i] === items[j].symbol) {
672+ if (first) {
673+ first = false;
674+ THIEF.html.addInfomation('<span style="color:' + THIEF.conf.bgColor + '; background:' + THIEF.conf.textColor + '">' + items[j].get(THIEF.PARAM.symbolName) + '</span>');
675+ }
676+
677+ var alphabet;
678+ if (abc) {
679+ alphabet = String.fromCharCode(alphabetIndex);
680+ alphabetIndex++;
681+ } else {
682+ alphabet = items[j].alphabet || this.getInventoryNonExistAlphabet();
683+ if (alphabet === null) {
684+ // ページ切り替え
685+ break;
686+ }
687+ items[j].alphabet = alphabet;
688+ }
689+
690+ THIEF.html.addInfomation(alphabet + '<span id="' + THIEF.conf.id + '_' + alphabet + '">&nbsp;-&nbsp;</span>' + items[j].get(THIEF.PARAM.displayName));
691+ targets[alphabet] = items[j];
692+ }
693+ }
694+ }
695+
696+ // 選択用関数返却
697+ return function() {
698+ var finish = false;
699+ switch (THIEF.global.keycode) {
700+
701+ case '*'.charCodeAt(0):
702+
703+ break;
704+
705+ case key.Esc:
706+ finish = true;
707+ selected.length = 0;
708+ break;
709+
710+ case key.Space:
711+ break;
712+
713+ case key.Enter:
714+ finish = true;
715+ this.action = THIEF.func.method.action;
716+ break;
717+
718+ // すべてを選択しない
719+ case key.Minus:
720+ if(immediately) {
721+ selected.push(undefined);
722+ finish = true;
723+ } else {
724+ selected.length = 0;
725+ for(var i=0; i<targets.length; i++){
726+ // 表示を初期化すること
727+ }
728+ }
729+ break;
730+
731+ default:
732+ var item = targets[String.fromCharCode(THIEF.global.keycode)];
733+ var itemID = THIEF.conf.id + '_' + String.fromCharCode(THIEF.global.keycode);
734+ if (typeof item !== 'undefined') {
735+ if (document.getElementById(itemID).innerHTML === '&nbsp;-&nbsp;') {
736+ document.getElementById(itemID).innerHTML = '&nbsp;+&nbsp;';
737+ selected.push(item);
738+ } else {
739+ document.getElementById(itemID).innerHTML = '&nbsp;-&nbsp;';
740+ selected.remove(item);
741+ }
742+ }
743+ if (immediately) {
744+ finish = true;
745+ }
746+
747+ break;
748+ }
749+
750+ var result = false;
751+ if (finish) {
752+ // 画面クリア
753+ THIEF.html.clearInfomation('');
754+
755+ // アクションを元に戻す
756+ this.action = THIEF.func.method.action;
757+
758+ // 選択後のアクションを実行
759+ result = exec(selected);
760+
761+ }
762+
763+ return result;
764+ };
765+
766+};
767+
768+THIEF.func.method.cpu = function() {
769+
770+ THIEF.html.addDebugMessage('CPU行動開始...');
771+
772+ var dx = 0;
773+ var dy = 0;
774+ var diffX = THIEF.global.adventurer.x - this.x;
775+ var diffY = THIEF.global.adventurer.y - this.y;
776+
777+ /*
778+ var rad = ((Math.atan2(diffY, diffX) * 180.0 / Math.PI) + 360.0) % 360.0;
779+
780+ if (typeof rad !== 'number') {
781+
782+ } else {
783+ if (337.5 < rad || (0 <= rad && rad < 22.5)) {
784+ dx = 1;
785+ dy = 0;
786+ } else if (22.5 <= rad && rad <= 67.5) {
787+ dx = 1;
788+ dy = 1;
789+ } else if (67.5 < rad && rad < 112.5) {
790+ dx = 0;
791+ dy = 1;
792+ } else if (112.5 <= rad && rad <= 157.5) {
793+ dx = -1;
794+ dy = 1;
795+ } else if (157.5 < rad && rad < 202.5) {
796+ dx = -1;
797+ dy = 0;
798+ } else if (202.5 <= rad && rad <= 247.5) {
799+ dx = -1;
800+ dy = -1;
801+ } else if (247.5 < rad && rad < 292.5) {
802+ dx = 0;
803+ dy = -1;
804+ } else if (292.5 <= rad && rad <= 337.5) {
805+ dx = 1;
806+ dy = -1;
807+ }
808+ }
809+ */
810+
811+
812+ if (diffX > 0) {
813+ dx = 1;
814+ } else if (diffX < 0) {
815+ dx = -1;
816+ }
817+
818+ if (diffY > 0) {
819+ dy = 1;
820+ } else if (diffY < 0) {
821+ dy = -1;
822+ }
823+
824+
825+ this.move(dx, dy);
826+
827+ THIEF.html.addDebugMessage('...CPU行動完了');
828+
829+ return true;
830+};
831+
832+THIEF.func.method.move = function(dx, dy) {
833+
834+ THIEF.html.addDebugMessage('移動処理 move(' + dx + ', ' + dy + ') を開始...');
835+
836+ THIEF.html.addDebugMessage(THIEF.global.actLV.get(THIEF.PARAM.displayName) + 'のインベントリ座標[' + (this.x + dx) + ', ' + (this.y + dy) + ']を調査を行う。');
837+ var target = THIEF.global.actLV.getInventoryXyLastObject(this.x + dx, this.y + dy);
838+
839+ if (this.get(THIEF.PARAM.stackable) || target.get(THIEF.PARAM.stackable)) {
840+ var sX = this.x;
841+ var sY = this.y;
842+
843+ THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + '[' + this.x + ', ' + this.y + ']は' + target.get(THIEF.PARAM.displayName) + '[' + (this.x + dx) + ', ' + (this.y + dy) + ']の上に移動する。');
844+ THIEF.global.actLV.removeFromInventory(this);
845+
846+ THIEF.html.addDebugMessage('移動前の座標[' + sX + ', ' + sY + ']の描画を更新');
847+ THIEF.html.refreshXy(sX, sY);
848+
849+ this.x = sX + dx;
850+ this.y = sY + dy;
851+ THIEF.global.actLV.addToInventory(this, this.x, this.y);
852+
853+ THIEF.html.addDebugMessage('移動後の座標[' + this.x + ', ' + this.y + ']の描画を更新');
854+ THIEF.html.refreshXy(this.x, this.y);
855+
856+ this.ct -= 60;
857+
858+ } else {
859+ if (target.get(THIEF.PARAM.active)) {
860+ THIEF.html.addDebugMessage('active なものが対象なので攻撃してみる。');
861+ target.attackedBy(this);
862+ } else {
863+ THIEF.html.addDebugMessage('インベントリ座標[' + (this.x + dx) + ', ' + (this.y + dy) + '] には移動できない。');
864+ }
865+ }
866+
867+ THIEF.html.addDebugMessage('...移動処理を完了。');
868+
869+ return true;
870+};
871+
872+THIEF.func.method.inputWait = function () {
873+ this.next = THIEF.func.method.manual;
874+ THIEF.html.addDebugMessage('入力待ち');
875+ return false;
876+};
877+
878+// 基本は AI 処理とする
879+THIEF.func.method.next = function() { return this.cpu(); };
880+
881+THIEF.func.method.notify = function() {
882+
883+ if (typeof this.inventory !== "undefined") {
884+ var width = this.get(THIEF.PARAM.inventoryWidth);
885+ for (var x = 0; x < width; x++) {
886+ if (typeof this.inventory[x] === "undefined") {
887+ break;
888+ }
889+ var length = this.get(THIEF.PARAM.inventoryHeight);
890+ for (var y = 0; y < length; y++) {
891+ if (typeof this.inventory[x][y] === "undefined") {
892+ break;
893+ }
894+ var height = this.inventory[x][y].length;
895+ for (var h = 0; h < height; h++) {
896+ this.inventory[x][y][h].notify();
897+ }
898+ }
899+ }
900+ }
901+
902+ // CT を増加
903+ if (this.get(THIEF.PARAM.active)) {
904+ if (typeof this.get(THIEF.PARAM.dex) === undefined) {
905+ this[THIEF.PARAM.ct] += this.get(THIEF.PARAM.dex);
906+ } else {
907+ this[THIEF.PARAM.ct] += 26; // test
908+ }
909+ THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + ' の CT を ' + this[THIEF.PARAM.ct] + ' に増加。');
910+ }
911+
912+ // ct が 100 を超えていたら行動対象に登録
913+ if (this.get(THIEF.PARAM.ct) >= 100) {
914+ if (typeof this[THIEF.PARAM.myOwner][THIEF.PARAM.actObjectList] === "undefined") {
915+ this[THIEF.PARAM.myOwner][THIEF.PARAM.actObjectList] = [];
916+ }
917+ THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + ' を、オーナ:' + this[THIEF.PARAM.myOwner].get(THIEF.PARAM.displayName) + ' に登録。');
918+ this[THIEF.PARAM.myOwner][THIEF.PARAM.actObjectList].push(this);
919+ }
920+};
921+
922+THIEF.func.method.action = function() {
923+
924+ THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + ' の行動を開始...');
925+
926+ if (typeof this[THIEF.PARAM.actObjectList] !== 'undefined') {
927+
928+ // ct の小さい順にソートする
929+ for (var i = 0; i < this[THIEF.PARAM.actObjectList].length - 2; i++) {
930+ var isSorted = true;
931+ for (var j = this[THIEF.PARAM.actObjectList].length - 1; j >= (1 + i); j--) {
932+ if (this[THIEF.PARAM.actObjectList][j].get(THIEF.PARAM.ct) < this[THIEF.PARAM.actObjectList][j - 1].get(THIEF.PARAM.ct)) {
933+ var swap = this[THIEF.PARAM.actObjectList][j];
934+ this[THIEF.PARAM.actObjectList][j] = this[THIEF.PARAM.actObjectList][j - 1];
935+ this[THIEF.PARAM.actObjectList][j - 1] = swap;
936+ isSorted = false;
937+ }
938+ }
939+ if (isSorted) {
940+ break;
941+ }
942+ }
943+
944+ // ct の大きい順(配列の最後部)から実行
945+ var obj = this[THIEF.PARAM.actObjectList].pop();
946+ for (; typeof obj !== 'undefined'; obj = this[THIEF.PARAM.actObjectList].pop()) {
947+ THIEF.html.addDebugMessage(obj.get(THIEF.PARAM.displayName) + ' の処理を開始...');
948+ if (obj.action() === false) {
949+ // 行動が完了しない場合、現在のオブジェクトを再登録して一時停止(結果的に入力を待つ)
950+ THIEF.html.addDebugMessage('...' + obj.get(THIEF.PARAM.displayName) + ' は処理が完了しなかった。');
951+ this[THIEF.PARAM.actObjectList].push(obj);
952+
953+ break;
954+ }
955+ THIEF.html.addDebugMessage('...処理を完了');
956+ }
957+ }
958+
959+ var result = true;
960+ if (typeof this[THIEF.PARAM.actObjectList] === 'undefined' || this[THIEF.PARAM.actObjectList].length === 0) {
961+ if (this.active && this.turnEnd !== THIEF.global.turn) {
962+
963+ if (this.get(THIEF.PARAM.ct) >= 100) {
964+ if (this.next()) {
965+ this.turnEnd = THIEF.global.turn;
966+ //this[THIEF.PARAM.ct] -= 100;
967+ result = true;
968+ } else {
969+ result = false;
970+ }
971+ }
972+ }
973+ } else if (this[THIEF.PARAM.actObjectList].length > 0) {
974+ result = false;
975+ }
976+
977+ THIEF.html.addDebugMessage('... ' + this.get(THIEF.PARAM.displayName) + ' の行動を完了。 (result = ' + result + ')');
978+
979+ return result;
980+};
981+
982+THIEF.func.method.decay = function() {
983+
984+ if (this.decayable) {
985+ this.dp--;
986+ if (this.dp <= 0) {
987+ THIEF.Data.Text.$(THIEF.Data.Text.decay, this.name);
988+ THIEF.global.actLV.delInventoryObject(this);
989+ }
990+ }
991+
992+ return true;
993+};
994+
995+THIEF.func.method.manual = function() {
996+
997+ var finish = true;
998+ var code = THIEF.global.keycode;
999+
1000+ if (code === 0) {
1001+ finish = false;
1002+ THIEF.html.addDebugMessage('無効なキー入力のため、何の処理もしない。')
1003+ } else {
1004+ THIEF.global.keycode = 0;
1005+ THIEF.html.addDebugMessage(String.fromCharCode(code) + '(' + code + ')の入力に対する処理を開始...');
1006+ if (typeof THIEF.func.method.manual[code] === 'function') {
1007+ THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + ' の ' + THIEF.func.method.manual[code] + 'を実行');
1008+ finish = THIEF.func.method.manual[code].apply(this);
1009+ } else {
1010+ finish = false;
1011+ }
1012+
1013+ if (typeof finish === 'undefined') {
1014+ finish = false;
1015+ }
1016+ THIEF.html.addDebugMessage('...' + String.fromCharCode(code) + '(' + code + ')の入力に対する処理を完了。(return : ' + finish + ')');
1017+
1018+ if (finish) {
1019+ this.next = THIEF.func.method.inputWait;
1020+ }
1021+ }
1022+
1023+ return finish;
1024+};
1025+
1026+// 束縛しないように関数化している
1027+THIEF.func.method.manual[THIEF.KEY.h] = function() { return this.goLeft(); };
1028+THIEF.func.method.manual[THIEF.KEY.k] = function() { return this.goUp(); };
1029+THIEF.func.method.manual[THIEF.KEY.j] = function() { return this.goDown(); };
1030+THIEF.func.method.manual[THIEF.KEY.l] = function() { return this.goRight(); };
1031+THIEF.func.method.manual[THIEF.KEY.y] = function() { return this.goUpperLeft(); };
1032+THIEF.func.method.manual[THIEF.KEY.u] = function() { return this.goUpperRight(); };
1033+THIEF.func.method.manual[THIEF.KEY.b]= function() { return this.goLowerLeft(); };
1034+THIEF.func.method.manual[THIEF.KEY.n] = function() { return this.goLowerRight(); };
1035+THIEF.func.method.manual[THIEF.KEY.R] = function() { return this.refreshHTML(); };
1036+THIEF.func.method.manual[THIEF.KEY.Comma] = function() { return this.pickup(); };
1037+THIEF.func.method.manual[THIEF.KEY.d] = function() { return this.drop(); };
1038+// TTHIEF.func.method.manual[THIEF.KEY.i] = function() { return this.showInventory(); };
1039+THIEF.func.method.manual[THIEF.KEY.p] = function() { return this.history(); };
1040+THIEF.func.method.manual[THIEF.KEY.s] = function() { return this.rest(); };
1041+THIEF.func.method.manual[THIEF.KEY.w] = function() { return this.wield(); };
1042+THIEF.func.method.manual[THIEF.KEY.Period] = function() { return this.rest(); };
1043+THIEF.func.method.manual[THIEF.KEY.Sharp] = function() { return this.extendedCommand(); };
1044+
1045+THIEF.func.command = {}; // マニュアルコマンドで実行して良いもの
1046+THIEF.func.command.goUp = function() {
3391047 return this.move(0, -1);
3401048 };
3411049
342-THIEF.command.goDown = function() {
1050+THIEF.func.command.goDown = function() {
3431051 return this.move(0, 1);
3441052 };
3451053
346-THIEF.command.goLeft = function() {
1054+THIEF.func.command.goLeft = function() {
3471055 return this.move(-1, 0);
3481056 };
3491057
350-THIEF.command.goRight = function() {
1058+THIEF.func.command.goRight = function() {
3511059 return this.move(1, 0);
3521060 };
3531061
354-THIEF.command.goUpperLeft = function() {
1062+THIEF.func.command.goUpperLeft = function() {
3551063 return this.move(-1, -1);
3561064 };
3571065
358-THIEF.command.goUpperRight = function() {
1066+THIEF.func.command.goUpperRight = function() {
3591067 return this.move(1, -1);
3601068 };
3611069
362-THIEF.command.goLowerLeft = function() {
1070+THIEF.func.command.goLowerLeft = function() {
3631071 return this.move(-1, 1);
3641072 };
3651073
366-THIEF.command.goLowerRight = function() {
1074+THIEF.func.command.goLowerRight = function() {
3671075 return this.move(1, 1);
3681076 };
3691077
370-THIEF.command.refreshHTML = function() {
1078+THIEF.func.command.refreshHTML = function() {
3711079 THIEF.html.refresh();
3721080 return false;
3731081 };
3741082
375-THIEF.command.rest = function() {
1083+THIEF.func.command.rest = function() {
3761084 return true;
3771085 };
3781086
379-THIEF.command.pickup = function() {
380- var objs = THIEF.global.actLV.getXyObjects(this.x, this.y);
1087+THIEF.func.command.pickup = function() {
1088+ var objs = THIEF.global.actLV.getInventoryXyObjects(this.x, this.y);
3811089 var finish = true;
3821090 // メソッド書き換え
3831091 if (objs.length > 2) { // 自分と床以外になにかあれば(?)
@@ -394,9 +1102,9 @@
3941102 // 重量オーバなら拾えない様にすること
3951103 if (from.removeFromInventory(selected[i])) {
3961104 to.addToInventory(selected[i]);
397- THIEF.TEXT.$(THIEF.TEXT.pickup, selected[i].get(THIEF.PARAM.displayName), to.get(THIEF.PARAM.displayName));
1105+ THIEF.Data.Text.$(THIEF.Data.Text.pickup, selected[i].get(THIEF.PARAM.displayName), to.get(THIEF.PARAM.displayName));
3981106 } else {
399- THIEF.TEXT.$(THIEF.TEXT.canNotPickup, selected[i].get(THIEF.PARAM.displayName), to.get(THIEF.PARAM.displayName));
1107+ THIEF.Data.Text.$(THIEF.Data.Text.canNotPickup, selected[i].get(THIEF.PARAM.displayName), to.get(THIEF.PARAM.displayName));
4001108 }
4011109 }
4021110
@@ -403,15 +1111,15 @@
4031111 return result;
4041112 };
4051113
406- this.action = THIEF.type.$.selecter(objs, exec, false, true);
1114+ this.action = THIEF.func.method.selecter(objs, exec, false, true);
4071115 finish = false;
4081116 } else {
409- THIEF.TEXT.$(THIEF.TEXT.noItemHere);
1117+ THIEF.Data.Text.$(THIEF.Data.Text.noItemHere);
4101118 }
4111119 return finish;
4121120 };
4131121
414-THIEF.command.drop = function() {
1122+THIEF.func.command.drop = function() {
4151123
4161124 // とりあえず一次元配列化
4171125 var list = [];
@@ -451,9 +1159,9 @@
4511159 // 呪われてたら捨てれない様にすること
4521160 if (from.removeFromInventory(selected[i])) {
4531161 to.addToInventory(selected[i], from.x, from.y);
454- THIEF.TEXT.$(THIEF.TEXT.drop, selected[i].get(THIEF.PARAM.displayName), from.get(THIEF.PARAM.displayName), to.get(THIEF.PARAM.displayName));
1162+ THIEF.Data.Text.$(THIEF.Data.Text.drop, selected[i].get(THIEF.PARAM.displayName), from.get(THIEF.PARAM.displayName), to.get(THIEF.PARAM.displayName));
4551163 } else {
456- THIEF.TEXT.$(THIEF.TEXT.canNotDrop, selected[i].get(THIEF.PARAM.displayName), from.get(THIEF.PARAM.displayName), to.get(THIEF.PARAM.displayName));
1164+ THIEF.Data.Text.$(THIEF.Data.Text.canNotDrop, selected[i].get(THIEF.PARAM.displayName), from.get(THIEF.PARAM.displayName), to.get(THIEF.PARAM.displayName));
4571165 }
4581166 }
4591167
@@ -467,17 +1175,17 @@
4671175 return act;
4681176 };
4691177
470- this.action = THIEF.type.$.selecter(list, exec, false, false);
1178+ this.action = THIEF.func.method.selecter(list, exec, false, false);
4711179 //result = this.action();
4721180 //result = false;
4731181 } else {
474- THIEF.TEXT.$(THIEF.TEXT.inventoryIsEmpty);
1182+ THIEF.Data.Text.$(THIEF.Data.Text.inventoryIsEmpty);
4751183 }
4761184
4771185 return false;
4781186 };
4791187
480-THIEF.command.showInventory = function() {
1188+THIEF.func.command.showInventory = function() {
4811189
4821190 THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + 'のインベントリ表示を開始...');
4831191
@@ -505,9 +1213,9 @@
5051213
5061214
5071215 if (list.length === 0) {
508- THIEF.TEXT.$(THIEF.TEXT.inventoryIsEmpty);
1216+ THIEF.Data.Text.$(THIEF.Data.Text.inventoryIsEmpty);
5091217 } else {
510- this.action = THIEF.type.$.selecter(list, this.action, true, false);
1218+ this.action = THIEF.func.method.selecter(list, this.action, true, false);
5111219 }
5121220
5131221 THIEF.html.addDebugMessage('...' + this.get(THIEF.PARAM.displayName) + 'のインベントリ表示を完了。');
@@ -515,7 +1223,7 @@
5151223 return false;
5161224 };
5171225
518-THIEF.command.history = function() {
1226+THIEF.func.command.history = function() {
5191227
5201228 var key = THIEF.KEY;
5211229
@@ -573,7 +1281,7 @@
5731281 // 画面クリア
5741282 THIEF.html.clearInfomation('');
5751283 // アクションを元に戻す
576- this.action = THIEF.type.$.action;
1284+ this.action = THIEF.func.method.action;
5771285 } else {
5781286 THIEF.html.clearInfomation();
5791287 //for (var i = THIEF.conf.messageLines - 1; i >= 0; i--) {
@@ -593,7 +1301,7 @@
5931301 return false;
5941302 };
5951303
596-THIEF.command.extendedCommand = function() {
1304+THIEF.func.command.extendedCommand = function() {
5971305
5981306 var key = THIEF.KEY;
5991307
@@ -600,7 +1308,7 @@
6001308 THIEF.html.setInput('#');
6011309
6021310 var com = [];
603- for (var name in THIEF.command) {
1311+ for (var name in THIEF.func.command) {
6041312 com.push(name);
6051313 }
6061314 com.sort();
@@ -628,15 +1336,15 @@
6281336 } else if (THIEF.global.keycode === key.Esc) {
6291337 THIEF.html.setInput('&nbsp;');
6301338 THIEF.html.clearInfomation();
631- this.action = THIEF.type.$.action;
1339+ this.action = THIEF.func.method.action;
6321340 } else if (THIEF.global.keycode === key.Enter) {
6331341 THIEF.html.setInput('&nbsp;');
6341342 THIEF.html.clearInfomation();
635- this.action = THIEF.type.$.action;
636- if (typeof THIEF.command[target] === 'function') {
1343+ this.action = THIEF.func.method.action;
1344+ if (typeof THIEF.func.command[target] === 'function') {
6371345 finish = this[target]();
6381346 } else {
639- THIEF.TEXT.$(THIEF.TEXT.commandNotFound, line);
1347+ THIEF.Data.Text.$(THIEF.Data.Text.commandNotFound, line);
6401348 }
6411349 }
6421350
@@ -664,10 +1372,8 @@
6641372 return this.action();
6651373 };
6661374
1375+THIEF.func.command.wield = function () {
6671376
668-// TODO
669-THIEF.command.wield = function () {
670-
6711377 /*
6721378 //var val = '2d100 * (2 + 15) + Math.max(3, 4) + (Math.round(11.2) * Math.PI + 6)';
6731379 var val = 'Math.round(5 / (4 + 5) * 10 / (6 - 3))';
@@ -713,9 +1419,9 @@
7131419 my.slot[THIEF.PARAM.slot.hand] = selected[0];
7141420
7151421 if(typeof selected[0] === 'undefined'){
716- THIEF.TEXT.$(THIEF.TEXT.wieldNone, my.get(THIEF.PARAM.displayName));
1422+ THIEF.Data.Text.$(THIEF.Data.Text.wieldNone, my.get(THIEF.PARAM.displayName));
7171423 } else {
718- THIEF.TEXT.$(THIEF.TEXT.wieldWeapon, selected[0].get(THIEF.PARAM.displayName), my.get(THIEF.PARAM.displayName));
1424+ THIEF.Data.Text.$(THIEF.Data.Text.wieldWeapon, selected[0].get(THIEF.PARAM.displayName), my.get(THIEF.PARAM.displayName));
7191425 THIEF.html.addDebugMessage(selected[0].get(THIEF.PARAM.displayName) + ' を手に装備した。');
7201426 }
7211427 // }
@@ -723,11 +1429,11 @@
7231429 return act;
7241430 };
7251431
726- this.action = THIEF.type.$.selecter(list, exec, true, false);
1432+ this.action = THIEF.func.method.selecter(list, exec, true, false);
7271433 //result = this.action();
7281434 //result = false;
7291435 } else {
730- THIEF.TEXT.$(THIEF.TEXT.inventoryIsEmpty);
1436+ THIEF.Data.Text.$(THIEF.Data.Text.inventoryIsEmpty);
7311437 }
7321438 };
7331439
@@ -766,8 +1472,7 @@
7661472 };
7671473
7681474 THIEF.util.test = function() {
769-
770- THIEF.global.adventurer = Object.create(THIEF.type.Human);
1475+ THIEF.global.adventurer = THIEF.util.factory(THIEF.Data.Obj.Human);
7711476 THIEF.global.adventurer.color = 'red';
7721477 THIEF.global.adventurer.next = THIEF.global.adventurer.inputWait;
7731478 THIEF.global.adventurer.name = {
@@ -785,14 +1490,13 @@
7851490 THIEF.global.actLV.addToInventory(THIEF.global.adventurer);
7861491
7871492 var tmp;
788- tmp = Object.create(THIEF.type._item._weapon.TestDugger);
1493+ tmp = THIEF.util.factory(THIEF.Data.Obj.DebugDagger);
7891494 tmp.alphabet = 'k';
7901495 THIEF.global.adventurer.addToInventory(tmp);
7911496
792- THIEF.util.spawn(THIEF.type._life._humanoid.Daemon);
793- THIEF.util.spawn(THIEF.type._life._humanoid.Daemon);
794- THIEF.util.spawn(THIEF.type._life._humanoid.Daemon);
795-
1497+ THIEF.util.spawn(THIEF.Data.Obj.DebugDaemon);
1498+ THIEF.util.spawn(THIEF.Data.Obj.DebugDaemon);
1499+ THIEF.util.spawn(THIEF.Data.Obj.DebugDaemon);
7961500 };
7971501
7981502 THIEF.util.next = function () {
@@ -821,7 +1525,7 @@
8211525
8221526 // 各レベルに実施させること
8231527 if (Math.random() > 0.9) {
824- THIEF.util.spawn(THIEF.type._life._humanoid.Daemon);
1528+ THIEF.util.spawn(THIEF.Data.Obj.DebugDaemon);
8251529 }
8261530 } else {
8271531 THIEF.html.addDebugMessage('<em>ターン:' + THIEF.global.turn + ' を再開...</em>');
@@ -1032,19 +1736,146 @@
10321736
10331737 };
10341738
1739+THIEF.util.factory = function() {
1740+
1741+ var tree = [];
1742+ var id = 0;
1743+
1744+ return function(obj) {
1745+
1746+ //THIEF.html.addDebugMessage('オブジェクトの生成処理を開始...');
1747+ //THIEF.html.addDebugMessage('マスターの有無を確認...');
1748+
1749+ if (typeof obj.uniqNumber === 'undefined') {
1750+ THIEF.html.addDebugMessage('要求オブジェクトのマスタが存在しないので作成開始...');
1751+
1752+ var inh = obj.inheritance || '$';
1753+ var inhPrev = '$';
1754+ var stack = [];
1755+
1756+ while (typeof inh !== 'undefined') {
1757+ stack.push(inh);
1758+ inh = THIEF.Data.Obj[inh].inheritance;
1759+ }
1760+
1761+ if (stack.getLast() !== '$') {
1762+ stack.push('$');
1763+ }
1764+
1765+ THIEF.html.addDebugMessage('以下の継承を遡って親マスタの有無を確認');
1766+ THIEF.html.addDebugMessage('this,' + stack.toString() + '.');
1767+
1768+ // 以下の順番で作成します
1769+ var propName;
1770+ while (stack.length > 0) {
1771+ inhPrev = inh || '$';
1772+ inh = stack.pop();
1773+
1774+ if (typeof THIEF.Data.Obj[inh].uniqNumber === 'undefined') {
1775+ THIEF.html.addDebugMessage(inh + ' のマスタが生成されていないので作成...');
1776+
1777+ if(typeof THIEF.Data.Obj[inh].uniqNumber === 'undefined'){
1778+ THIEF.Data.Obj[inh].uniqNumber = id;
1779+ id++;
1780+ }
1781+
1782+ if (inh === '$') {
1783+ tree[THIEF.Data.Obj[inh].uniqNumber] = {};
1784+ THIEF.html.addDebugMessage('以下のプロパティを Data.Obj.' + inh + ' からコピー...');
1785+ for (propName in THIEF.func.method) {
1786+ if (THIEF.func.method.hasOwnProperty(propName)) {
1787+ tree[THIEF.Data.Obj[inh].uniqNumber][propName] = THIEF.func.method[propName];
1788+ THIEF.html.addDebugMessage('.' + propName);
1789+ }
1790+ }
1791+
1792+ for (propName in THIEF.func.command) {
1793+ if (THIEF.func.command.hasOwnProperty(propName)) {
1794+ tree[THIEF.Data.Obj[inh].uniqNumber][propName] = THIEF.func.command[propName];
1795+ THIEF.html.addDebugMessage('.' + propName);
1796+ }
1797+ }
1798+
1799+ for (propName in THIEF.Data.Obj.$) {
1800+ if (THIEF.Data.Obj.$.hasOwnProperty(propName)) {
1801+ tree[THIEF.Data.Obj[inh].uniqNumber][propName] = THIEF.Data.Obj.$[propName];
1802+ THIEF.html.addDebugMessage('.' + propName);
1803+ }
1804+ }
1805+ THIEF.html.addDebugMessage('...コピー完了');
1806+
1807+ } else {
1808+ THIEF.html.addDebugMessage(inhPrev + 'マスタを元に' + inh + 'のマスタを作成');
1809+ tree[THIEF.Data.Obj[inh].uniqNumber] = Object.create(tree[THIEF.Data.Obj[inhPrev].uniqNumber]);
1810+
1811+ THIEF.html.addDebugMessage('以下のプロパティを Data.Obj.' + inh + ' からコピー...');
1812+ for (propName in THIEF.Data.Obj[inh]) {
1813+ if (THIEF.Data.Obj[inh].hasOwnProperty(propName)) {
1814+ tree[THIEF.Data.Obj[inh].uniqNumber][propName] = THIEF.Data.Obj[inh][propName];
1815+ THIEF.html.addDebugMessage('.' + propName);
1816+ }
1817+ }
1818+ THIEF.html.addDebugMessage('.inheritance = ' + inhPrev );
1819+ tree[THIEF.Data.Obj[inh].uniqNumber].inheritance = inhPrev;
1820+ THIEF.html.addDebugMessage('...コピー完了');
1821+
1822+ }
1823+
1824+ THIEF.html.addDebugMessage('...作成完了');
1825+ }
1826+ }
1827+ inhPrev = inh;
1828+
1829+ THIEF.html.addDebugMessage('...作成完了');
1830+
1831+ obj.uniqNumber = id;
1832+ id++;
1833+
1834+ if(obj !== THIEF.Data.Obj.$){
1835+ THIEF.html.addDebugMessage('要求オブジェクトのマスタ作成開始...');
1836+ THIEF.html.addDebugMessage(inhPrev + ' より雛形オブジェクトを作成');
1837+ tree[obj.uniqNumber] = Object.create(tree[THIEF.Data.Obj[inhPrev].uniqNumber]);
1838+ THIEF.html.addDebugMessage('Own Property をコピー開始...');
1839+ for(propName in obj) {
1840+ if(obj.hasOwnProperty(propName)){
1841+ tree[obj.uniqNumber][propName] = obj[propName];
1842+ THIEF.html.addDebugMessage('.' + propName);
1843+ }
1844+ }
1845+ THIEF.html.addDebugMessage('.inheritance = ' + inhPrev );
1846+ tree[obj.uniqNumber].inheritance = inhPrev;
1847+ THIEF.html.addDebugMessage('...コピー完了');
1848+ THIEF.html.addDebugMessage('...マスタ作成完了');
1849+ }
1850+
1851+ //THIEF.html.addDebugMessage('...マスターの生成を完了');
1852+ } else {
1853+ //THIEF.html.addDebugMessage('...マスターは生成済み');
1854+ }
1855+
1856+ //THIEF.html.addDebugMessage('マスターからインスタンスを作成');
1857+ var val = Object.create(tree[obj.uniqNumber]);
1858+
1859+ //THIEF.html.addDebugMessage('...オブジェクトの生成処理を完了');
1860+
1861+ return Object.create(val);
1862+ };
1863+}();
1864+
10351865 THIEF.util.createLevel = function() {
10361866
1037- var lv = Object.create(THIEF.type.Level);
1867+ var lv = THIEF.util.factory(THIEF.Data.Obj.$Level);
10381868 lv.mapRefreshPointList = [];
10391869 lv.inventory = THIEF.util.createMap(THIEF.conf.mapWidth, THIEF.conf.mapHeight);
1040- lv.set(THIEF.PARAM.name, {ja:'テストレベル', en:'Practice'});
1041- lv.set(THIEF.PARAM.inventoryWidth, THIEF.conf.mapWidth);
1042- lv.set(THIEF.PARAM.inventoryHeight, THIEF.conf.mapHeight);
1043- lv.set(THIEF.PARAM.inventoryDepth, THIEF.conf.mapDepth);
1870+ lv[THIEF.PARAM.name] = {ja:'テストレベル', en:'Practice'};
1871+ lv[THIEF.PARAM.inventoryWidth] = THIEF.conf.mapWidth;
1872+ lv[THIEF.PARAM.inventoryHeight] = THIEF.conf.mapHeight;
1873+ lv[THIEF.PARAM.inventoryDepth] = THIEF.conf.mapDepth;
10441874 lv.inventoryCellSize = 1;
10451875 return lv;
10461876 };
10471877
1878+// TODO
10481879 THIEF.util.createMap = function(width, height) {
10491880
10501881 var i, j;
@@ -1056,7 +1887,7 @@
10561887 for (j = 0; j < height; j++) {
10571888 line[j] = [];
10581889 if (i === 0 || j === 0 || i === (width - 1) || j === (height - 1)) {
1059- line[j].push(THIEF.type.Wall.NonDiggable);
1890+ line[j].push( THIEF.util.factory(THIEF.Data.Obj.NonDiggableWall) );
10601891 }
10611892 }
10621893 map[i] = line;
@@ -1140,7 +1971,7 @@
11401971 // 一般的にマップ全体は横幅の方が長いと仮定している
11411972 // 壁までの距離が短い方に伸ばすように分割線を引く
11421973 // 長い方に伸ばすように引くと部屋が小さくなるため
1143- map[ax][ay].push(THIEF.type.Floor.Dark);
1974+ map[ax][ay].push( THIEF.util.factory(THIEF.Data.Obj.DarkFloor) );
11441975 anchors.push({x:ax, y:ay});
11451976
11461977 if (my < mx) {
@@ -1147,7 +1978,7 @@
11471978 // 縦に引く
11481979 for (i = ay - 1; i >= 0; i--) {
11491980 if (map[ax][i].length === 0) {
1150- map[ax][i].push(THIEF.type.Floor.Dark);
1981+ map[ax][i].push(THIEF.util.factory(THIEF.Data.Obj.DarkFloor));
11511982 } else {
11521983 roomEdges.push({x:ax + 1, y:i + 1});
11531984 break;
@@ -1155,7 +1986,7 @@
11551986 }
11561987 for (i = ay + 1; i < height; i++) {
11571988 if (map[ax][i].length === 0) {
1158- map[ax][i].push(THIEF.type.Floor.Dark);
1989+ map[ax][i].push(THIEF.util.factory(THIEF.Data.Obj.DarkFloor));
11591990 } else {
11601991 break;
11611992 }
@@ -1164,7 +1995,7 @@
11641995 // 横に引く
11651996 for (i = ax - 1; i >= 0; i--) {
11661997 if (map[i][ay].length === 0) {
1167- map[i][ay].push(THIEF.type.Floor.Dark);
1998+ map[i][ay].push(THIEF.util.factory(THIEF.Data.Obj.DarkFloor));
11681999 } else {
11692000 roomEdges.push({x:i + 1, y:ay + 1});
11702001 break;
@@ -1172,7 +2003,7 @@
11722003 }
11732004 for (i = ax + 1; i < width; i++) {
11742005 if (map[i][ay].length === 0) {
1175- map[i][ay].push(THIEF.type.Floor.Dark);
2006+ map[i][ay].push(THIEF.util.factory(THIEF.Data.Obj.DarkFloor));
11762007 } else {
11772008 break;
11782009 }
@@ -1232,14 +2063,15 @@
12322063 for (i = startX; i < endX; i++) {
12332064 for (j = startY; j < endY; j++) {
12342065 if (i === startX || i === (endX - 1) || j === startY || j === (endY - 1)) {
1235- map[x + i][y + j].push(THIEF.type.Wall.Normal);
2066+ map[x + i][y + j].push(THIEF.util.factory(THIEF.Data.Obj.NormalWall));
12362067 } else {
1237- map[x + i][y + j].push(THIEF.type.Floor.Lit);
2068+ map[x + i][y + j].push(THIEF.util.factory(THIEF.Data.Obj.LitFloor));
12382069 }
12392070 }
12402071 }
12412072 }
12422073
2074+ /* TODO
12432075 // 今は仮の処理として、部屋の中心から(どこかの)アンカーに向かって経路を引く
12442076 // アンカーが一個足りないのでマップの中心として追加
12452077 anchors.push({x:Math.floor(THIEF.conf.mapWidth / 2), y:Math.floor(THIEF.conf.mapHeight / 2)});
@@ -1270,18 +2102,20 @@
12702102 dy += vy;
12712103 }
12722104
2105+ //alert(typeof map);
2106+
12732107 var pix = map[centers[i].x + dx][centers[i].y + dy];
12742108 var obj = pix.getLast();
12752109
12762110 if (typeof obj === 'undefined') { // 道を作る
1277- pix.push(THIEF.type.Floor.Dark);
2111+ pix.push(THIEF.util.factory(THIEF.Data.Obj.DarkFloor));
12782112 if (door > 0) { // ドアを作った後はひたすらまっすぐ
12792113 counter++;
12802114 }
12812115
1282- } else if (obj === THIEF.type.Wall.Normal) { // ドアを作る
1283- pix.remove(THIEF.type.Wall.Normal);
1284- pix.push(THIEF.type.Floor.Lit);
2116+ } else if (obj.prototype === THIEF.Data.Obj.NormalWall) { // ドアを作る
2117+ pix.remove(THIEF.util.factory(THIEF.Data.Obj.NormalWall));
2118+ pix.push(THIEF.util.factory(THIEF.Data.Obj.LitFloor));
12852119 if (door === 2) {
12862120 break; // 二回ドアを作ったら終了
12872121 }
@@ -1288,7 +2122,7 @@
12882122 counter++;
12892123 door++;
12902124
1291- } else if (obj === THIEF.type.Floor.Dark || obj === THIEF.type.Wall.NonDiggable) {
2125+ } else if (obj.prototype === THIEF.Data.Obj.DarkFloor || obj.prototype === THIEF.Data.Obj.NonDiggableWall) {
12922126 break;
12932127 }
12942128 }
@@ -1301,26 +2135,26 @@
13012135 // 上から
13022136 for (i = 1; i < width - 1; i++) {
13032137 for (j = 1; j < height - 1; j++) {
1304- if (map[i][j].getLast() === THIEF.type.Floor.Dark) {
2138+ if (map[i][j].getLast().prototype === THIEF.Data.Obj.DarkFloor) {
13052139 cnt = 0;
13062140 around = map[i - 1][j].getLast();
1307- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2141+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13082142 cnt++;
13092143 }
13102144 around = map[i + 1][j].getLast();
1311- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2145+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13122146 cnt++;
13132147 }
13142148 around = map[i][j - 1].getLast();
1315- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2149+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13162150 cnt++;
13172151 }
13182152 around = map[i][j + 1].getLast();
1319- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2153+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13202154 cnt++;
13212155 }
13222156 if (cnt < 2) {
1323- map[i][j].remove(THIEF.type.Floor.Dark);
2157+ map[i][j].remove(THIEF.Data.Obj.DarkFloor);
13242158 }
13252159 }
13262160 }
@@ -1329,26 +2163,26 @@
13292163 // 下から
13302164 for (i = 1; i <= width - 1; i++) {
13312165 for (j = height - 1; j > 1; j--) {
1332- if (map[i][j].getLast() === THIEF.type.Floor.Dark) {
2166+ if (map[i][j].getLast().prototype === THIEF.Data.Obj.DarkFloor) {
13332167 cnt = 0;
13342168 around = map[i - 1][j].getLast();
1335- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2169+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13362170 cnt++;
13372171 }
13382172 around = map[i + 1][j].getLast();
1339- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2173+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13402174 cnt++;
13412175 }
13422176 around = map[i][j - 1].getLast();
1343- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2177+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13442178 cnt++;
13452179 }
13462180 around = map[i][j + 1].getLast();
1347- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2181+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13482182 cnt++;
13492183 }
13502184 if (cnt < 2) {
1351- map[i][j].remove(THIEF.type.Floor.Dark);
2185+ map[i][j].remove(THIEF.Data.Obj.DarkFloor);
13522186 }
13532187 }
13542188 }
@@ -1357,26 +2191,26 @@
13572191 // 左から
13582192 for (i = 1; i < height - 1; i++) {
13592193 for (j = 1; j < width - 1; j++) {
1360- if (map[j][i].getLast() === THIEF.type.Floor.Dark) {
2194+ if (map[j][i].getLast().prototype === THIEF.Data.Obj.DarkFloor) {
13612195 cnt = 0;
13622196 around = map[j - 1][i].getLast();
1363- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2197+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13642198 cnt++;
13652199 }
13662200 around = map[j + 1][i].getLast();
1367- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2201+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13682202 cnt++;
13692203 }
13702204 around = map[j][i - 1].getLast();
1371- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2205+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13722206 cnt++;
13732207 }
13742208 around = map[j][i + 1].getLast();
1375- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2209+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13762210 cnt++;
13772211 }
13782212 if (cnt < 2) {
1379- map[j][i].remove(THIEF.type.Floor.Dark);
2213+ map[j][i].remove(THIEF.Data.Obj.DarkFloor);
13802214 }
13812215 }
13822216 }
@@ -1385,36 +2219,39 @@
13852219 // 右から
13862220 for (i = 1; i < height - 1; i++) {
13872221 for (j = width - 1; j > 1; j--) {
1388- if (map[j][i].getLast() === THIEF.type.Floor.Dark) {
2222+ if (map[j][i].getLast().prototype === THIEF.Data.Obj.DarkFloor) {
13892223 cnt = 0;
13902224 around = map[j - 1][i].getLast();
1391- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2225+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13922226 cnt++;
13932227 }
13942228 around = map[j + 1][i].getLast();
1395- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2229+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
13962230 cnt++;
13972231 }
13982232 around = map[j][i - 1].getLast();
1399- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2233+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
14002234 cnt++;
14012235 }
14022236 around = map[j][i + 1].getLast();
1403- if (around === THIEF.type.Floor.Dark || around === THIEF.type.Wall.Door || around === THIEF.type.Floor.Lit) {
2237+ if (around.prototype === THIEF.Data.Obj.DarkFloor || around.prototype === THIEF.Data.Obj.Door || around.prototype === THIEF.Data.Obj.LitFloor) {
14042238 cnt++;
14052239 }
14062240 if (cnt < 2) {
1407- map[j][i].remove(THIEF.type.Floor.Dark);
2241+ map[j][i].remove(THIEF.Data.Obj.DarkFloor);
14082242 }
14092243 }
14102244 }
14112245 }
14122246
2247+ */
2248+
14132249 // 残りを初期化
14142250 for (i = 0; i < width; i++) {
14152251 for (j = 0; j < height; j++) {
14162252 if (map[i][j].length === 0) {
1417- map[i][j].push(THIEF.type.Wall.Hidden);
2253+ //map[i][j].push( THIEF.util.factory(THIEF.Data.Obj.HiddenWall));
2254+ map[i][j].push( THIEF.util.factory(THIEF.Data.Obj.LitFloor));
14182255 }
14192256 }
14202257 }
@@ -1423,7 +2260,6 @@
14232260 };
14242261
14252262 THIEF.util.spawn = function (obj) {
1426-
14272263 THIEF.html.addDebugMessage('湧き処理を開始...');
14282264
14292265 var monster = null;
@@ -1430,19 +2266,11 @@
14302266 THIEF.html.addDebugMessage('オブジェクトの複製');
14312267 if (typeof obj === 'undefined') {
14322268 // 条件に応じた対象を選択すること
1433- monster = Object.create(THIEF.type._life._humanoid.Daemon);
2269+ monster = THIEF.util.factory(THIEF.Data.Obj.DebugDaemon);
14342270 } else {
1435- monster = Object.create(obj);
2271+ monster = THIEF.util.factory(obj);
14362272 }
14372273
1438- // ???
1439- /*
1440- monster.inventoryDepth = 1;
1441- monster.inventoryHeight = 10;
1442- monster.inventoryWidth = 10;
1443- monster.inventoryCellSize = 1;
1444- */
1445-
14462274 // 空きスペースの検索条件
14472275 var point;
14482276 for (var i = 0; i < 10; i++) {
@@ -1462,7 +2290,6 @@
14622290 THIEF.global.actLV.addToInventory(monster, point.x, point.y);
14632291 THIEF.html.refreshXy(monster.x, monster.y);
14642292 THIEF.html.addDebugMessage('...湧き処理を完了')
1465-
14662293 };
14672294
14682295 THIEF.util.infixToRevP = function (val) {
@@ -1606,15 +2433,15 @@
16062433 return revP;
16072434 };
16082435
1609-THIEF.util.execRevP = function (array) {
2436+THIEF.util.execRevP = function (val) {
16102437 THIEF.html.addDebugMessage('逆ポーランド記法の数式を計算開始...');
16112438
16122439 var revP;
1613- if(typeof array === 'number'){
2440+ if(typeof val === 'number'){
16142441 revP = [];
1615- revP[0] = array;
2442+ revP[0] = val;
16162443 } else {
1617- revP = array.slice(0);
2444+ revP = val.slice(0);
16182445 }
16192446 var index=0;
16202447 THIEF.html.addDebugMessage('X = ' + revP);
@@ -1821,7 +2648,7 @@
18212648 help += '<table border=1>\n';
18222649 help += '<tr><th colspan=3>Command Help</th></tr>\n';
18232650 var com = [];
1824- for (var name in THIEF.type.$.manual) {
2651+ for (var name in THIEF.func.method.manual) {
18252652 com.push(name);
18262653 }
18272654 com.sort(function(a, b) {
@@ -1849,7 +2676,7 @@
18492676 return x - y;
18502677 });
18512678 for (var i = 0; i < com.length; i++) {
1852- help += '<tr><td>' + String.fromCharCode(com[i]) + '</td><td>' + THIEF.type.$.manual[com[i]].toString().slice(THIEF.type.$.manual[com[i]].toString().indexOf('this.') + 5, THIEF.type.$.manual[com[i]].toString().lastIndexOf('(')) + '</td></tr>\n';
2679+ help += '<tr><td>' + String.fromCharCode(com[i]) + '</td><td>' + THIEF.func.method.manual[com[i]].toString().slice(THIEF.func.method.manual[com[i]].toString().indexOf('this.') + 5, THIEF.func.method.manual[com[i]].toString().lastIndexOf('(')) + '</td></tr>\n';
18532680 }
18542681 help += '</table>\n';
18552682 document.getElementById(THIEF.conf.id + 'Footer').innerHTML = help;
@@ -2011,18 +2838,19 @@
20112838 ※ スポーンの対象にならない・一覧に表示されない、など
20122839
20132840 Date.Obj 配下に格納されるオブジェクトは、
2014-自動的に THIEF.command 内のメソッドを継承し、その対象になります。
2841+自動的に THIEF.func.command 内のメソッドを継承し、その対象になります。
20152842 その為、すべてのオブジェクトが eat や wear メソッドの対象になります。
20162843 ※ 各コマンド名に -able をつけたプロパティ (eatable, wearable) の
20172844 Boolean値 (true/false) に応じて動作します。
20182845
2019-オブジェクト内に super プロパティがあると、
2846+オブジェクト内に inheritance プロパティがあると、
20202847 そのオブジェクトも継承します。
2021-super は文字列で指定してください。
2022- ※ super : 'Human'
2848+inheritance は文字列で指定してください。
2849+ ※ inheritance : 'Human'
2850+何もない場合は、Date.Obj.$を継承します。
20232851
20242852 プロパティは以下の順番で参照されます。
2025- ※ Object -> THIEF.command -> Date.Human -> this
2853+ ※ Object -> THIEF.func.command -> Date.Obj.$ -> Date.Obj.Human -> this
20262854
20272855 現段階では、多段的な階層はサポートしていません。
20282856 今後もするつもりはありません。
@@ -2039,11 +2867,9 @@
20392867
20402868 */
20412869
2870+
20422871 THIEF.Data = {};
20432872 THIEF.Data.Obj = {}; // Monster & Item
2044-THIEF.Data.Event = {}; // Event & Scenario
2045-THIEF.Data.Text = {}; //
2046-
20472873 THIEF.Data.Obj.$ = { // Default
20482874 name : {
20492875 ja : '無名',
@@ -2053,852 +2879,150 @@
20532879 symbolName : {
20542880 ja : '不明',
20552881 en : 'Unknown'
2882+ },
2883+ displayName : function() {
2884+ return this.get(THIEF.PARAM.name) + '(<span style="color:' + this.get(THIEF.PARAM.color) + '">' + this.get(THIEF.PARAM.symbol) + '</span>)';
20562885 }
20572886 };
20582887
2888+
20592889 THIEF.Data.Obj.$Monster = {
2060- active : true
2890+ active : true,
2891+ ct : 0
20612892 };
20622893
20632894 THIEF.Data.Obj.$Item = {
20642895 stackable : true,
20652896 mergeable : true,
2066- portable : true
2897+ portable : true,
2898+ isItem : true,
2899+ wieldable : true
20672900 };
20682901
2069-THIEF.type = {};
2070-THIEF.type.$ = Object.create(THIEF.command);
2071-THIEF.type.$.active = false; // turn
2072-THIEF.type.$.name = 'Nameless';
2073-THIEF.type.$.displayName = function() {
2074- return this.get(THIEF.PARAM.name) + '(<span style="color:' + this.get(THIEF.PARAM.color) + '">' + this.get(THIEF.PARAM.symbol) + '</span>)'
2902+THIEF.Data.Obj.$Level = {
2903+ active : false
20752904 };
2076-//THIEF.type.$.territory = false; // 自分と同じインベントリセルに対する侵入を拒むか
2077-THIEF.type.$.symbol = '&#x2573;'; // 未登録用印(X に近い)
2078-THIEF.type.$.color = undefined;
2079-THIEF.type.$.decayable = false;
2080-THIEF.type.$.portable = false;
2081-THIEF.type.$.mergeable = false;
2082-THIEF.type.$.stackable = false; // インベントリ内で同じものが重ねられるか
2083-THIEF.type.$.ct = 0;
20842905
2085-THIEF.type.$.get = function (param) {
2086-
2087- var val;
2088-
2089- if (typeof this[param] === 'function') {
2090- val = this[param]();
2091-
2092- } else if (this[param]) {
2093- if (this[param][THIEF.conf.language]) {
2094- val = this[param][THIEF.conf.language];
2095- } else {
2096- val = this[param];
2097- for (var i = 0; i < THIEF.conf.languagePriolity.length; i++) {
2098- if (this[param][THIEF.conf.languagePriolity[i]]) {
2099- val = this[param][THIEF.conf.languagePriolity[i]];
2100- break;
2101- }
2102- }
2103- }
2104- }
2105-
2106- return val;
2906+THIEF.Data.Obj.$Humanoid = {
2907+ inheritance : '$Monster',
2908+ symbol : '@'
21072909 };
21082910
2109-THIEF.type.$.set = function (param, val) {
2110- this[param] = val;
2911+THIEF.Data.Obj.Human = {
2912+ inheritance : '$Humanoid',
2913+ color : 'red'
21112914 };
21122915
2113-THIEF.type.$.removeFromInventory = function(obj) {
2114- var objX = obj.x;
2115- var objY = obj.y;
2116- THIEF.html.addDebugMessage(obj.get(THIEF.PARAM.displayName) + 'を' + this.get(THIEF.PARAM.displayName) + 'のインベントリ座標[' + obj.x + ', ' + obj.y + ']から除外...');
2117- var shapeX = Math.ceil(obj.get(THIEF.PARAM.shapeWidth) / this.get(THIEF.PARAM.inventoryCellSize)) || 1;
2118- var shapeY = Math.ceil(obj.get(THIEF.PARAM.shapeHeight) / this.get(THIEF.PARAM.inventoryCellSize)) || 1;
2119-
2120- if (obj.myOwner === this) {
2121- obj.myOwner = null;
2122- obj.x = undefined;
2123- obj.y = undefined;
2124- for (var i = 0; i < shapeX; i++) {
2125- for (var j = 0; j < shapeY; j++) {
2126- THIEF.html.addDebugMessage('座標[' + (objX + i) + ', ' + (objY + j) + ']から除外');
2127- this.inventory[objX + i][objY + j].remove(obj);
2128- THIEF.html.refreshXy(objX + i, objY + j);
2129- }
2130- }
2131- }
2132- THIEF.html.addDebugMessage('...' + obj.get(THIEF.PARAM.displayName) + 'を' + this.get(THIEF.PARAM.displayName) + 'のインベントリ座標[' + objX + ', ' + objY + ']から除外完了。');
2133-
2134- return true;
2916+THIEF.Data.Obj.$Daemon = {
2917+ inheritance : '$Humanoid',
2918+ symbol : '&amp;'
21352919 };
21362920
2137-
2138-THIEF.type.$.addToInventory = function(obj, x, y) {
2139-
2140- var result = false;
2141-
2142- THIEF.html.addDebugMessage(obj.get(THIEF.PARAM.displayName) + 'を' + this.get(THIEF.PARAM.displayName) + 'のインベントリ座標[' + x + ', ' + y + ']に追加処理を開始...');
2143-
2144- var target = this.getInventoryFreeSpace(obj, x, y);
2145- if (target.x >= 0 && target.y >= 0) {
2146- obj.x = target.x;
2147- obj.y = target.y;
2148- obj.myOwner = this;
2149- THIEF.html.addDebugMessage(target.x + ', ' + target.y + 'を基準に ' + target.width + 'x' + target.len + ' のサイズとして追加');
2150- for (var i = target.x; i < target.x + target.width; i++) {
2151- for (var j = target.y; j < target.y + target.len; j++) {
2152-
2153- if (!this.inventory) {
2154- this.inventory = [];
2155- }
2156-
2157- if (!this.inventory[i]) {
2158- this.inventory[i] = [];
2159- }
2160-
2161- if (!this.inventory[i][j]) {
2162- this.inventory[i][j] = [];
2163- }
2164-
2165- // Item の場合のみアルファベットを設定
2166- if(obj.isItem){
2167- THIEF.html.addDebugMessage(obj.get(THIEF.PARAM.displayName) + ' はアイテムなので、アルファベットの割り当てを行う...');
2168- var alphabets = this.getInventoryAlphabets();
2169- if (typeof obj.get(THIEF.PARAM.alphabet) === 'string' && alphabets.indexOf(obj.get(THIEF.PARAM.alphabet)) === -1) {
2170- // すでにアルファベットが登録済みで、かつ変更の必要は無い
2171- THIEF.html.addDebugMessage('すでに割りあたっているもの' + obj.get(THIEF.PARAM.alphabet) + 'が再利用可能。');
2172- } else {
2173- var alp = this.getInventoryNonExistAlphabet();
2174- if (typeof alp === 'undefined') {
2175- alert('アルファベット関係の使用制限バグ');
2176- } else {
2177- obj.set(THIEF.PARAM.alphabet, alp);
2178- }
2179- THIEF.html.addDebugMessage('新たに ' + alp + ' を割り当てた。')
2180- }
2181- THIEF.html.addDebugMessage('...アルファベットの割り当て処理完了。');
2182- }
2183-
2184- this.inventory[i][j].push(obj);
2185- THIEF.html.addDebugMessage('[' + i + ', ' + j + ']に' + obj.get(THIEF.PARAM.alphabet) + 'として追加');
2186- result = true;
2187- }
2188- }
2189- } else {
2190- THIEF.html.addDebugMessage('追加可能なスペースがない。');
2191- }
2192-
2193- THIEF.html.addDebugMessage('...' + obj.get(THIEF.PARAM.displayName) + 'を' + this.get(THIEF.PARAM.displayName) + 'のインベントリ座標[' + x + ', ' + y + ']に追加処理を完了。(return : ' + result + ')');
2194-
2195- return result;
2921+THIEF.Data.Obj.DebugDaemon = {
2922+ inheritance : '$Daemon',
2923+ color : '#00FF88',
2924+ name : {
2925+ ja : 'デバッグ用モンスター',
2926+ en : 'DebugMonster'
2927+ },
2928+ hp : 10,
2929+ damage : '1d3'
21962930 };
21972931
2198-THIEF.type.$.getInventoryFreeSpace = function(obj, _x, _y) {
2199-
2200- var invCellSize = this.get(THIEF.PARAM.inventoryCellSize) || 10;
2201- var invWidth = this.get(THIEF.PARAM.inventoryWidth) || 0;
2202- var invHeight = this.get(THIEF.PARAM.inventoryHeight) || 0;
2203- var invDepth = this.get(THIEF.PARAM.inventoryDepth) || 0;
2204- var objShapeWight = obj.get(THIEF.PARAM.shapeWidth) || Math.ceil(obj.get(THIEF.PARAM.siz) / 4) || 1;
2205- var objShapeHeight = obj.get(THIEF.PARAM.shapeHeight) || Math.ceil(obj.get(THIEF.PARAM.siz) / 4) || 1;
2206- var objInvShapeWight = Math.ceil(objShapeWight / invCellSize);
2207- var objInvShapeHeight = Math.ceil(objShapeHeight / invCellSize);
2208-
2209- var resultAnc = {};
2210-
2211- var startX = _x || 0;
2212- var startY = _y || 0;
2213- var once = (typeof _x === "number" || typeof _y === "number");
2214-
2215- THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + 'のインベントリ(' + invHeight + ', ' + invWidth + ', ' + invDepth + ')の座標[' + _x + ', ' + _y + ']に' + obj.get(THIEF.PARAM.displayName) + '(' + objInvShapeWight + ', ' + objInvShapeHeight + ')として格納できるか確認を開始...');
2216-
2217- var free;
2218-
2219- outloop : for (var ancY = startY; ancY < invHeight; ancY++) {
2220- //alert(ancY + '行目を処理...');
2221- for (var ancX = startX; ancX < invWidth; ancX++) {
2222- //alert(ancX + ', ' + ancY);
2223- free = true;
2224-
2225- //THIEF.html.addDebugMessage(ancX + ', ' + ancY + 'を確認...');
2226-
2227- inloop : for (var targetY = ancY; targetY < ancY + objInvShapeHeight; targetY++) {
2228- for (var targetX = ancX + objInvShapeWight - 1; targetX >= ancX; targetX--) {
2229- if (this.inventory && this.inventory[targetX] && this.inventory[targetX][targetY]) {
2230- if (this.inventory[targetX][targetY].length <= invDepth) {
2231- var lastObj = this.inventory[targetX][targetY].getLast();
2232- if (obj.get(THIEF.PARAM.stackable) || typeof lastObj === 'undefined' || lastObj.get(THIEF.PARAM.stackable) /* || !lastObj.get(THIEF.PARAM.mergeable) */) {
2233- if (lastObj) {
2234- THIEF.html.addDebugMessage('[' + targetX + ', ' + targetY + ']にある' + lastObj.get(THIEF.PARAM.displayName) + 'には重ねられる。');
2235- } else {
2236- THIEF.html.addDebugMessage('[' + targetX + ', ' + targetY + ']には何も無いので重ねられる。');
2237- }
2238- } else {
2239- free = false;
2240- ancX = targetX;
2241- //THIEF.html.addDebugMessage(targetX + ', ' + targetY + 'にある' + lastObj.get(THIEF.PARAM.name) + 'には重ねられない');
2242- break inloop;
2243- }
2244- } else {
2245- free = false;
2246- ancX = targetX;
2247- //THIEF.html.addDebugMessage(targetX + ', ' + targetY + ' は高さが足りないからダメ');
2248- break inloop;
2249- }
2250-
2251-
2252- } else {
2253- THIEF.html.addDebugMessage(targetX + ', ' + targetY + ' は空');
2254- }
2255- }
2256- }
2257-
2258- if (free) {
2259- resultAnc.x = ancX;
2260- resultAnc.y = ancY;
2261- resultAnc.width = objInvShapeWight;
2262- resultAnc.len = objInvShapeHeight;
2263- break outloop;
2264- }
2265- if (once) {
2266- break outloop;
2267- }
2268- }
2269- }
2270-
2271- THIEF.html.addDebugMessage('...' + obj.get(THIEF.PARAM.displayName) + '(' + objInvShapeWight + ', ' + objInvShapeHeight + ')として格納できるか確認を完了。');
2272-
2273- return resultAnc;
2932+THIEF.Data.Obj.$Floor = {
2933+ stackable : true
2934+ // diggable : true
22742935 };
22752936
2276-THIEF.type.$.attackedBy = function(obj) {
2277-
2278- THIEF.html.addDebugMessage(obj.get(THIEF.PARAM.displayName) + ' による ' + this.get(THIEF.PARAM.displayName) + ' への攻撃処理を開始...');
2279-
2280- //my.slot[THIEF.PARAM.slot.hand] = selected[0];
2281- var revP;
2282- if(typeof obj.slot === 'undefined' || typeof obj.slot[THIEF.PARAM.slot.hand] === 'undefined'){
2283- revP = 1;
2284- } else {
2285- var wep = obj.slot[THIEF.PARAM.slot.hand].damage;
2286- revP = THIEF.util.infixToRevP(wep);
2937+THIEF.Data.Obj.LitFloor = {
2938+ inheritance : '$Floor',
2939+ symbol : '.',
2940+ name : {
2941+ ja : '明るい床',
2942+ en : 'Lit Floor'
22872943 }
2288- var damage = THIEF.util.execRevP(revP);
2289-
2290- THIEF.html.addDebugMessage('ベースダメージを ' + damage + 'とする。');
2291-
2292- THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + ' HP : ' + this.get(THIEF.PARAM.hp) + ' -> ' + (this.get(THIEF.PARAM.hp) - damage) + 'とする。');
2293- this.hp -= damage;
2294- THIEF.TEXT.$(THIEF.TEXT.attack, damage, this.get(THIEF.PARAM.displayName), obj.get(THIEF.PARAM.displayName) );
2295-
2296- obj.ct -= 100;
2297-
2298- if (this.get(THIEF.PARAM.hp) <= 0) {
2299- THIEF.html.addDebugMessage('死亡処理を開始...');
2300- THIEF.TEXT.$(THIEF.TEXT.killBy, this.get(THIEF.PARAM.displayName), obj.get(THIEF.PARAM.displayName));
2301- THIEF.global.actLV.removeFromInventory(this);
2302- this.next = function() {
2303- return true
2304- };
2305- THIEF.html.addDebugMessage('...死亡処理を完了。')
2306- }
2307-
2308- THIEF.html.addDebugMessage('...攻撃処理を完了。');
2309-
2310- return true;
23112944 };
23122945
2313-THIEF.type.$.addParam = function(param) {
2314- for (var name in param) {
2315- if (typeof this[name] === 'undefined' || typeof this[name] === 'null') {
2316- this[name] = param[name];
2317- } else {
2318- this[name] += param[name];
2319- }
2946+THIEF.Data.Obj.DarkFloor = {
2947+ inheritance : '$Floor',
2948+ symbol : '#',
2949+ name : {
2950+ ja : '暗い床',
2951+ en : 'Dark Floor'
23202952 }
23212953 };
23222954
2323-
2324-THIEF.type.$.getInventoryObjects = function(request) {
2325- var array = [];
2326-
2327- // 必ずしも inventory の配列を完全に持っているとは限らないので注意すること
2328- if (!!this.inventory) {
2329- for (var i = this.inventory.length; i >= 0; i--) {
2330- for (var j = this.inventory[i].length; j >= 0; j--) {
2331- for (var k = this.inventory[i][j].length; k >= 0; k--) {
2332- var item = this.inventory[i][j][k];
2333- if (item.checkParam(request)) {
2334- array.push(item);
2335- }
2336- }
2337- }
2338- }
2339- }
2340- return array;
2955+THIEF.Data.Obj.$Wall = {
2956+ symbol : '&#x2593;' // 濃いドット模様
2957+ //diggable : true
23412958 };
23422959
2343-THIEF.type.$.getInventoryXyLastObject = function(x, y) {
2344- var obj;
2345-
2346- // 必ずしも inventory の配列を完全に持っているとは限らないので注意すること
2347- if (this.inventory && this.inventory[x] && this.inventory[x][y]) {
2348- obj = this.inventory[x][y].getLast();
2349- }
2350- return obj;
2960+THIEF.Data.Obj.NonDiggableWall = {
2961+ inheritance : '$Wall',
2962+ symbol : '&#x2591;' // 薄いドット模様
23512963 };
23522964
2353-// ループ処理を加えること
2354-THIEF.type.$.getInventoryAlphabets = function() {
2355- var alphabets = [];
2356- if(this.inventory){
2357- for(var i=0; i<this.get(THIEF.PARAM.inventoryWidth); i++){
2358- if(this.inventory[i]){
2359- for(var j=0; j<this.get(THIEF.PARAM.inventoryHeight); j++){
2360- if(this.inventory[i][j]){
2361- for(var k=0; k<this.inventory[i][j].length; k++){
2362- var alphabet = this.inventory[i][j][k].get(THIEF.PARAM.alphabet);
2363- if(alphabet){
2364- alphabets.push(alphabet);
2365- }
2366- }
2367- }
2368- }
2369- }
2370- }
2371- }
2372-
2373- return alphabets;
2965+THIEF.Data.Obj.NormalWall = {
2966+ inheritance : '$Wall',
2967+ symbol : '+'
23742968 };
23752969
2376-THIEF.type.$.getInventoryNonExistAlphabet = function() {
2377- // 常にアルファベットの先頭が利用されないようにしている
2378- var key = THIEF.KEY;
2379- var index = key.a;
2380- return function() {
2381- var alphabets = this.getInventoryAlphabets();
2382-
2383- var counter = 0;
2384- while (alphabets.indexOf(String.fromCharCode(index)) !== -1 && counter < 52) {
2385- counter++;
2386- index++;
2387- if (index === (key.z + 1)) {
2388- index = key.A;
2389- } else {
2390- if (index === (key.Z + 1)) {
2391- index = key.a;
2392- }
2393- }
2394- }
2395-
2396- var alphabet;
2397- if (counter < 52) {
2398- alphabet = String.fromCharCode(index);
2399- index++;
2400- }
2401-
2402- return alphabet;
2403- };
2404-
2405-}();
2406-
2407-
2408-THIEF.type.$.checkParam = function(request) {
2409-
2410- var result = true;
2411- for (var name in request) {
2412- if (typeof name !== 'function') {
2413- if (this[name] !== request[name]) {
2414- result = false;
2415- break;
2416- }
2417- }
2418- }
2419- return result;
2970+THIEF.Data.Obj.HiddenWall = {
2971+ inheritance : '$Wall',
2972+ symbol : '&nbsp;'
24202973 };
24212974
2422-// items 配列を渡してカリー化(?)
2423-THIEF.type.$.selecter = function(objs, exec, immediately, abc) {
2424-
2425- var key = THIEF.KEY;
2426- var items = [];
2427- var selected = [];
2428- var targets = [];
2429- var i, j;
2430-
2431- THIEF.html.addDebugMessage('セレクターを生成');
2432- for (i = 0; i < objs.length; i++) {
2433- THIEF.html.addDebugMessage('セレクターターゲット:' + objs[i].get(THIEF.PARAM.displayName));
2434- if (objs[i] !== this && objs[i].portable && objs[i].get(THIEF.PARAM.displayName)) {
2435- items.push(objs[i]);
2436- }
2437- }
2438-
2439- // root_abc
2440- var alphabetIndex = key.a;
2441-
2442- // アイテム出力
2443- for (i = 0; i < THIEF.conf.itemSort.length; i++) {
2444-
2445- //アイテムがあるか確認
2446- var first = true;
2447- for (j = 0; j < items.length; j++) {
2448- if (THIEF.conf.itemSort[i] === items[j].symbol) {
2449- if (first) {
2450- first = false;
2451- THIEF.html.addInfomation('<span style="color:' + THIEF.conf.bgColor + '; background:' + THIEF.conf.textColor + '">' + items[j].get(THIEF.PARAM.symbolName) + '</span>');
2452- }
2453-
2454- var alphabet;
2455- if (abc) {
2456- alphabet = String.fromCharCode(alphabetIndex);
2457- alphabetIndex++;
2458- } else {
2459- alphabet = items[j].alphabet || this.getInventoryNonExistAlphabet();
2460- if (alphabet === null) {
2461- // ページ切り替え
2462- break;
2463- }
2464- items[j].alphabet = alphabet;
2465- }
2466-
2467- THIEF.html.addInfomation(alphabet + '<span id="' + THIEF.conf.id + '_' + alphabet + '">&nbsp;-&nbsp;</span>' + items[j].get(THIEF.PARAM.displayName));
2468- targets[alphabet] = items[j];
2469- }
2470- }
2471- }
2472-
2473- // 選択用関数返却
2474- return function() {
2475- var finish = false;
2476- switch (THIEF.global.keycode) {
2477-
2478- case '*'.charCodeAt(0):
2479-
2480- break;
2481-
2482- case key.Esc:
2483- finish = true;
2484- selected.length = 0;
2485- break;
2486-
2487- case key.Space:
2488- break;
2489-
2490- case key.Enter:
2491- finish = true;
2492- this.action = THIEF.type.$.action;
2493- break;
2494-
2495- // すべてを選択しない
2496- case key.Minus:
2497- if(immediately) {
2498- selected.push(undefined);
2499- finish = true;
2500- } else {
2501- selected.length = 0;
2502- for(var i=0; i<targets.length; i++){
2503- // TODO
2504- // 表示を初期化すること
2505- }
2506- }
2507- break;
2508-
2509- default:
2510- var item = targets[String.fromCharCode(THIEF.global.keycode)];
2511- var itemID = THIEF.conf.id + '_' + String.fromCharCode(THIEF.global.keycode);
2512- if (typeof item !== 'undefined') {
2513- if (document.getElementById(itemID).innerHTML === '&nbsp;-&nbsp;') {
2514- document.getElementById(itemID).innerHTML = '&nbsp;+&nbsp;';
2515- selected.push(item);
2516- } else {
2517- document.getElementById(itemID).innerHTML = '&nbsp;-&nbsp;';
2518- selected.remove(item);
2519- }
2520- }
2521- if (immediately) {
2522- finish = true;
2523- }
2524-
2525- break;
2526- }
2527-
2528- var result = false;
2529- if (finish) {
2530- // 画面クリア
2531- THIEF.html.clearInfomation('');
2532-
2533- // アクションを元に戻す
2534- this.action = THIEF.type.$.action;
2535-
2536- // 選択後のアクションを実行
2537- result = exec(selected);
2538-
2539- }
2540-
2541- return result;
2542- };
2543-
2975+THIEF.Data.Obj.Door = {
2976+ inheritance : '$Wall',
2977+ symbol : '+',
2978+ color : 'burlywood'
25442979 };
25452980
2546-THIEF.type.$.cpu = function() {
2547-
2548- THIEF.html.addDebugMessage('CPU行動開始...');
2549-
2550- var dx = 0;
2551- var dy = 0;
2552- var diffX = THIEF.global.adventurer.x - this.x;
2553- var diffY = THIEF.global.adventurer.y - this.y;
2554-
2555- /*
2556- var rad = ((Math.atan2(diffY, diffX) * 180.0 / Math.PI) + 360.0) % 360.0;
2557-
2558- if (typeof rad !== 'number') {
2559-
2560- } else {
2561- if (337.5 < rad || (0 <= rad && rad < 22.5)) {
2562- dx = 1;
2563- dy = 0;
2564- } else if (22.5 <= rad && rad <= 67.5) {
2565- dx = 1;
2566- dy = 1;
2567- } else if (67.5 < rad && rad < 112.5) {
2568- dx = 0;
2569- dy = 1;
2570- } else if (112.5 <= rad && rad <= 157.5) {
2571- dx = -1;
2572- dy = 1;
2573- } else if (157.5 < rad && rad < 202.5) {
2574- dx = -1;
2575- dy = 0;
2576- } else if (202.5 <= rad && rad <= 247.5) {
2577- dx = -1;
2578- dy = -1;
2579- } else if (247.5 < rad && rad < 292.5) {
2580- dx = 0;
2581- dy = -1;
2582- } else if (292.5 <= rad && rad <= 337.5) {
2583- dx = 1;
2584- dy = -1;
2585- }
2586- }
2587- */
2588-
2589-
2590- if (diffX > 0) {
2591- dx = 1;
2592- } else if (diffX < 0) {
2593- dx = -1;
2981+THIEF.Data.Obj.$Food = {
2982+ inheritance : '$Item',
2983+ symbol : '%',
2984+ symbolName : {
2985+ ja : '食料',
2986+ en : 'Food'
25942987 }
2595-
2596- if (diffY > 0) {
2597- dy = 1;
2598- } else if (diffY < 0) {
2599- dy = -1;
2600- }
2601-
2602-
2603- this.move(dx, dy);
2604-
2605- THIEF.html.addDebugMessage('...CPU行動完了');
2606-
2607- return true;
26082988 };
26092989
2610-THIEF.type.$.move = function(dx, dy) {
2611-
2612- THIEF.html.addDebugMessage('移動処理 move(' + dx + ', ' + dy + ') を開始...');
2613-
2614- THIEF.html.addDebugMessage(THIEF.global.actLV.get(THIEF.PARAM.displayName) + 'のインベントリ座標[' + (this.x + dx) + ', ' + (this.y + dy) + ']を調査を行う。');
2615- var target = THIEF.global.actLV.getInventoryXyLastObject(this.x + dx, this.y + dy);
2616-
2617- if (this.get(THIEF.PARAM.stackable) || target.get(THIEF.PARAM.stackable)) {
2618- var sX = this.x;
2619- var sY = this.y;
2620-
2621- THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + '[' + this.x + ', ' + this.y + ']は' + target.get(THIEF.PARAM.displayName) + '[' + (this.x + dx) + ', ' + (this.y + dy) + ']の上に移動する。');
2622- THIEF.global.actLV.removeFromInventory(this);
2623-
2624- THIEF.html.addDebugMessage('移動前の座標[' + sX + ', ' + sY + ']の描画を更新');
2625- THIEF.html.refreshXy(sX, sY);
2626-
2627- this.x = sX + dx;
2628- this.y = sY + dy;
2629- THIEF.global.actLV.addToInventory(this, this.x, this.y);
2630-
2631- THIEF.html.addDebugMessage('移動後の座標[' + this.x + ', ' + this.y + ']の描画を更新');
2632- THIEF.html.refreshXy(this.x, this.y);
2633-
2634- this.ct -= 60;
2635-
2636- } else {
2637- if (target.get(THIEF.PARAM.active)) {
2638- THIEF.html.addDebugMessage('active なものが対象なので攻撃してみる。');
2639- target.attackedBy(this);
2640- } else {
2641- THIEF.html.addDebugMessage('インベントリ座標[' + (this.x + dx) + ', ' + (this.y + dy) + '] には移動できない。');
2642- }
2643- }
2644-
2645- THIEF.html.addDebugMessage('...移動処理を完了。');
2646-
2647- return true;
2990+THIEF.Data.Obj.$Corpse = {
2991+ inheritance : '$Food',
2992+ decayable : true,
2993+ next : THIEF.func.method.decay,
2994+ dp : 20
26482995 };
26492996
2650-THIEF.type.$.inputWait = function () {
2651- this.next = THIEF.type.$.manual;
2652- THIEF.html.addDebugMessage('入力待ち');
2653- return false;
2997+THIEF.Data.Obj.Ration = {
2998+ inheritance : '$Food',
2999+ name : {
3000+ ja : '食料',
3001+ en : 'Ration'
3002+ },
3003+ color : 'red'
26543004 };
26553005
2656-THIEF.type.$.manual = function() {
2657-
2658- var finish = true;
2659- var code = THIEF.global.keycode;
2660-
2661- if (code === 0) {
2662- finish = false;
2663- THIEF.html.addDebugMessage('無効なキー入力のため、何の処理もしない。')
2664- } else {
2665- THIEF.global.keycode = 0;
2666- THIEF.html.addDebugMessage(String.fromCharCode(code) + '(' + code + ')の入力に対する処理を開始...');
2667- if (typeof THIEF.type.$.manual[code] === 'function') {
2668- THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + ' の ' + THIEF.type.$.manual[code] + 'を実行');
2669- finish = THIEF.type.$.manual[code].apply(this);
2670- } else {
2671- finish = false;
2672- }
2673-
2674- if (typeof finish === 'undefined') {
2675- finish = false;
2676- }
2677- THIEF.html.addDebugMessage('...' + String.fromCharCode(code) + '(' + code + ')の入力に対する処理を完了。(return : ' + finish + ')');
2678-
2679- if (finish) {
2680- this.next = THIEF.type.$.inputWait;
2681- }
3006+THIEF.Data.Obj.$Weapon = {
3007+ inheritance : '$Item',
3008+ symbol : ']',
3009+ symbolName : {
3010+ ja : '武器',
3011+ en : 'Weapn'
26823012 }
2683-
2684- return finish;
26853013 };
26863014
2687-// 束縛しないように関数化している
2688-THIEF.type.$.manual['h'.charCodeAt(0)] = function() { return this.goLeft(); };
2689-THIEF.type.$.manual['k'.charCodeAt(0)] = function() { return this.goUp(); };
2690-THIEF.type.$.manual['j'.charCodeAt(0)] = function() { return this.goDown(); };
2691-THIEF.type.$.manual['l'.charCodeAt(0)] = function() { return this.goRight(); };
2692-THIEF.type.$.manual['y'.charCodeAt(0)] = function() { return this.goUpperLeft(); };
2693-THIEF.type.$.manual['u'.charCodeAt(0)] = function() { return this.goUpperRight(); };
2694-THIEF.type.$.manual['b'.charCodeAt(0)] = function() { return this.goLowerLeft(); };
2695-THIEF.type.$.manual['n'.charCodeAt(0)] = function() { return this.goLowerRight(); };
2696-THIEF.type.$.manual['R'.charCodeAt(0)] = function() { return this.refreshHTML(); };
2697-THIEF.type.$.manual[','.charCodeAt(0)] = function() { return this.pickup(); };
2698-THIEF.type.$.manual['d'.charCodeAt(0)] = function() { return this.drop(); };
2699-/*
2700- THIEF.type.$.manual['i'.charCodeAt(0)] = function() {
2701- return this.showInventory();
2702- };
2703- */
2704-THIEF.type.$.manual['p'.charCodeAt(0)] = function() { return this.history(); };
2705-THIEF.type.$.manual['s'.charCodeAt(0)] = function() { return this.rest(); };
2706-THIEF.type.$.manual['w'.charCodeAt(0)] = function() { return this.wield(); };
2707-THIEF.type.$.manual['.'.charCodeAt(0)] = function() { return this.rest(); };
2708-THIEF.type.$.manual['#'.charCodeAt(0)] = function() { return this.extendedCommand(); };
2709-THIEF.type.$.next = function() {
2710- return this.cpu();
2711-}; // 基本は CPU
2712-
2713-
2714-THIEF.type.$.notify = function() {
2715-
2716- if (typeof this.inventory !== "undefined") {
2717- var width = this.get(THIEF.PARAM.inventoryWidth);
2718- for (var x = 0; x < width; x++) {
2719- if (typeof this.inventory[x] === "undefined") {
2720- break;
2721- }
2722- var length = this.get(THIEF.PARAM.inventoryHeight);
2723- for (var y = 0; y < length; y++) {
2724- if (typeof this.inventory[x][y] === "undefined") {
2725- break;
2726- }
2727- var height = this.inventory[x][y].length;
2728- for (var h = 0; h < height; h++) {
2729- this.inventory[x][y][h].notify();
2730- }
2731- }
2732- }
2733- }
2734-
2735- // CT を増加
2736- if (this.get(THIEF.PARAM.active)) {
2737- if (typeof this.get(THIEF.PARAM.dex) === undefined) {
2738- this[THIEF.PARAM.ct] += this.get(THIEF.PARAM.dex);
2739- } else {
2740- this[THIEF.PARAM.ct] += 26; // test
2741- }
2742- THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + ' の CT を ' + this[THIEF.PARAM.ct] + ' に増加。');
2743- }
2744-
2745- // ct が 100 を超えていたら行動対象に登録
2746- if (this.get(THIEF.PARAM.ct) >= 100) {
2747- if (typeof this[THIEF.PARAM.myOwner][THIEF.PARAM.actObjectList] === "undefined") {
2748- this[THIEF.PARAM.myOwner][THIEF.PARAM.actObjectList] = [];
2749- }
2750- THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + ' を、オーナ:' + this[THIEF.PARAM.myOwner].get(THIEF.PARAM.displayName) + ' に登録。');
2751- this[THIEF.PARAM.myOwner][THIEF.PARAM.actObjectList].push(this);
2752- }
3015+THIEF.Data.Obj.DebugDagger = {
3016+ inheritance : '$Weapon',
3017+ name : {
3018+ ja : 'テスト用ダガー',
3019+ en : 'DebuggingDagger'
3020+ },
3021+ damage : '2d4',
3022+ color : 'silver'
27533023 };
27543024
2755-THIEF.type.$.action = function() {
27563025
2757- THIEF.html.addDebugMessage(this.get(THIEF.PARAM.displayName) + ' の行動を開始...');
2758-
2759- if (typeof this[THIEF.PARAM.actObjectList] !== 'undefined') {
2760-
2761- // ct の小さい順にソートする
2762- for (var i = 0; i < this[THIEF.PARAM.actObjectList].length - 2; i++) {
2763- var isSorted = true;
2764- for (var j = this[THIEF.PARAM.actObjectList].length - 1; j >= (1 + i); j--) {
2765- if (this[THIEF.PARAM.actObjectList][j].get(THIEF.PARAM.ct) < this[THIEF.PARAM.actObjectList][j - 1].get(THIEF.PARAM.ct)) {
2766- var swap = this[THIEF.PARAM.actObjectList][j];
2767- this[THIEF.PARAM.actObjectList][j] = this[THIEF.PARAM.actObjectList][j - 1];
2768- this[THIEF.PARAM.actObjectList][j - 1] = swap;
2769- isSorted = false;
2770- }
2771- }
2772- if (isSorted) {
2773- break;
2774- }
2775- }
2776-
2777- // ct の大きい順(配列の最後部)から実行
2778- var obj = this[THIEF.PARAM.actObjectList].pop();
2779- for (; typeof obj !== 'undefined'; obj = this[THIEF.PARAM.actObjectList].pop()) {
2780- THIEF.html.addDebugMessage(obj.get(THIEF.PARAM.displayName) + ' の処理を開始...');
2781- if (obj.action() === false) {
2782- // 行動が完了しない場合、現在のオブジェクトを再登録して一時停止(結果的に入力を待つ)
2783- THIEF.html.addDebugMessage('...' + obj.get(THIEF.PARAM.displayName) + ' は処理が完了しなかった。');
2784- this[THIEF.PARAM.actObjectList].push(obj);
2785-
2786- break;
2787- }
2788- THIEF.html.addDebugMessage('...処理を完了');
2789- }
2790- }
2791-
2792- var result = true;
2793- if (typeof this[THIEF.PARAM.actObjectList] === 'undefined' || this[THIEF.PARAM.actObjectList].length === 0) {
2794- if (this.active && this.turnEnd !== THIEF.global.turn) {
2795-
2796- if (this.get(THIEF.PARAM.ct) >= 100) {
2797- if (this.next()) {
2798- this.turnEnd = THIEF.global.turn;
2799- //this[THIEF.PARAM.ct] -= 100;
2800- result = true;
2801- } else {
2802- result = false;
2803- }
2804- }
2805- }
2806- } else if (this[THIEF.PARAM.actObjectList].length > 0) {
2807- result = false;
2808- }
2809-
2810- THIEF.html.addDebugMessage('... ' + this.get(THIEF.PARAM.displayName) + ' の行動を完了。 (result = ' + result + ')');
2811-
2812- return result;
2813-};
2814-
2815-THIEF.type.$.decay = function() {
2816-
2817- if (this.decayable) {
2818- this.dp--;
2819- if (this.dp <= 0) {
2820- THIEF.TEXT.$(THIEF.TEXT.decay, this.name);
2821- THIEF.global.actLV.delObject(this);
2822- }
2823- }
2824-
2825- return true;
2826-};
2827-
2828-THIEF.type._life = Object.create(THIEF.type.$);
2829-THIEF.type._life.active = true;
2830-THIEF.type._life.stackable = false; // on map
2831-
2832-THIEF.type._life._humanoid = Object.create(THIEF.type._life);
2833-THIEF.type._life._humanoid.symbol = 'h';
2834-
2835-THIEF.type.Level = Object.create(THIEF.type.$);
2836-
2837-THIEF.type.Level.getXyObjects = function(x, y) {
2838- return this.inventory[x][y];
2839-};
2840-
2841-THIEF.type.Level.delObject = function(o) {
2842- this.delXyObject(o.x, o.y, o);
2843-};
2844-
2845-THIEF.type.Level.delXyObject = function(x, y, o) {
2846- this.inventory[x][y].remove(o);
2847- if (this.mapRefreshPointList) {
2848- this.mapRefreshPointList.push({
2849- x: x,
2850- y: y
2851- });
2852- }
2853-};
2854-
2855-THIEF.type._item = Object.create(THIEF.type.$);
2856-THIEF.type._item.isItem = true;
2857-THIEF.type._item.decayable = false;
2858-THIEF.type._item.stackable = true;
2859-THIEF.type._item.portable = true;
2860-
2861-// '&#x2573;'; // 未登録用印(X に近い)
2862-// '&#x2591;'; // 薄いドット模様
2863-// '&#x2591;'; // 濃いドット模様
2864-THIEF.type.Floor = Object.create(THIEF.type.$);
2865-THIEF.type.Floor.symbol = '&#x2573;'; // 未登録用印(X に近い)
2866-THIEF.type.Floor.active = false;
2867-THIEF.type.Floor.stackable = true; // on map
2868-
2869-THIEF.type.Floor.Lit = Object.create(THIEF.type.Floor);
2870-THIEF.type.Floor.Lit.symbol = '.';
2871-THIEF.type.Floor.Lit.name = {
2872- ja : '明るい床',
2873- en : 'Lit Floor'
2874-};
2875-
2876-THIEF.type.Floor.Dark = Object.create(THIEF.type.Floor);
2877-THIEF.type.Floor.Dark.symbol = '#';
2878-THIEF.type.Floor.Dark.name = {
2879- ja : '暗い床',
2880- en : 'Dark Floor'
2881-};
2882-
2883-THIEF.type.Wall = Object.create(THIEF.type.$);
2884-THIEF.type.Wall.symbol = '&#x2591;'; // 薄いドット模様
2885-THIEF.type.Wall.active = false;
2886-THIEF.type.Wall.stackable = false; // on map
2887-
2888-THIEF.type.Wall.NonDiggable = Object.create(THIEF.type.Wall);
2889-THIEF.type.Wall.NonDiggable.symbol = '&nbsp;';
2890-
2891-THIEF.type.Wall.Normal = Object.create(THIEF.type.Wall);
2892-THIEF.type.Wall.Normal.symbol = '+';
2893-
2894-THIEF.type.Wall.Hidden = Object.create(THIEF.type.Wall);
2895-THIEF.type.Wall.Hidden.symbol = '&nbsp;';
2896-// THIEF.type.WALL.Hidden.symbol = '&#x2591;' // 薄いドット模様
2897-
2898-THIEF.type.Wall.Door = Object.create(THIEF.type.Wall);
2899-THIEF.type.Wall.Door.symbol = '+';
2900-THIEF.type.Wall.Door.color = 'burlywood';
2901-
29023026 /*
29033027 * Symbol Memo
29043028 *
@@ -2958,22 +3082,7 @@
29583082 * Y
29593083 * Z
29603084 * @ : human, Aventurier and sametype
2961- *
2962- */
2963-THIEF.type.Human = Object.create(THIEF.type._life._humanoid);
2964-THIEF.type.Human.symbol = '@';
2965-
2966-/*
29673085 * & : Daemon
2968- */
2969-THIEF.type._life._humanoid.Daemon = Object.create(THIEF.type.Human);
2970-THIEF.type._life._humanoid.Daemon.symbol = '&amp;';
2971-THIEF.type._life._humanoid.Daemon.color = '#00FF88';
2972-THIEF.type._life._humanoid.Daemon.name = {ja:'Daemon'};
2973-THIEF.type._life._humanoid.Daemon.hp = 10;
2974-
2975-/*
2976- *
29773086 * # : dark floor, unbreakable floor
29783087 * . : lit floor
29793088 * ~ : tail? -> &#x0330; &#x02F7;
@@ -2990,10 +3099,6 @@
29903099 * < : staircase up
29913100 * > : staircase down
29923101 * _ : altar, throne, tomb?
2993- *
2994- *
2995- *
2996- *
29973102 * 0(ZERO) : STONE
29983103 * ? : scrool
29993104 * ! : potion
@@ -3011,41 +3116,8 @@
30113116 *
30123117 */
30133118
3014-THIEF.type._item._food = Object.create(THIEF.type._item);
3015-THIEF.type._item._food.symbol = '%';
3016-THIEF.type._item._food.symbolName = {
3017- ja : '食料',
3018- en : 'Food'
3019-};
30203119
3021-THIEF.type._item._food._corpse = Object.create(THIEF.type._item._food);
3022-THIEF.type._item._food._corpse.decayable = true;
3023-THIEF.type._item._food._corpse.next = THIEF.type.$.decay;
3024-THIEF.type._item._food._corpse.dp = 20;
3025-
3026-THIEF.type._item._food.Ration = Object.create(THIEF.type._item._food);
3027-THIEF.type._item._food.Ration.name = {
3028- ja : 'レーション',
3029- en : 'Ration'
3030-};
3031-THIEF.type._item._food.Ration.color = 'red';
3032-
3033-THIEF.type._item._weapon = Object.create(THIEF.type._item);
3034-THIEF.type._item._weapon.wieldable = true;
3035-THIEF.type._item._weapon.symbol = ']';
3036-THIEF.type._item._weapon.symbolName = {
3037- ja : '武器',
3038- en : 'Weapon'
3039-};
3040-THIEF.type._item._weapon.TestDugger = Object.create(THIEF.type._item._weapon);
3041-THIEF.type._item._weapon.TestDugger.name = {
3042- ja : 'テスト用ダガー',
3043- en : 'Dagger(debugging)'
3044-};
3045-THIEF.type._item._weapon.TestDugger.damage = '2d4';
3046-THIEF.type._item._weapon.TestDugger.color = 'silver';
3047-
3048-THIEF.TEXT = {
3120+THIEF.Data.Text = {
30493121 $ : function(){
30503122 var text;
30513123
@@ -3182,3 +3254,11 @@
31823254 en : '${1} emptied the hand.'
31833255 }
31843256 };
3257+
3258+THIEF.Data.Porp = {
3259+ displayName : function() {
3260+ return this.get(THIEF.PARAM.name) + '(<span style="color:' + this.get(THIEF.PARAM.color) + '">' + this.get(THIEF.PARAM.symbol) + '</span>)'
3261+ }
3262+};
3263+
3264+THIEF.Data.Event = {}; // Event & Scenario
Show on old repository browser