Advertisement
Debugbro

DUNGEONS

Sep 4th, 2013
755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.72 KB | None | 0 0
  1. var LaunchDungeons=function()
  2. {
  3. Game.GetWord=function(type)
  4. {
  5. if (type=='secret') return choose(['hidden','secret','mysterious','forgotten','forbidden','lost','sunk','buried','concealed','shrouded','invisible','elder']);
  6. if (type=='ruined') return choose(['ancient','old','ruined','ravaged','destroyed','collapsed','demolished','burnt','torn-down','shattered','dilapidated','abandoned','crumbling','derelict','decaying']);
  7. if (type=='magical') return choose(['arcane','magical','mystical','sacred','honed','banished','unholy','holy','demonic','enchanted','necromantic','bewitched','haunted','occult','astral']);
  8. return '';
  9. }
  10.  
  11. /*=====================================================================================
  12. DUNGEONS
  13. =======================================================================================*/
  14. Game.DungeonTypes=[];
  15. Game.DungeonType=function(name)
  16. {
  17. this.name=name;
  18. this.nameGenerator=function(){return 'Mysterious dungeon';};
  19. this.roomTypes=[];
  20. Game.DungeonTypes[this.name]=this;
  21. return this;
  22. };
  23.  
  24. /*=====================================================================================
  25. CREATE DUNGEON TYPES
  26. =======================================================================================*/
  27. new Game.DungeonType('Factory').
  28. nameGenerator=function(){
  29. var str='';
  30. str+=Game.GetWord(choose(['secret','ruined','magical']))+' '+choose(['factory','factories','bakery','bakeries','confectionery','laboratory','research center','chocolate forge','chocolate foundry','manufactory','warehouse','machinery','works','bakeworks','workshop','assembly line']);
  31. return str;
  32. };
  33.  
  34. new Game.DungeonType('Mine').
  35. nameGenerator=function(){
  36. var str='';
  37. str+=Game.GetWord(choose(['secret','ruined','magical']))+' '+choose(['chocolate','chocolate','chocolate','white chocolate','sugar','cacao'])+' '+choose(['mine','mines','pit','pits','quarry','excavation','tunnel','shaft','lode','trench','mountain','vein','cliff','peak','dome','crater','abyss','chasm','hole','burrow']);
  38. return str;
  39. };
  40.  
  41. new Game.DungeonType('Portal').
  42. nameGenerator=function(){
  43. var str='';
  44. str+=Game.GetWord(choose(['secret','ruined','magical']))+' '+choose(['portal','gate','dimension','warpgate','door']);
  45. return str;
  46. };
  47.  
  48. new Game.DungeonType('Secret zebra level').
  49. nameGenerator=function(){
  50. var str='';
  51. str+=Game.GetWord(choose(['secret']))+' '+choose(['zebra level']);
  52. return str;
  53. };
  54.  
  55. Game.DungeonTiles=[];
  56. Game.DungeonTile=function(name,pic,obstacle)
  57. {
  58. this.name=name;
  59. this.pic=pic;
  60. this.obstacle=obstacle;
  61. this.id=Game.DungeonTiles.length;
  62. Game.DungeonTiles[this.id]=this;
  63. }
  64. new Game.DungeonTile('void',[0,0],1);
  65. new Game.DungeonTile('path',[0,0],0);
  66. new Game.DungeonTile('path2',[0,0],0);
  67. new Game.DungeonTile('land',[0,0],0);
  68. new Game.DungeonTile('land2',[0,0],0);
  69. new Game.DungeonTile('bridge',[0,0],0);
  70. new Game.DungeonTile('wall1',[0,0],1);
  71. new Game.DungeonTile('wall2',[0,0],1);
  72. new Game.DungeonTile('water',[0,0],1);
  73.  
  74. Game.DungeonNode=function(type)
  75. {
  76. //note : this isn't how it's gonna work in the final version.
  77. //it'll have tiny little maps
  78. //it's gonna be cute as butts
  79. this.type=type;
  80. this.id=0;
  81. this.dungeon=-1;
  82. this.exits=[];
  83. this.Write=function()
  84. {
  85. var str='';
  86. for (var i in this.exits) {str+='<br><a onclick="Game.ExploreDungeon('+this.dungeon+','+this.id+','+this.exits[i].id+');">'+this.exits[i].type+'</a>';}
  87. return 'This is a '+this.type+'.'+(str!=''?'<br>Exits :'+str:'');
  88. }
  89. }
  90.  
  91. Game.Dungeons=[];
  92. Game.Dungeon=function(type,id)
  93. {
  94. this.type=type;
  95. this.id=id;
  96. Game.Dungeons[this.id]=this;
  97. this.log=[];
  98. this.name=Game.DungeonTypes[this.type].nameGenerator();
  99. this.Log=function(what)
  100. {
  101. }
  102.  
  103. this.map=[];
  104. this.Generate=function()
  105. {
  106. this.map=[];
  107. var nodes=20;
  108. for (var i=0;i<nodes;i++)
  109. {
  110. //this is really just temporary
  111. //like, for testing and stuff
  112. this.map[i]=new Game.DungeonNode(choose(['hallowed','bloody','filthy','dark','hidden','pretty','fancy','magic','dangerous','haunted','cursed','pixie','dwarven','elven','demonic'])+' '+choose(['alley','forest','tunnel','inn','castle','river','village','mansion','mountain','lair','cave','woods','jungle','depths']));
  113. this.map[i].exits=[];
  114. this.map[i].id=i;
  115. this.map[i].dungeon=this.id;
  116. }
  117. for (var i=0;i<nodes;i++)
  118. {
  119. if (i>0) this.map[i].exits.push(this.map[i-1]);
  120. if (i<nodes-1) this.map[i].exits.push(this.map[i+1]);
  121. if (Math.random()<0.1 && i>0)
  122. {
  123. var other=this.map[Math.floor(Math.random()*(20))];
  124. if (other.id==i-1 || other.id==i || other.id==i+1) {}
  125. else
  126. {
  127. this.map[i].exits.push(other);
  128. other.exits.push(this.map[i]);
  129. }
  130. }
  131. }
  132. this.onTile=this.map[0];
  133. }
  134.  
  135. this.onTile=-1;
  136.  
  137. this.Draw=function()
  138. {
  139. var str='';
  140. str+=this.onTile.Write();
  141. str='<a onclick="Game.ObjectsById['+this.id+'].setSpecial(0);">Exit</a> | <i>(note : this is placeholder code, the final dungeons will have a tiny map and stuff)</i><br><b>'+this.name+'</b><br>'+str;
  142. l('rowSpecial'+this.id).innerHTML='<div style="width:100%;height:100%;z-index:10000;position:absolute;left:0px;top:0px;background:#000;">'+str+'</div>';
  143. }
  144.  
  145. this.DrawButton=function()
  146. {
  147. var str='';
  148. str+='<div style="text-align:center;margin:48px auto;color:#999;"><a onclick="Game.ObjectsById['+this.id+'].setSpecial(1);">Enter</a></div>';
  149. return str;
  150. }
  151. }
  152.  
  153. Game.ExploreDungeon=function(dungeon,from,to)
  154. {
  155. var me=Game.Dungeons[dungeon];
  156. me.onTile=me.map[to];
  157. me.Draw();
  158. }
  159.  
  160.  
  161. /*=====================================================================================
  162. CREATE DUNGEONS
  163. =======================================================================================*/
  164. Game.Objects['Factory'].special=function()
  165. {
  166. this.dungeon=new Game.Dungeon('Factory',this.id);
  167. this.dungeon.Generate();
  168. this.specialDrawFunction=function(){this.dungeon.Draw();};
  169. this.drawSpecialButton=function(){return this.dungeon.DrawButton();};
  170. }
  171. //Game.Objects['Factory'].special();
  172. //setTimeout(function(){Game.Objects['Factory'].dungeon.Draw();},500);
  173. //Game.Objects['Factory'].unlockSpecial();//unlock it
  174. //Game.Objects['Factory'].setSpecial(1);//enter it
  175.  
  176.  
  177. /*=====================================================================================
  178. HEROES
  179. =======================================================================================*/
  180. Game.Heroes=[];
  181. Game.HeroesById=[];
  182. Game.Hero=function(name,pic)
  183. {
  184. this.name=name;
  185. this.pic=pic;
  186. this.stats={
  187. hp:20,
  188. hpm:20,
  189. might:5,
  190. guard:5,
  191. speed:5,
  192. dodge:5,
  193. luck:5
  194. };
  195. this.dialogue={
  196. 'greeting':'Oh hey.|Sup.',
  197. 'entrance':'Here we go.|So exciting.',
  198. 'completion':'That was easy.|All done here.',
  199. 'defeat':'Welp.|Better luck next time.'
  200. };
  201. this.gear={
  202. 'armor':-1,
  203. 'weapon':-1
  204. };
  205. this.inDungeon=-1;
  206. this.completedDungeons=0;
  207.  
  208.  
  209. this.save=function()
  210. {
  211. var str='';
  212. str+=
  213. this.inDungeon+','+
  214. this.completedDungeons+','+
  215. this.gear.armor+','+
  216. this.gear.weapon
  217. ;
  218. return str;
  219. }
  220. this.load=function(data)
  221. {
  222. var str=data.split(',');
  223. this.inDungeon=parseInt(str[0]);
  224. this.completedDungeons=parseInt(str[1]);
  225. this.gear.armor=parseInt(str[2]);
  226. this.gear.weapon=parseInt(str[3]);
  227. }
  228. this.id=Game.Heroes.length;
  229. Game.Heroes[this.name]=this;
  230. Game.HeroesById[this.id]=this;
  231. }
  232.  
  233. /*=====================================================================================
  234. CREATE HEROES
  235. =======================================================================================*/
  236. new Game.Hero('Mysterious hero','nopic.png');
  237. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement