Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ae0be08721 | ||
![]() |
1f1dfd8e8e | ||
![]() |
1342593004 | ||
![]() |
e1b40abf33 | ||
![]() |
af9be9a447 | ||
![]() |
406228f75b | ||
![]() |
19af13e48f | ||
![]() |
9ca225a331 | ||
![]() |
98d3d111e0 | ||
![]() |
4da29c1bf4 | ||
![]() |
9172991efe | ||
![]() |
a2c8dc0ae1 |
871
DungeonGen.js
Normal file
|
@ -0,0 +1,871 @@
|
|||
/*
|
||||
Orteil's crappy dungeon generation library, 2013
|
||||
Unfinished and buggy, use at your own risk (please credit)
|
||||
http://orteil.dashnet.org
|
||||
|
||||
Rough process (might or might not be what actually happens) :
|
||||
1 make a room in the middle
|
||||
2 pick one of its walls (not corners)
|
||||
3 select a free tile on the other side of that wall
|
||||
4 iteratively expand the selection in one (corridors) or two (rooms) directions, stopping when we meet a wall or when we're above the size threshold
|
||||
5 compute that selection into a room
|
||||
6 add decorations to the room (pillars, water) but only on the center tiles, as to leave free passages (sprinkle destructible decorations anywhere)
|
||||
7 take a random floor tile in the room and repeat step 4, but don't stop at the walls of this room (this creates branching) - repeat about 5 times for interesting shapes
|
||||
8 add those branches to the room
|
||||
9 carve the room into the map, and set the initially selected wall as a door - set the new room's parent to the previous room, and add it to its parent's children
|
||||
10 repeat step 2 with any free wall on the map until the amount of tiles dug is above the desired fill ratio
|
||||
|
||||
Note : I should probably switch the rendering to canvas to allow stuff like occlusion shadows and lights
|
||||
*/
|
||||
|
||||
if (1==1 || undefined==Math.seedrandom)
|
||||
{
|
||||
//seeded random function, courtesy of http://davidbau.com/archives/2010/01/30/random_seeds_coded_hints_and_quintillions.html
|
||||
(function(a,b,c,d,e,f){function k(a){var b,c=a.length,e=this,f=0,g=e.i=e.j=0,h=e.S=[];for(c||(a=[c++]);d>f;)h[f]=f++;for(f=0;d>f;f++)h[f]=h[g=j&g+a[f%c]+(b=h[f])],h[g]=b;(e.g=function(a){for(var b,c=0,f=e.i,g=e.j,h=e.S;a--;)b=h[f=j&f+1],c=c*d+h[j&(h[f]=h[g=j&g+b])+(h[g]=b)];return e.i=f,e.j=g,c})(d)}function l(a,b){var e,c=[],d=(typeof a)[0];if(b&&"o"==d)for(e in a)try{c.push(l(a[e],b-1))}catch(f){}return c.length?c:"s"==d?a:a+"\0"}function m(a,b){for(var d,c=a+"",e=0;c.length>e;)b[j&e]=j&(d^=19*b[j&e])+c.charCodeAt(e++);return o(b)}function n(c){try{return a.crypto.getRandomValues(c=new Uint8Array(d)),o(c)}catch(e){return[+new Date,a,a.navigator.plugins,a.screen,o(b)]}}function o(a){return String.fromCharCode.apply(0,a)}var g=c.pow(d,e),h=c.pow(2,f),i=2*h,j=d-1;c.seedrandom=function(a,f){var j=[],p=m(l(f?[a,o(b)]:0 in arguments?a:n(),3),j),q=new k(j);return m(o(q.S),b),c.random=function(){for(var a=q.g(e),b=g,c=0;h>a;)a=(a+c)*d,b*=d,c=q.g(1);for(;a>=i;)a/=2,b/=2,c>>>=1;return(a+c)/b},p},m(c.random(),b)})(this,[],Math,256,6,52);
|
||||
}
|
||||
|
||||
if (1==1 || undefined==choose) {function choose(arr) {if (arr.length==0) return 0; else return arr[Math.floor(Math.random()*arr.length)];}}
|
||||
|
||||
|
||||
var DungeonGen=function()
|
||||
{
|
||||
var TILE_EMPTY=0;//solid
|
||||
var TILE_LIMIT=-100;//can't build anything here; edges of map
|
||||
var TILE_FLOOR_EDGE=100;
|
||||
var TILE_FLOOR_CENTER=110;
|
||||
var TILE_DOOR=200;
|
||||
var TILE_PILLAR=300;//not just pillars, could be any type of repetitive decoration
|
||||
var TILE_WATER=400;
|
||||
var TILE_WALL=500;
|
||||
var TILE_WALL_CORNER=510;
|
||||
var TILE_ENTRANCE=250;
|
||||
var TILE_EXIT=260;
|
||||
|
||||
var colors=[];
|
||||
colors[TILE_EMPTY]='000';
|
||||
colors[TILE_LIMIT]='900';
|
||||
colors[TILE_FLOOR_EDGE]='ffc';
|
||||
colors[TILE_FLOOR_CENTER]='ff9';
|
||||
colors[TILE_DOOR]='f9f';
|
||||
colors[TILE_PILLAR]='990';
|
||||
colors[TILE_WATER]='99f';
|
||||
colors[TILE_WALL]='960';
|
||||
colors[TILE_WALL_CORNER]='630';
|
||||
colors[TILE_ENTRANCE]='f9f';
|
||||
colors[TILE_EXIT]='f9f';
|
||||
|
||||
var rand=function(a,b){return Math.floor(Math.random()*(b-a+1)+a);}//return random value between a and b
|
||||
|
||||
var Patterns=[];
|
||||
this.Pattern=function(name,func)
|
||||
{
|
||||
this.name=name;
|
||||
this.func=func;
|
||||
Patterns.push(this);
|
||||
}
|
||||
new this.Pattern('Pillars',function(x,y,room)
|
||||
{
|
||||
if ((x+room.x)%2==0 && (y+room.y)%2==0 && Math.random()<0.8) return TILE_PILLAR;
|
||||
return 0;
|
||||
});
|
||||
new this.Pattern('Large pillars',function(x,y,room)
|
||||
{
|
||||
if ((x+room.x)%3<2 && (y+room.y)%3<2 && Math.random()<0.8) return TILE_PILLAR;
|
||||
return 0;
|
||||
});
|
||||
new this.Pattern('Sparse pillars',function(x,y,room)
|
||||
{
|
||||
if ((x+room.x)%3==0 && (y+room.y)%3==0 && Math.random()<0.8) return TILE_PILLAR;
|
||||
return 0;
|
||||
});
|
||||
new this.Pattern('Lines',function(x,y,room)
|
||||
{
|
||||
if (room.x%2==0) if ((x+room.x)%2==0 && Math.random()<0.98) return TILE_PILLAR;
|
||||
if (room.x%2==1) if ((y+room.y)%2==0 && Math.random()<0.98) return TILE_PILLAR;
|
||||
return 0;
|
||||
});
|
||||
|
||||
|
||||
var getRandomPattern=function()
|
||||
{return choose(Patterns);}
|
||||
|
||||
var defaultGenerator=function(me)
|
||||
{
|
||||
me.roomSize=10;
|
||||
me.corridorSize=5;
|
||||
me.fillRatio=1/3;
|
||||
me.corridorRatio=0.2;
|
||||
me.pillarRatio=0.2;
|
||||
me.waterRatio=0;
|
||||
me.branching=4;
|
||||
me.sizeVariance=0.2;
|
||||
|
||||
me.fillRatio=0.1+Math.random()*0.4;
|
||||
me.roomSize=Math.ceil(rand(5,15)*me.fillRatio*2);
|
||||
me.corridorSize=Math.ceil(rand(1,7)*me.fillRatio*2);
|
||||
me.corridorRatio=Math.random()*0.8+0.1;
|
||||
me.pillarRatio=Math.random()*0.5+0.5;
|
||||
me.waterRatio=Math.pow(Math.random(),2);
|
||||
me.branching=Math.floor(Math.random()*6);
|
||||
me.sizeVariance=Math.random();
|
||||
}
|
||||
|
||||
|
||||
this.Map=function(w,h,seed,params)
|
||||
{
|
||||
//create a new map
|
||||
//leave the seed out for a random seed
|
||||
//params is an object that contains custom parameters as defined in defaultGenerator
|
||||
//example : MyMap=new DungeonGen.Map(30,30,MySeed,{waterRatio:0.8}); (80 percent of the rooms will contain water)
|
||||
if (undefined!=seed) this.seed=seed; else {Math.seedrandom();this.seed=Math.random();}
|
||||
Math.seedrandom(this.seed);
|
||||
this.seedState=Math.random;
|
||||
this.w=w||20;
|
||||
this.h=h||20;
|
||||
|
||||
this.roomsAreHidden=0;
|
||||
|
||||
this.rooms=[];
|
||||
this.freeWalls=[];//all walls that would be a good spot for a door
|
||||
this.freeTiles=[];//all passable floor tiles
|
||||
this.doors=[];
|
||||
this.tiles=this.w*this.h;
|
||||
this.tilesDug=0;
|
||||
this.digs=0;//amount of digging steps
|
||||
this.stuck=0;//how many times we ran into a problem; stop digging if we get too many of these
|
||||
|
||||
this.data=[];//fill the map with 0
|
||||
for (var x=0;x<this.w;x++)
|
||||
{
|
||||
this.data[x]=[];
|
||||
for (var y=0;y<this.h;y++)
|
||||
{
|
||||
this.data[x][y]=[TILE_EMPTY,-1,0];//data is stored as [tile system type,room id,tile displayed type] (-1 is no room)
|
||||
if (x==0 || y==0 || x==this.w-1 || y==this.h-1) this.data[x][y]=[TILE_LIMIT,-1,0];
|
||||
}
|
||||
}
|
||||
|
||||
defaultGenerator(this);
|
||||
if (params)
|
||||
{
|
||||
for (var i in params)
|
||||
{
|
||||
this[i]=params[i];
|
||||
}
|
||||
}
|
||||
Math.seedrandom();
|
||||
|
||||
}
|
||||
|
||||
this.Map.prototype.getType=function(x,y){return this.data[x][y][0];}
|
||||
this.Map.prototype.getRoom=function(x,y){if (this.data[x][y][1]!=-1) return this.rooms[this.data[x][y][1]]; else return -1;}
|
||||
this.Map.prototype.getTile=function(x,y){return this.rooms[this.data[x][y][2]];}
|
||||
|
||||
this.Map.prototype.isWall=function(x,y)
|
||||
{
|
||||
var n=0;
|
||||
for (var i in this.freeWalls){if (this.freeWalls[i][0]==x && this.freeWalls[i][1]==y) return n; else n++;}
|
||||
return -1;
|
||||
}
|
||||
this.Map.prototype.isFloor=function(x,y)
|
||||
{
|
||||
var n=0;
|
||||
for (var i in this.freeTiles){if (this.freeTiles[i][0]==x && this.freeTiles[i][1]==y) return n; else n++;}
|
||||
return -1;
|
||||
}
|
||||
this.Map.prototype.removeFreeTile=function(x,y)
|
||||
{
|
||||
this.freeTiles.splice(this.isFloor(x,y),1);
|
||||
}
|
||||
|
||||
this.Map.prototype.fill=function(what)
|
||||
{
|
||||
//fill with something (either a set value, or a function that takes the map, a position X and a position Y as arguments)
|
||||
//NOTE : this also resets the rooms!
|
||||
//example : MyMap.fill(function(m,x,y){return Math.floor((Math.random());});
|
||||
//...will fill the map with 0s and 1s
|
||||
var func=0;
|
||||
if (typeof(what)=='function') func=1;
|
||||
for (var x=0;x<this.w;x++){for (var y=0;y<this.h;y++){
|
||||
if (func) this.data[x][y]=[what(this,x,y),-1,0]; else this.data[x][y]=[what,-1,0];
|
||||
}}
|
||||
this.rooms=[];
|
||||
}
|
||||
|
||||
this.Map.prototype.fillZone=function(X,Y,W,H,what)
|
||||
{
|
||||
//just plain fill a rectangle
|
||||
for (var x=X;x<X+W;x++){for (var y=Y;y<Y+H;y++){
|
||||
this.data[x][y][0]=what;
|
||||
}}
|
||||
}
|
||||
|
||||
this.Map.prototype.getRoomTile=function(room,x,y)
|
||||
{
|
||||
var n=0;
|
||||
for (var i in room.tiles) {if (room.tiles[i].x==x && room.tiles[i].y==y) return n; else n++;}
|
||||
return -1;
|
||||
}
|
||||
|
||||
this.Map.prototype.getFloorTileInRoom=function(room)
|
||||
{
|
||||
var tiles=[];
|
||||
for (var i in room.tiles) {if (room.tiles[i].type==TILE_FLOOR_EDGE || room.tiles[i].type==TILE_FLOOR_CENTER) tiles.push(room.tiles[i]);}
|
||||
return choose(tiles);
|
||||
}
|
||||
|
||||
this.Map.prototype.canPlaceRoom=function(rx,ry,rw,rh)
|
||||
{
|
||||
if (rx<2 || ry<2 || rx+rw>=this.w-1 || ry+rh>=this.h-1) return false;
|
||||
for (var x=rx;x<rx+rw;x++)
|
||||
{
|
||||
for (var y=ry;y<ry+rh;y++)
|
||||
{
|
||||
var tile=this.getType(x,y);
|
||||
var room=this.getRoom(x,y);
|
||||
if (tile==TILE_LIMIT) return false;
|
||||
if (room!=-1) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
this.Map.prototype.setRoomTile=function(room,x,y,tile)
|
||||
{
|
||||
//var mapTile=this.getType(x,y);
|
||||
var oldTile=this.getRoomTile(room,x,y);
|
||||
var oldTileType=oldTile!=-1?room.tiles[oldTile].type:-1;
|
||||
if (oldTile!=-1 && (
|
||||
//(tile!=TILE_FLOOR_EDGE && tile!=TILE_FLOOR_CENTER) ||// && (oldTileType!=TILE_FLOOR_EDGE && oldTileType!=TILE_FLOOR_CENTER)) ||
|
||||
//(tile!=TILE_FLOOR_EDGE && tile!=TILE_FLOOR_CENTER && (oldTileType!=TILE_FLOOR_EDGE && oldTileType!=TILE_FLOOR_CENTER)) ||
|
||||
(tile==TILE_WALL || tile==TILE_WALL_CORNER) ||//don't place a wall over an existing room
|
||||
(tile==TILE_FLOOR_EDGE && oldTileType==TILE_FLOOR_CENTER)//don't place an edge floor over a center floor
|
||||
)) {return false;}
|
||||
else
|
||||
{
|
||||
if (oldTile!=-1) room.tiles.splice(oldTile,1);
|
||||
room.tiles.push({x:x,y:y,type:tile,score:0});
|
||||
if ((tile==TILE_FLOOR_EDGE || tile==TILE_FLOOR_CENTER) && (oldTileType!=TILE_FLOOR_EDGE && oldTileType!=TILE_FLOOR_CENTER)) room.freeTiles++;
|
||||
else if (tile!=TILE_FLOOR_EDGE && tile!=TILE_FLOOR_CENTER && (oldTileType==TILE_FLOOR_EDGE || oldTileType==TILE_FLOOR_CENTER)) room.freeTiles--;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
this.Map.prototype.expandRoom=function(room,rx,ry,rw,rh)
|
||||
{
|
||||
var x=0;var y=0;
|
||||
//floor
|
||||
for (var x=rx;x<rx+rw;x++){for (var y=ry;y<ry+rh;y++){
|
||||
this.setRoomTile(room,x,y,TILE_FLOOR_EDGE);
|
||||
}}
|
||||
for (var x=rx+1;x<rx+rw-1;x++){for (var y=ry+1;y<ry+rh-1;y++){
|
||||
this.setRoomTile(room,x,y,TILE_FLOOR_CENTER);
|
||||
}}
|
||||
//walls
|
||||
y=ry-1;
|
||||
for (var x=rx;x<rx+rw;x++){
|
||||
this.setRoomTile(room,x,y,TILE_WALL);
|
||||
}
|
||||
y=ry+rh;
|
||||
for (var x=rx;x<rx+rw;x++){
|
||||
this.setRoomTile(room,x,y,TILE_WALL);
|
||||
}
|
||||
x=rx-1;
|
||||
for (var y=ry;y<ry+rh;y++){
|
||||
this.setRoomTile(room,x,y,TILE_WALL);
|
||||
}
|
||||
x=rx+rw;
|
||||
for (var y=ry;y<ry+rh;y++){
|
||||
this.setRoomTile(room,x,y,TILE_WALL);
|
||||
}
|
||||
//corners
|
||||
x=rx-1;y=ry-1;
|
||||
this.setRoomTile(room,x,y,TILE_WALL_CORNER);
|
||||
x=rx+rw;y=ry-1;
|
||||
this.setRoomTile(room,x,y,TILE_WALL_CORNER);
|
||||
x=rx-1;y=ry+rh;
|
||||
this.setRoomTile(room,x,y,TILE_WALL_CORNER);
|
||||
x=rx+rw;y=ry+rh;
|
||||
this.setRoomTile(room,x,y,TILE_WALL_CORNER);
|
||||
|
||||
//decoration
|
||||
var water=Math.random()<this.waterRatio?1:0;
|
||||
var pattern=Math.random()<this.pillarRatio?getRandomPattern():0;
|
||||
for (var x=rx;x<rx+rw;x++){for (var y=ry;y<ry+rh;y++){
|
||||
if (room.tiles[this.getRoomTile(room,x,y)].type==TILE_FLOOR_CENTER)
|
||||
{
|
||||
var tile=0;
|
||||
if (water!=0) tile=TILE_WATER;
|
||||
if (pattern!=0)
|
||||
{
|
||||
tile=pattern.func(x,y,room)||tile;
|
||||
}
|
||||
if (tile!=0) this.setRoomTile(room,x,y,tile);
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
this.Map.prototype.newRoom=function(x,y,w,h,parent)
|
||||
{
|
||||
//create a new abstract room, ready to be carved
|
||||
var room={};
|
||||
room.id=this.rooms.length;
|
||||
room.w=w;//||rand(2,this.roomSize);
|
||||
room.h=h;//||rand(2,this.roomSize);
|
||||
room.x=x||rand(1,this.w-room.w-1);
|
||||
room.y=y||rand(1,this.h-room.h-1);
|
||||
room.tiles=[];
|
||||
room.freeTiles=0;
|
||||
room.parent=parent?parent:-1;
|
||||
room.children=[];
|
||||
room.gen=0;
|
||||
room.door=0;
|
||||
room.corridor=Math.random()<this.corridorRatio?1:0;
|
||||
room.hidden=this.roomsAreHidden;//if 1, don't draw
|
||||
//if (room.parent!=-1) room.corridor=!room.parent.corridor;//alternate rooms and corridors
|
||||
|
||||
return room;
|
||||
}
|
||||
this.Map.prototype.planRoom=function(room)
|
||||
{
|
||||
var branches=this.branching+1;
|
||||
var forcedExpansions=[];
|
||||
var w=room.w;
|
||||
var h=room.h;
|
||||
while (w>0 && h>0)
|
||||
{
|
||||
if (w>0) {forcedExpansions.push(1,3);w--;}
|
||||
if (h>0) {forcedExpansions.push(2,4);h--;}
|
||||
}
|
||||
|
||||
for (var i=0;i<branches;i++)
|
||||
{
|
||||
var steps=0;
|
||||
var expansions=[];
|
||||
if (!room.corridor)
|
||||
{
|
||||
expansions=[1,2,3,4];
|
||||
steps=this.roomSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
expansions=choose([[1,3],[2,4]]);
|
||||
steps=this.corridorSize;
|
||||
}
|
||||
steps=Math.max(room.w+room.h,Math.ceil(steps*(1-Math.random()*this.sizeVariance)));
|
||||
if (room.tiles.length==0) {var rx=room.x;var ry=room.y;var rw=1;var rh=1;}
|
||||
else {var randomTile=this.getFloorTileInRoom(room);var rx=randomTile.x;var ry=randomTile.y;var rw=1;var rh=1;}
|
||||
for (var ii=0;ii<steps;ii++)
|
||||
{
|
||||
if (expansions.length==0) break;
|
||||
var xd=0;var yd=0;var wd=0;var hd=0;
|
||||
var side=choose(expansions);
|
||||
if (forcedExpansions.length>0) side=forcedExpansions[0];
|
||||
if (side==1) {xd=-1;wd=1;}
|
||||
else if (side==2) {yd=-1;hd=1;}
|
||||
else if (side==3) {wd=1;}
|
||||
else if (side==4) {hd=1;}
|
||||
if (this.canPlaceRoom(rx+xd,ry+yd,rw+wd,rh+hd)) {rx+=xd;ry+=yd;rw+=wd;rh+=hd;} else expansions.splice(expansions.indexOf(side),1);
|
||||
if (forcedExpansions.length>0) forcedExpansions.splice(0,1);
|
||||
}
|
||||
if (rw>1 || rh>1)
|
||||
{
|
||||
this.expandRoom(room,rx,ry,rw,rh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.Map.prototype.carve=function(room)
|
||||
{
|
||||
//carve a room into the map
|
||||
for (var i in room.tiles)
|
||||
{
|
||||
var thisTile=room.tiles[i];
|
||||
var x=thisTile.x;var y=thisTile.y;
|
||||
var myType=this.data[x][y][0];
|
||||
var type=thisTile.type;
|
||||
|
||||
if ((type==TILE_WALL || type==TILE_WALL_CORNER) && this.isWall(x,y)!=-1) {this.freeWalls.splice(this.isWall(x,y),1);}
|
||||
|
||||
if (this.data[x][y][1]!=-1 && (type==TILE_WALL || type==TILE_WALL_CORNER)) {}
|
||||
else
|
||||
{
|
||||
if (this.data[x][y][1]==-1) this.tilesDug++;
|
||||
this.data[x][y]=[thisTile.type,room.id,0];
|
||||
if (x>1 && y>1 && x<this.w-2 && y<this.h-2 && type==TILE_WALL) this.freeWalls.push([x,y]);
|
||||
if (type==TILE_FLOOR_EDGE || type==TILE_FLOOR_CENTER) this.freeTiles.push([x,y]);
|
||||
}
|
||||
var pos=[x,y];
|
||||
}
|
||||
this.rooms[room.id]=room;
|
||||
}
|
||||
|
||||
this.Map.prototype.newRandomRoom=function(params)
|
||||
{
|
||||
var success=1;
|
||||
params=params||{};//params is an object such as {corridor:1}
|
||||
var door=choose(this.freeWalls);//select a free wall to use as a door
|
||||
if (!door) {success=0;}
|
||||
else
|
||||
{
|
||||
//this.data[door[0]][door[1]][0]=TILE_LIMIT;//not door
|
||||
var parentRoom=this.getRoom(door[0],door[1]);
|
||||
var sides=[];//select a free side of that door
|
||||
if (this.getType(door[0]-1,door[1])==TILE_EMPTY) sides.push([-1,0]);
|
||||
if (this.getType(door[0]+1,door[1])==TILE_EMPTY) sides.push([1,0]);
|
||||
if (this.getType(door[0],door[1]-1)==TILE_EMPTY) sides.push([0,-1]);
|
||||
if (this.getType(door[0],door[1]+1)==TILE_EMPTY) sides.push([0,1]);
|
||||
var side=choose(sides);
|
||||
if (!side) {success=0;this.freeWalls.splice(this.isWall(door[0],door[1]),1);}
|
||||
else
|
||||
{
|
||||
var room=this.newRoom(door[0]+side[0],door[1]+side[1],0,0,parentRoom);//try a new room from this spot
|
||||
for (var i in params)
|
||||
{
|
||||
room[i]=params[i];
|
||||
}
|
||||
this.planRoom(room);
|
||||
if (room.tiles.length>0 && room.freeTiles>0)//we got a decent room
|
||||
{
|
||||
this.carve(room);
|
||||
this.data[door[0]][door[1]][0]=TILE_DOOR;//place door
|
||||
room.door=[door[0],door[1]];
|
||||
this.data[door[0]][door[1]][1]=room.id;//set ID
|
||||
this.freeWalls.splice(this.isWall(door[0],door[1]),1);//the door isn't a wall anymore
|
||||
this.doors.push([door[0],door[1],room]);
|
||||
//remove free tiles on either side of the door
|
||||
if (this.isFloor(door[0]+side[0],door[1]+side[1])!=-1) this.removeFreeTile(door[0]+side[0],door[1]+side[1]);
|
||||
if (this.isFloor(door[0]-side[0],door[1]-side[1])!=-1) this.removeFreeTile(door[0]-side[0],door[1]-side[1]);
|
||||
room.parent=parentRoom;
|
||||
parentRoom.children.push(room);
|
||||
room.gen=parentRoom.gen+1;
|
||||
}
|
||||
else//not a good spot; remove this tile from the list of walls
|
||||
{
|
||||
this.freeWalls.splice(this.isWall(door[0],door[1]),1);
|
||||
success=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (success) return room;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
this.Map.prototype.getRandomSpotInRoom=function(room)
|
||||
{
|
||||
var listOfTiles=[];
|
||||
for (var i in room.tiles)
|
||||
{
|
||||
if ((room.tiles[i].type==TILE_FLOOR_EDGE || room.tiles[i].type==TILE_FLOOR_CENTER) && this.isFloor(room.tiles[i].x,room.tiles[i].y)!=-1)
|
||||
{
|
||||
listOfTiles.push(room.tiles[i]);
|
||||
}
|
||||
}
|
||||
if (listOfTiles.length==0) return -1;
|
||||
return choose(listOfTiles);
|
||||
}
|
||||
this.Map.prototype.getBestSpotInRoom=function(room)
|
||||
{
|
||||
var highest=-1;
|
||||
var listOfHighest=[];
|
||||
for (var i in room.tiles)
|
||||
{
|
||||
if ((room.tiles[i].type==TILE_FLOOR_EDGE || room.tiles[i].type==TILE_FLOOR_CENTER) && this.isFloor(room.tiles[i].x,room.tiles[i].y)!=-1)
|
||||
{
|
||||
if (room.tiles[i].score>highest)
|
||||
{
|
||||
listOfHighest=[];
|
||||
highest=room.tiles[i].score;
|
||||
listOfHighest.push(room.tiles[i]);
|
||||
}
|
||||
else if (room.tiles[i].score==highest)
|
||||
{
|
||||
listOfHighest.push(room.tiles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (listOfHighest.length==0) return -1;
|
||||
return choose(listOfHighest);
|
||||
}
|
||||
this.Map.prototype.getEarliestRoom=function()
|
||||
{
|
||||
return this.rooms[0];
|
||||
}
|
||||
this.Map.prototype.getDeepestRoom=function()
|
||||
{
|
||||
var deepest=0;
|
||||
var deepestRoom=this.rooms[0];
|
||||
for (var i in this.rooms)
|
||||
{
|
||||
if ((this.rooms[i].gen+Math.sqrt(this.rooms[i].freeTiles)*0.05)>=deepest && this.rooms[i].corridor==0 && this.rooms[i].freeTiles>4) {deepest=(this.rooms[i].gen+Math.sqrt(this.rooms[i].freeTiles)*0.05);deepestRoom=this.rooms[i];}
|
||||
}
|
||||
return deepestRoom;
|
||||
}
|
||||
|
||||
this.Map.prototype.dig=function()
|
||||
{
|
||||
//one step in which we try to carve new stuff
|
||||
//returns 0 when we couldn't dig this step, 1 when we could, and 2 when the digging is complete
|
||||
Math.random=this.seedState;
|
||||
|
||||
var badDig=0;
|
||||
|
||||
if (this.digs==0)//first dig : build a starting room in the middle of the map
|
||||
{
|
||||
var w=rand(3,7);
|
||||
var h=rand(3,7);
|
||||
var room=this.newRoom(Math.floor(this.w/2-w/2),Math.floor(this.h/2-h/2),w,h);
|
||||
room.corridor=0;
|
||||
this.planRoom(room);
|
||||
this.carve(room);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.newRandomRoom()==0) badDig++;
|
||||
}
|
||||
if (badDig>0) this.stuck++;
|
||||
|
||||
this.digs++;
|
||||
|
||||
var finished=0;
|
||||
if (this.tilesDug>=this.tiles*this.fillRatio) finished=1;
|
||||
if (this.stuck>100) finished=1;
|
||||
|
||||
if (finished==1)//last touch : try to add a whole room at the end
|
||||
{
|
||||
for (var i=0;i<10;i++)
|
||||
{
|
||||
var newRoom=this.newRandomRoom({corridor:0,w:rand(3,7),h:rand(3,7)});
|
||||
if (newRoom!=0 && newRoom.freeTiles>15) break;
|
||||
}
|
||||
}
|
||||
|
||||
Math.seedrandom();
|
||||
if (finished==1) return 1; else if (badDig>0) return -1; else return 0;
|
||||
}
|
||||
|
||||
this.Map.prototype.finish=function()
|
||||
{
|
||||
//touch up the map : add pillars in corners etc
|
||||
/*
|
||||
//set paths
|
||||
for (var i in this.rooms)
|
||||
{
|
||||
var me=this.rooms[i];
|
||||
if (me.door!=0)
|
||||
{
|
||||
var doors=[];
|
||||
doors.push(me.door);
|
||||
for (var ii in me.children)
|
||||
{
|
||||
if (me.children[ii].door!=0) doors.push(me.children[ii].door);
|
||||
}
|
||||
for (var ii in doors)
|
||||
{
|
||||
this.data[doors[ii][0]][doors[ii][1]][0]=TILE_LIMIT;
|
||||
//ideally we should run agents that step from each door to the next
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
for (var i in this.rooms)
|
||||
{
|
||||
var pillars=Math.random()<this.pillarRatio;
|
||||
for (var ii in this.rooms[i].tiles)
|
||||
{
|
||||
var x=this.rooms[i].tiles[ii].x;
|
||||
var y=this.rooms[i].tiles[ii].y;
|
||||
var me=this.data[x][y][0];
|
||||
var x1=this.data[x-1][y][0];
|
||||
var x2=this.data[x+1][y][0];
|
||||
var y1=this.data[x][y-1][0];
|
||||
var y2=this.data[x][y+1][0];
|
||||
var xy1=this.data[x-1][y-1][0];
|
||||
var xy2=this.data[x+1][y-1][0];
|
||||
var xy3=this.data[x-1][y+1][0];
|
||||
var xy4=this.data[x+1][y+1][0];
|
||||
|
||||
var walls=0;
|
||||
if ((x1==TILE_WALL||x1==TILE_WALL_CORNER)) walls++;
|
||||
if ((y1==TILE_WALL||y1==TILE_WALL_CORNER)) walls++;
|
||||
if ((x2==TILE_WALL||x2==TILE_WALL_CORNER)) walls++;
|
||||
if ((y2==TILE_WALL||y2==TILE_WALL_CORNER)) walls++;
|
||||
if ((xy1==TILE_WALL||xy1==TILE_WALL_CORNER)) walls++;
|
||||
if ((xy2==TILE_WALL||xy2==TILE_WALL_CORNER)) walls++;
|
||||
if ((xy3==TILE_WALL||xy3==TILE_WALL_CORNER)) walls++;
|
||||
if ((xy4==TILE_WALL||xy4==TILE_WALL_CORNER)) walls++;
|
||||
|
||||
var floors=0;
|
||||
if ((x1==TILE_FLOOR_CENTER||x1==TILE_FLOOR_EDGE)) floors++;
|
||||
if ((y1==TILE_FLOOR_CENTER||y1==TILE_FLOOR_EDGE)) floors++;
|
||||
if ((x2==TILE_FLOOR_CENTER||x2==TILE_FLOOR_EDGE)) floors++;
|
||||
if ((y2==TILE_FLOOR_CENTER||y2==TILE_FLOOR_EDGE)) floors++;
|
||||
if ((xy1==TILE_FLOOR_CENTER||xy1==TILE_FLOOR_EDGE)) floors++;
|
||||
if ((xy2==TILE_FLOOR_CENTER||xy2==TILE_FLOOR_EDGE)) floors++;
|
||||
if ((xy3==TILE_FLOOR_CENTER||xy3==TILE_FLOOR_EDGE)) floors++;
|
||||
if ((xy4==TILE_FLOOR_CENTER||xy4==TILE_FLOOR_EDGE)) floors++;
|
||||
|
||||
var complete=0;
|
||||
if (walls+floors==8) complete=1;
|
||||
|
||||
var angle=0;
|
||||
if (complete)
|
||||
{
|
||||
var top=0;
|
||||
var left=0;
|
||||
var right=0;
|
||||
var bottom=0;
|
||||
if ((xy1==TILE_WALL||xy1==TILE_WALL_CORNER) && (y1==TILE_WALL||y1==TILE_WALL_CORNER) && (xy2==TILE_WALL||xy2==TILE_WALL_CORNER)) top=1;
|
||||
else if ((xy1==TILE_FLOOR_CENTER||xy1==TILE_FLOOR_EDGE) && (y1==TILE_FLOOR_CENTER||y1==TILE_FLOOR_EDGE) && (xy2==TILE_FLOOR_CENTER||xy2==TILE_FLOOR_EDGE)) top=-1;
|
||||
if ((xy2==TILE_WALL||xy2==TILE_WALL_CORNER) && (x2==TILE_WALL||x2==TILE_WALL_CORNER) && (xy4==TILE_WALL||xy4==TILE_WALL_CORNER)) right=1;
|
||||
else if ((xy2==TILE_FLOOR_CENTER||xy2==TILE_FLOOR_EDGE) && (x2==TILE_FLOOR_CENTER||x2==TILE_FLOOR_EDGE) && (xy4==TILE_FLOOR_CENTER||xy4==TILE_FLOOR_EDGE)) right=-1;
|
||||
if ((xy1==TILE_WALL||xy1==TILE_WALL_CORNER) && (x1==TILE_WALL||x1==TILE_WALL_CORNER) && (xy3==TILE_WALL||xy3==TILE_WALL_CORNER)) left=1;
|
||||
else if ((xy1==TILE_FLOOR_CENTER||xy1==TILE_FLOOR_EDGE) && (x1==TILE_FLOOR_CENTER||x1==TILE_FLOOR_EDGE) && (xy3==TILE_FLOOR_CENTER||xy3==TILE_FLOOR_EDGE)) left=-1;
|
||||
if ((xy3==TILE_WALL||xy3==TILE_WALL_CORNER) && (y2==TILE_WALL||y2==TILE_WALL_CORNER) && (xy4==TILE_WALL||xy4==TILE_WALL_CORNER)) bottom=1;
|
||||
else if ((xy3==TILE_FLOOR_CENTER||xy3==TILE_FLOOR_EDGE) && (y2==TILE_FLOOR_CENTER||y2==TILE_FLOOR_EDGE) && (xy4==TILE_FLOOR_CENTER||xy4==TILE_FLOOR_EDGE)) bottom=-1;
|
||||
if ((top==1 && bottom==-1) || (top==-1 && bottom==1) || (left==1 && right==-1) || (left==-1 && right==1)) angle=1;
|
||||
}
|
||||
|
||||
if (pillars && Math.random()<0.8 && this.rooms[i].freeTiles>4)
|
||||
{
|
||||
if ((angle==1 || (complete && walls==7)) && me==TILE_FLOOR_EDGE && x1!=TILE_DOOR && x2!=TILE_DOOR && y1!=TILE_DOOR && y2!=TILE_DOOR)
|
||||
{
|
||||
this.data[x][y][0]=TILE_PILLAR;
|
||||
me=TILE_PILLAR;
|
||||
this.removeFreeTile(x,y);
|
||||
this.rooms[i].freeTiles--;
|
||||
}
|
||||
}
|
||||
|
||||
//calculate score (for placing items and exits)
|
||||
if (top==1 || bottom==1 || left==1 || right==1)
|
||||
{
|
||||
this.rooms[i].tiles[ii].score+=2;
|
||||
}
|
||||
if (walls>5 || floors>5)
|
||||
{
|
||||
this.rooms[i].tiles[ii].score+=1;
|
||||
}
|
||||
if (walls==7 || floors==8)
|
||||
{
|
||||
this.rooms[i].tiles[ii].score+=5;
|
||||
}
|
||||
if ((me!=TILE_FLOOR_CENTER && me!=TILE_FLOOR_EDGE) || x1==TILE_DOOR || x2==TILE_DOOR || y1==TILE_DOOR || y2==TILE_DOOR) this.rooms[i].tiles[ii].score=-1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//carve entrance and exit
|
||||
var entrance=this.getBestSpotInRoom(this.getEarliestRoom());
|
||||
this.data[entrance.x][entrance.y][0]=TILE_ENTRANCE;
|
||||
this.entrance=[entrance.x,entrance.y];
|
||||
entrance.score=0;
|
||||
this.removeFreeTile(entrance.x,entrance.y);
|
||||
var exit=this.getBestSpotInRoom(this.getDeepestRoom());
|
||||
this.data[exit.x][exit.y][0]=TILE_EXIT;
|
||||
this.exit=[exit.x,exit.y];
|
||||
this.removeFreeTile(exit.x,exit.y);
|
||||
exit.score=0;
|
||||
|
||||
/*
|
||||
for (var i in this.doors)//remove door tiles (to add later; replace the tiles by entities that delete themselves when opened)
|
||||
{
|
||||
this.data[this.doors[i][0]][this.doors[i][1]][0]=TILE_FLOOR_EDGE;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
this.Map.prototype.isObstacle=function(x,y)
|
||||
{
|
||||
var free=[TILE_FLOOR_EDGE,TILE_FLOOR_CENTER,TILE_DOOR,TILE_ENTRANCE,TILE_EXIT];
|
||||
for (var i in free)
|
||||
{
|
||||
if (this.data[x][y][0]==free[i]) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
var joinTile=function(map,x,y,joinWith)
|
||||
{
|
||||
//for the tile at x,y, return 2 if it joins with its horizontal neighbors, 3 if it joins with its vertical neighbors, 1 if it joins with either both or neither.
|
||||
//joinWith contains the tile types that count as joinable, in addition to this tile. (don't add the tested tile to joinWith!)
|
||||
var p=1;
|
||||
var me=map.data[x][y][0];
|
||||
var x1=map.data[x-1][y][0];
|
||||
var x2=map.data[x+1][y][0];
|
||||
var y1=map.data[x][y-1][0];
|
||||
var y2=map.data[x][y+1][0];
|
||||
joinWith.push(me);
|
||||
var joinsX=0;
|
||||
for (var i in joinWith)
|
||||
{
|
||||
if (x1==joinWith[i]) joinsX++;
|
||||
if (x2==joinWith[i]) joinsX++;
|
||||
}
|
||||
var joinsY=0;
|
||||
for (var i in joinWith)
|
||||
{
|
||||
if (y1==joinWith[i]) joinsY++;
|
||||
if (y2==joinWith[i]) joinsY++;
|
||||
}
|
||||
if (joinsX==2 && joinsY==2) p=1;
|
||||
else if (joinsX==2) p=2;
|
||||
else if (joinsY==2) p=3;
|
||||
return p;
|
||||
}
|
||||
this.Map.prototype.getPic=function(x,y)
|
||||
{
|
||||
//return a position [x,y] in the tiles (as 0, 1, 2...) for the tile on the map at position x,y
|
||||
if (Tiles[this.data[x][y][2]])
|
||||
{
|
||||
if (Tiles[this.data[x][y][2]].joinType=='join')
|
||||
{
|
||||
var thisPic=Tiles[this.data[x][y][2]].pic;
|
||||
thisPic=[thisPic[0],thisPic[1]];//why is this even necessary?
|
||||
var joinWith=[];
|
||||
if (this.data[x][y][0]==TILE_WALL) joinWith.push(TILE_WALL_CORNER);
|
||||
else if (this.data[x][y][0]==TILE_DOOR) joinWith.push(TILE_WALL,TILE_WALL_CORNER);
|
||||
thisPic[0]+=joinTile(this,x,y,joinWith)-1;
|
||||
return thisPic;
|
||||
}
|
||||
else if (Tiles[this.data[x][y][2]].joinType=='random3')
|
||||
{
|
||||
var thisPic=Tiles[this.data[x][y][2]].pic;
|
||||
thisPic=[thisPic[0],thisPic[1]];
|
||||
thisPic[0]+=Math.floor(Math.random()*3);
|
||||
return thisPic;
|
||||
}
|
||||
return Tiles[this.data[x][y][2]].pic;
|
||||
}
|
||||
return [0,0];
|
||||
}
|
||||
|
||||
var Tiles=[];
|
||||
var TilesByName=[];
|
||||
this.Tile=function(name,pic,joinType)
|
||||
{
|
||||
this.name=name;
|
||||
this.pic=pic;
|
||||
this.joinType=joinType||'none';
|
||||
this.id=Tiles.length;
|
||||
Tiles[this.id]=this;
|
||||
TilesByName[this.name]=this;
|
||||
}
|
||||
new this.Tile('void',[0,0]);
|
||||
this.loadTiles=function(tiles)
|
||||
{
|
||||
for (var i in tiles)
|
||||
{
|
||||
var name=tiles[i][0];
|
||||
var pic=tiles[i][1];
|
||||
var joinType=tiles[i][2];
|
||||
new this.Tile(name,pic,joinType);
|
||||
}
|
||||
}
|
||||
|
||||
var computeTile=function(tile,tiles,value,name)
|
||||
{
|
||||
if (tile==value && tiles[name]) return TilesByName[tiles[name]];
|
||||
return 0;
|
||||
}
|
||||
this.Map.prototype.assignTiles=function(room,tiles)
|
||||
{
|
||||
//set the displayed tiles for this room
|
||||
for (var i in room.tiles)
|
||||
{
|
||||
var type=Tiles[0];
|
||||
var me=room.tiles[i];
|
||||
var tile=this.data[me.x][me.y][0];
|
||||
type=computeTile(tile,tiles,TILE_WALL_CORNER,'wall corner')||type;
|
||||
type=computeTile(tile,tiles,TILE_WALL,'wall')||type;
|
||||
type=computeTile(tile,tiles,TILE_FLOOR_EDGE,'floor edges')||type;
|
||||
type=computeTile(tile,tiles,TILE_FLOOR_CENTER,'floor')||type;
|
||||
type=computeTile(tile,tiles,TILE_PILLAR,'pillar')||type;
|
||||
type=computeTile(tile,tiles,TILE_DOOR,'door')||type;
|
||||
type=computeTile(tile,tiles,TILE_WATER,'water')||type;
|
||||
type=computeTile(tile,tiles,TILE_ENTRANCE,'entrance')||type;
|
||||
type=computeTile(tile,tiles,TILE_EXIT,'exit')||type;
|
||||
|
||||
this.data[me.x][me.y][2]=type.id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.Map.prototype.draw=function(size)
|
||||
{
|
||||
//return a string containing a rough visual representation of the map
|
||||
var str='';
|
||||
var size=size||10;
|
||||
for (var y=0;y<this.h;y++){for (var x=0;x<this.w;x++){
|
||||
var text='';
|
||||
if (this.isFloor(x,y)!=-1) text='o';
|
||||
if (this.isWall(x,y)!=-1) text+='x';
|
||||
var room=this.getRoom(x,y);
|
||||
var opacity=Math.max(0.1,1-(this.getRoom(x,y).gen/10));
|
||||
var title=room.freeTiles;//this.data[x][y][0].toString();
|
||||
text='';
|
||||
str+='<div style="opacity:'+opacity+';width:'+size+'px;height:'+size+'px;position:absolute;left:'+(x*size)+'px;top:'+(y*size)+'px;display:block;padding:0px;margin:0px;background:#'+colors[this.data[x][y][0]]+';color:#999;" title="'+title+'">'+text+'</div>';
|
||||
}
|
||||
str+='<br>';
|
||||
}
|
||||
str='<div style="position:relative;width:'+(this.w*size)+'px;height:'+(this.h*size)+'px;background:#000;font-family:Courier;font-size:'+size+'px;float:left;margin:10px;">'+str+'</div>';
|
||||
return str;
|
||||
}
|
||||
|
||||
this.Map.prototype.drawDetailed=function()
|
||||
{
|
||||
//return a string containing a rough visual representation of the map (with graphics)
|
||||
var str='';
|
||||
var size=16;
|
||||
for (var y=0;y<this.h;y++){for (var x=0;x<this.w;x++){
|
||||
var room=this.getRoom(x,y);
|
||||
//var opacity=Math.max(0.1,room.tiles[this.getRoomTile(room,x,y)].score);
|
||||
var opacity=1;
|
||||
var title='void';
|
||||
if (room!=-1)
|
||||
{
|
||||
opacity=Math.max(0.1,1-room.gen/5);
|
||||
if (this.data[x][y][0]==TILE_ENTRANCE || this.data[x][y][0]==TILE_EXIT) opacity=1;
|
||||
title=(room.corridor?'corridor':'room')+' '+room.id+' | depth : '+room.gen+' | children : '+room.children.length;
|
||||
}
|
||||
var pic=this.getPic(x,y);
|
||||
str+='<div style="opacity:'+opacity+';width:'+size+'px;height:'+size+'px;position:absolute;left:'+(x*size)+'px;top:'+(y*size)+'px;display:block;padding:0px;margin:0px;background:#'+colors[this.data[x][y][0]]+' url(img/dungeonTiles.png) '+(-pic[0]*16)+'px '+(-pic[1]*16)+'px;color:#999;" title="'+title+'"></div>';
|
||||
}
|
||||
str+='<br>';
|
||||
}
|
||||
str='<div style="box-shadow:0px 0px 12px 6px #00061b;position:relative;width:'+(this.w*size)+'px;height:'+(this.h*size)+'px;background:#00061b;font-family:Courier;font-size:'+size+'px;float:left;margin:10px;">'+str+'</div>';
|
||||
return str;
|
||||
}
|
||||
|
||||
this.Map.prototype.getStr=function()
|
||||
{
|
||||
//return a string containing the map with tile graphics, ready to be pasted in a wrapper
|
||||
var str='';
|
||||
var size=16;
|
||||
for (var y=0;y<this.h;y++){for (var x=0;x<this.w;x++){
|
||||
var room=this.getRoom(x,y);
|
||||
//var opacity=Math.max(0.1,room.tiles[this.getRoomTile(room,x,y)].score);
|
||||
var opacity=1;
|
||||
var title='void';
|
||||
var pic=this.getPic(x,y);
|
||||
if (room!=-1)
|
||||
{
|
||||
/*
|
||||
opacity=Math.max(0.1,1-room.gen/5);
|
||||
if (room.hidden) opacity=0;
|
||||
if (this.data[x][y][0]==TILE_ENTRANCE || this.data[x][y][0]==TILE_EXIT) opacity=1;
|
||||
*/
|
||||
if (room.hidden) pic=[0,0];
|
||||
title=(room.corridor?'corridor':'room')+' '+room.id+' | depth : '+room.gen+' | children : '+room.children.length;
|
||||
}
|
||||
str+='<div style="opacity:'+opacity+';width:'+size+'px;height:'+size+'px;position:absolute;left:'+(x*size)+'px;top:'+(y*size)+'px;display:block;padding:0px;margin:0px;background:#'+colors[this.data[x][y][0]]+' url(img/dungeonTiles.png) '+(-pic[0]*16)+'px '+(-pic[1]*16)+'px;color:#999;" title="'+title+'"></div>';
|
||||
}
|
||||
str+='<br>';
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
6
ajax.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
function ajax(url,callback){
|
||||
var ajaxRequest;
|
||||
try{ajaxRequest = new XMLHttpRequest();} catch (e){try{ajaxRequest=new ActiveXObject('Msxml2.XMLHTTP');} catch (e) {try{ajaxRequest=new ActiveXObject('Microsoft.XMLHTTP');} catch (e){alert("Something broke!");return false;}}}
|
||||
if (callback){ajaxRequest.onreadystatechange=function(){if(ajaxRequest.readyState==4){callback(ajaxRequest.responseText);}}}
|
||||
ajaxRequest.open('GET',url+'&nocache='+(new Date().getTime()),true);ajaxRequest.send(null);
|
||||
}
|
142
base64.js
Normal file
|
@ -0,0 +1,142 @@
|
|||
/**
|
||||
*
|
||||
* Base64 encode / decode
|
||||
* http://www.webtoolkit.info/
|
||||
*
|
||||
**/
|
||||
|
||||
var Base64 = {
|
||||
|
||||
// private property
|
||||
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
||||
|
||||
// public method for encoding
|
||||
encode : function (input) {
|
||||
var output = "";
|
||||
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
|
||||
input = Base64._utf8_encode(input);
|
||||
|
||||
while (i < input.length) {
|
||||
|
||||
chr1 = input.charCodeAt(i++);
|
||||
chr2 = input.charCodeAt(i++);
|
||||
chr3 = input.charCodeAt(i++);
|
||||
|
||||
enc1 = chr1 >> 2;
|
||||
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
||||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||
enc4 = chr3 & 63;
|
||||
|
||||
if (isNaN(chr2)) {
|
||||
enc3 = enc4 = 64;
|
||||
} else if (isNaN(chr3)) {
|
||||
enc4 = 64;
|
||||
}
|
||||
|
||||
output = output +
|
||||
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
|
||||
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
// public method for decoding
|
||||
decode : function (input) {
|
||||
var output = "";
|
||||
var chr1, chr2, chr3;
|
||||
var enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
|
||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
||||
|
||||
while (i < input.length) {
|
||||
|
||||
enc1 = this._keyStr.indexOf(input.charAt(i++));
|
||||
enc2 = this._keyStr.indexOf(input.charAt(i++));
|
||||
enc3 = this._keyStr.indexOf(input.charAt(i++));
|
||||
enc4 = this._keyStr.indexOf(input.charAt(i++));
|
||||
|
||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||
chr3 = ((enc3 & 3) << 6) | enc4;
|
||||
|
||||
output = output + String.fromCharCode(chr1);
|
||||
|
||||
if (enc3 != 64) {
|
||||
output = output + String.fromCharCode(chr2);
|
||||
}
|
||||
if (enc4 != 64) {
|
||||
output = output + String.fromCharCode(chr3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
output = Base64._utf8_decode(output);
|
||||
|
||||
return output;
|
||||
|
||||
},
|
||||
|
||||
// private method for UTF-8 encoding
|
||||
_utf8_encode : function (string) {
|
||||
string = string.replace(/\r\n/g,"\n");
|
||||
var utftext = "";
|
||||
|
||||
for (var n = 0; n < string.length; n++) {
|
||||
|
||||
var c = string.charCodeAt(n);
|
||||
|
||||
if (c < 128) {
|
||||
utftext += String.fromCharCode(c);
|
||||
}
|
||||
else if((c > 127) && (c < 2048)) {
|
||||
utftext += String.fromCharCode((c >> 6) | 192);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
else {
|
||||
utftext += String.fromCharCode((c >> 12) | 224);
|
||||
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return utftext;
|
||||
},
|
||||
|
||||
// private method for UTF-8 decoding
|
||||
_utf8_decode : function (utftext) {
|
||||
var string = "";
|
||||
var i = 0;
|
||||
var c = c1 = c2 = 0;
|
||||
|
||||
while ( i < utftext.length ) {
|
||||
|
||||
c = utftext.charCodeAt(i);
|
||||
|
||||
if (c < 128) {
|
||||
string += String.fromCharCode(c);
|
||||
i++;
|
||||
}
|
||||
else if((c > 191) && (c < 224)) {
|
||||
c2 = utftext.charCodeAt(i+1);
|
||||
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
||||
i += 2;
|
||||
}
|
||||
else {
|
||||
c2 = utftext.charCodeAt(i+1);
|
||||
c3 = utftext.charCodeAt(i+2);
|
||||
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
||||
i += 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
}
|
1136
dungeons.js
Normal file
BIN
favicon.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
img/aqworldsbanner.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
img/bgBlue.jpg
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
img/blackGradient.png
Normal file
After Width: | Height: | Size: 561 B |
BIN
img/buttonTile.jpg
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
img/control.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
img/cursor.png
Normal file
After Width: | Height: | Size: 335 B |
BIN
img/darkNoise.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
img/dungeonIcons.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
img/dungeonOverlay.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
img/dungeonTiles.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
img/empty.png
Normal file
After Width: | Height: | Size: 95 B |
BIN
img/goldCookie.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
img/hpBar.png
Normal file
After Width: | Height: | Size: 781 B |
BIN
img/hpmBar.png
Normal file
After Width: | Height: | Size: 778 B |
BIN
img/icons.png
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
img/imperfectCookie.png
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
img/infoBG.png
Normal file
After Width: | Height: | Size: 94 B |
BIN
img/infoBGfade.png
Normal file
After Width: | Height: | Size: 276 B |
BIN
img/mapBG.jpg
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
img/money.png
Normal file
After Width: | Height: | Size: 280 B |
BIN
img/panelHorizontal.png
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
img/panelVertical.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
img/perfectCookie.png
Normal file
After Width: | Height: | Size: 96 KiB |
BIN
img/smallCookies.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
img/storeTile.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
img/timerBars.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
img/upgradeFrame.png
Normal file
After Width: | Height: | Size: 880 B |
2016
minigameGarden.js
|
@ -1,500 +0,0 @@
|
|||
var M={};
|
||||
M.parent=Game.Objects['Wizard tower'];
|
||||
M.parent.minigame=M;
|
||||
M.launch=function()
|
||||
{
|
||||
var M=this;
|
||||
M.name=M.parent.minigameName;
|
||||
M.init=function(div)
|
||||
{
|
||||
//populate div with html and initialize values
|
||||
|
||||
M.spells={
|
||||
'conjure baked goods':{
|
||||
name:'Conjure Baked Goods',
|
||||
desc:'Summon half an hour worth of your CpS, capped at 15% of your cookies owned.',
|
||||
failDesc:'Trigger a 15-minute clot and lose 15 minutes of CpS.',
|
||||
icon:[21,11],
|
||||
costMin:2,
|
||||
costPercent:0.4,
|
||||
win:function()
|
||||
{
|
||||
var val=Math.max(7,Math.min(Game.cookies*0.15,Game.cookiesPs*60*30));
|
||||
Game.Earn(val);
|
||||
Game.Notify('Conjure baked goods!','You magic <b>'+Beautify(val)+' cookie'+(val==1?'':'s')+'</b> out of thin air.',[21,11],6);
|
||||
Game.Popup('<div style="font-size:80%;">+'+Beautify(val)+' cookie'+(val==1?'':'s')+'!</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
fail:function()
|
||||
{
|
||||
var buff=Game.gainBuff('clot',60*15,0.5);
|
||||
var val=Math.min(Game.cookies*0.15,Game.cookiesPs*60*15)+13;
|
||||
val=Math.min(Game.cookies,val);
|
||||
Game.Spend(val);
|
||||
Game.Notify(buff.name,buff.desc,buff.icon,6);
|
||||
Game.Popup('<div style="font-size:80%;">Backfire!<br>Summoning failed! Lost '+Beautify(val)+' cookie'+(val==1?'':'s')+'!</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
},
|
||||
'hand of fate':{
|
||||
name:'Force the Hand of Fate',
|
||||
desc:'Summon a random golden cookie. Each existing golden cookie makes this spell +15% more likely to backfire.',
|
||||
failDesc:'Summon an unlucky wrath cookie.',
|
||||
icon:[22,11],
|
||||
costMin:10,
|
||||
costPercent:0.6,
|
||||
failFunc:function(fail)
|
||||
{
|
||||
return fail+0.15*Game.shimmerTypes['golden'].n;
|
||||
},
|
||||
win:function()
|
||||
{
|
||||
var newShimmer=new Game.shimmer('golden',{noWrath:true});
|
||||
var choices=[];
|
||||
choices.push('frenzy','multiply cookies');
|
||||
if (!Game.hasBuff('Dragonflight')) choices.push('click frenzy');
|
||||
if (Math.random()<0.1) choices.push('chain cookie','cookie storm','blab');
|
||||
if (Game.BuildingsOwned>=10 && Math.random()<0.25) choices.push('building special');
|
||||
//if (Math.random()<0.2) choices.push('clot','cursed finger','ruin cookies');
|
||||
if (Math.random()<0.15) choices=['cookie storm drop'];
|
||||
if (Math.random()<0.0001) choices.push('free sugar lump');
|
||||
newShimmer.force=choose(choices);
|
||||
if (newShimmer.force=='cookie storm drop')
|
||||
{
|
||||
newShimmer.sizeMult=Math.random()*0.75+0.25;
|
||||
}
|
||||
Game.Popup('<div style="font-size:80%;">Promising fate!</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
fail:function()
|
||||
{
|
||||
var newShimmer=new Game.shimmer('golden',{wrath:true});
|
||||
var choices=[];
|
||||
choices.push('clot','ruin cookies');
|
||||
if (Math.random()<0.1) choices.push('cursed finger','blood frenzy');
|
||||
if (Math.random()<0.003) choices.push('free sugar lump');
|
||||
if (Math.random()<0.1) choices=['blab'];
|
||||
newShimmer.force=choose(choices);
|
||||
Game.Popup('<div style="font-size:80%;">Backfire!<br>Sinister fate!</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
},
|
||||
'stretch time':{
|
||||
name:'Stretch Time',
|
||||
desc:'All active buffs gain 10% more time (up to 5 more minutes).',
|
||||
failDesc:'All active buffs are shortened by 20% (up to 10 minutes shorter).',
|
||||
icon:[23,11],
|
||||
costMin:8,
|
||||
costPercent:0.2,
|
||||
win:function()
|
||||
{
|
||||
var changed=0;
|
||||
for (var i in Game.buffs)
|
||||
{
|
||||
var me=Game.buffs[i];
|
||||
var gain=Math.min(Game.fps*60*5,me.maxTime*0.1);
|
||||
me.maxTime+=gain;
|
||||
me.time+=gain;
|
||||
changed++;
|
||||
}
|
||||
if (changed==0){Game.Popup('<div style="font-size:80%;">No buffs to alter!</div>',Game.mouseX,Game.mouseY);return -1;}
|
||||
Game.Popup('<div style="font-size:80%;">Zap! Buffs lengthened.</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
fail:function()
|
||||
{
|
||||
var changed=0;
|
||||
for (var i in Game.buffs)
|
||||
{
|
||||
var me=Game.buffs[i];
|
||||
var loss=Math.min(Game.fps*60*10,me.time*0.2);
|
||||
me.time-=loss;
|
||||
me.time=Math.max(me.time,0);
|
||||
changed++;
|
||||
}
|
||||
if (changed==0){Game.Popup('<div style="font-size:80%;">No buffs to alter!</div>',Game.mouseX,Game.mouseY);return -1;}
|
||||
Game.Popup('<div style="font-size:80%;">Backfire!<br>Fizz! Buffs shortened.</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
},
|
||||
'spontaneous edifice':{
|
||||
name:'Spontaneous Edifice',
|
||||
desc:'The spell picks a random building you could afford if you had twice your current cookies, and gives it to you for free. The building selected must be under 400, and cannot be your most-built one (unless it is your only one).',
|
||||
failDesc:'Lose a random building.',
|
||||
icon:[24,11],
|
||||
costMin:20,
|
||||
costPercent:0.75,
|
||||
win:function()
|
||||
{
|
||||
var buildings=[];
|
||||
var max=0;
|
||||
var n=0;
|
||||
for (var i in Game.Objects)
|
||||
{
|
||||
if (Game.Objects[i].amount>max) max=Game.Objects[i].amount;
|
||||
if (Game.Objects[i].amount>0) n++;
|
||||
}
|
||||
for (var i in Game.Objects)
|
||||
{if ((Game.Objects[i].amount<max || n==1) && Game.Objects[i].getPrice()<=Game.cookies*2 && Game.Objects[i].amount<400) buildings.push(Game.Objects[i]);}
|
||||
if (buildings.length==0){Game.Popup('<div style="font-size:80%;">No buildings to improve!</div>',Game.mouseX,Game.mouseY);return -1;}
|
||||
var building=choose(buildings);
|
||||
building.buyFree(1);
|
||||
Game.Popup('<div style="font-size:80%;">A new '+building.single+'<br>bursts out of the ground.</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
fail:function()
|
||||
{
|
||||
if (Game.BuildingsOwned==0){Game.Popup('<div style="font-size:80%;">Backfired, but no buildings to destroy!</div>',Game.mouseX,Game.mouseY);return -1;}
|
||||
var buildings=[];
|
||||
for (var i in Game.Objects)
|
||||
{if (Game.Objects[i].amount>0) buildings.push(Game.Objects[i]);}
|
||||
var building=choose(buildings);
|
||||
building.sacrifice(1);
|
||||
Game.Popup('<div style="font-size:80%;">Backfire!<br>One of your '+building.plural+'<br>disappears in a puff of smoke.</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
},
|
||||
'haggler\'s charm':{
|
||||
name:'Haggler\'s Charm',
|
||||
desc:'Upgrades are 2% cheaper for 1 minute.',
|
||||
failDesc:'Upgrades are 2% more expensive for an hour.<q>What\'s that spell? Loadsamoney!</q>',
|
||||
icon:[25,11],
|
||||
costMin:10,
|
||||
costPercent:0.1,
|
||||
win:function()
|
||||
{
|
||||
Game.killBuff('Haggler\'s misery');
|
||||
var buff=Game.gainBuff('haggler luck',60,2);
|
||||
Game.Popup('<div style="font-size:80%;">Upgrades are cheaper!</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
fail:function()
|
||||
{
|
||||
Game.killBuff('Haggler\'s luck');
|
||||
var buff=Game.gainBuff('haggler misery',60*60,2);
|
||||
Game.Popup('<div style="font-size:80%;">Backfire!<br>Upgrades are pricier!</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
},
|
||||
'summon crafty pixies':{
|
||||
name:'Summon Crafty Pixies',
|
||||
desc:'Buildings are 2% cheaper for 1 minute.',
|
||||
failDesc:'Buildings are 2% more expensive for an hour.',
|
||||
icon:[26,11],
|
||||
costMin:10,
|
||||
costPercent:0.2,
|
||||
win:function()
|
||||
{
|
||||
Game.killBuff('Nasty goblins');
|
||||
var buff=Game.gainBuff('pixie luck',60,2);
|
||||
Game.Popup('<div style="font-size:80%;">Crafty pixies!<br>Buildings are cheaper!</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
fail:function()
|
||||
{
|
||||
Game.killBuff('Crafty pixies');
|
||||
var buff=Game.gainBuff('pixie misery',60*60,2);
|
||||
Game.Popup('<div style="font-size:80%;">Backfire!<br>Nasty goblins!<br>Buildings are pricier!</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
},
|
||||
'gambler\'s fever dream':{
|
||||
name:'Gambler\'s Fever Dream',
|
||||
desc:'Cast a random spell at half the magic cost, with twice the chance of backfiring.',
|
||||
icon:[27,11],
|
||||
costMin:3,
|
||||
costPercent:0.05,
|
||||
win:function()
|
||||
{
|
||||
var spells=[];
|
||||
var selfCost=M.getSpellCost(M.spells['gambler\'s fever dream']);
|
||||
for (var i in M.spells)
|
||||
{if (i!='gambler\'s fever dream' && (M.magic-selfCost)>=M.getSpellCost(M.spells[i])*0.5) spells.push(M.spells[i]);}
|
||||
if (spells.length==0){Game.Popup('<div style="font-size:80%;">No eligible spells!</div>',Game.mouseX,Game.mouseY);return -1;}
|
||||
var spell=choose(spells);
|
||||
var cost=M.getSpellCost(spell)*0.5;
|
||||
setTimeout(function(){
|
||||
var out=M.castSpell(spell,{cost:cost,failChanceMax:0.5,passthrough:true});
|
||||
if (!out)
|
||||
{
|
||||
M.magic+=selfCost;
|
||||
setTimeout(function(){
|
||||
Game.Popup('<div style="font-size:80%;">That\'s too bad!<br>Magic refunded.</div>',Game.mouseX,Game.mouseY);
|
||||
},1500);
|
||||
}
|
||||
},1000);
|
||||
Game.Popup('<div style="font-size:80%;">Casting '+spell.name+'<br>for '+Beautify(cost)+' magic...</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
},
|
||||
'resurrect abomination':{
|
||||
name:'Resurrect Abomination',
|
||||
desc:'Instantly summon a wrinkler if conditions are fulfilled.',
|
||||
failDesc:'Pop one of your wrinklers.',
|
||||
icon:[28,11],
|
||||
costMin:20,
|
||||
costPercent:0.1,
|
||||
win:function()
|
||||
{
|
||||
var out=Game.SpawnWrinkler();
|
||||
if (!out){Game.Popup('<div style="font-size:80%;">Unable to spawn a wrinkler!</div>',Game.mouseX,Game.mouseY);return -1;}
|
||||
Game.Popup('<div style="font-size:80%;">Rise, my precious!</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
fail:function()
|
||||
{
|
||||
var out=Game.PopRandomWrinkler();
|
||||
if (!out){Game.Popup('<div style="font-size:80%;">Backfire!<br>But no wrinkler was harmed.</div>',Game.mouseX,Game.mouseY);return -1;}
|
||||
Game.Popup('<div style="font-size:80%;">Backfire!<br>So long, ugly...</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
},
|
||||
'diminish ineptitude':{
|
||||
name:'Diminish Ineptitude',
|
||||
desc:'Spells backfire 10 times less for the next 5 minutes.',
|
||||
failDesc:'Spells backfire 5 times more for the next 10 minutes.',
|
||||
icon:[29,11],
|
||||
costMin:5,
|
||||
costPercent:0.2,
|
||||
win:function()
|
||||
{
|
||||
Game.killBuff('Magic inept');
|
||||
var buff=Game.gainBuff('magic adept',5*60,10);
|
||||
Game.Popup('<div style="font-size:80%;">Ineptitude diminished!</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
fail:function()
|
||||
{
|
||||
Game.killBuff('Magic adept');
|
||||
var buff=Game.gainBuff('magic inept',10*60,5);
|
||||
Game.Popup('<div style="font-size:80%;">Backfire!<br>Ineptitude magnified!</div>',Game.mouseX,Game.mouseY);
|
||||
},
|
||||
},
|
||||
};
|
||||
M.spellsById=[];var n=0;
|
||||
for (var i in M.spells){M.spells[i].id=n;M.spellsById[n]=M.spells[i];n++;}
|
||||
|
||||
|
||||
M.computeMagicM=function()
|
||||
{
|
||||
var towers=Math.max(M.parent.amount,1);
|
||||
var lvl=Math.max(M.parent.level,1);
|
||||
M.magicM=Math.floor(4+Math.pow(towers,0.6)+Math.log((towers+(lvl-1)*10)/15+1)*15);
|
||||
//old formula :
|
||||
/*
|
||||
M.magicM=8+Math.min(M.parent.amount,M.parent.level*5)+Math.ceil(M.parent.amount/10);
|
||||
if (M.magicM>200)
|
||||
{
|
||||
//diminishing returns starting at 200, being 5% as fast by 400
|
||||
var x=M.magicM;
|
||||
var top=x-200;
|
||||
top/=200;
|
||||
var top2=top;
|
||||
top*=(1-top/2);
|
||||
if (top2>=1) top=0.5;
|
||||
top=top*0.95+top2*0.05;
|
||||
top*=200;
|
||||
x=top+200;
|
||||
M.magicM=x;
|
||||
}
|
||||
*/
|
||||
M.magic=Math.min(M.magicM,M.magic);
|
||||
}
|
||||
|
||||
M.getFailChance=function(spell)
|
||||
{
|
||||
var failChance=0.15;
|
||||
if (Game.hasBuff('Magic adept')) failChance*=0.1;
|
||||
if (Game.hasBuff('Magic inept')) failChance*=5;
|
||||
if (spell.failFunc) failChance=spell.failFunc(failChance);
|
||||
return failChance;
|
||||
}
|
||||
|
||||
M.castSpell=function(spell,obj)
|
||||
{
|
||||
var obj=obj||{};
|
||||
var out=0;
|
||||
var cost=0;
|
||||
var fail=false;
|
||||
if (typeof obj.cost!=='undefined') cost=obj.cost; else cost=M.getSpellCost(spell);
|
||||
if (M.magic<cost) return false;
|
||||
var failChance=M.getFailChance(spell);
|
||||
if (typeof obj.failChanceSet!=='undefined') failChance=obj.failChanceSet;
|
||||
if (typeof obj.failChanceAdd!=='undefined') failChance+=obj.failChanceAdd;
|
||||
if (typeof obj.failChanceMult!=='undefined') failChance*=obj.failChanceMult;
|
||||
if (typeof obj.failChanceMax!=='undefined') failChance=Math.max(failChance,obj.failChanceMax);
|
||||
Math.seedrandom(Game.seed+'/'+M.spellsCastTotal);
|
||||
if (!spell.fail || Math.random()<(1-failChance)) {out=spell.win();} else {fail=true;out=spell.fail();}
|
||||
Math.seedrandom();
|
||||
if (out!=-1)
|
||||
{
|
||||
if (!spell.passthrough && !obj.passthrough)
|
||||
{
|
||||
M.spellsCast++;
|
||||
M.spellsCastTotal++;
|
||||
if (M.spellsCastTotal>=9) Game.Win('Bibbidi-bobbidi-boo');
|
||||
if (M.spellsCastTotal>=99) Game.Win('I\'m the wiz');
|
||||
if (M.spellsCastTotal>=999) Game.Win('A wizard is you');
|
||||
}
|
||||
|
||||
M.magic-=cost;
|
||||
M.magic=Math.max(0,M.magic);
|
||||
|
||||
var rect=l('grimoireSpell'+spell.id).getBoundingClientRect();
|
||||
Game.SparkleAt((rect.left+rect.right)/2,(rect.top+rect.bottom)/2-24);
|
||||
|
||||
if (fail) PlaySound('snd/spellFail.mp3',0.75); else PlaySound('snd/spell.mp3',0.75);
|
||||
return true;
|
||||
}
|
||||
PlaySound('snd/spellFail.mp3',0.75);
|
||||
return false;
|
||||
}
|
||||
|
||||
M.getSpellCost=function(spell)
|
||||
{
|
||||
var out=spell.costMin;
|
||||
if (spell.costPercent) out+=M.magicM*spell.costPercent;
|
||||
return Math.floor(out);
|
||||
}
|
||||
M.getSpellCostBreakdown=function(spell)
|
||||
{
|
||||
var str='';
|
||||
if (spell.costPercent) str+=Beautify(spell.costMin)+' magic +'+Beautify(Math.ceil(spell.costPercent*100))+'% of max magic';
|
||||
else str+=Beautify(spell.costMin)+' magic';
|
||||
return str;
|
||||
}
|
||||
|
||||
M.spellTooltip=function(id)
|
||||
{
|
||||
return function(){
|
||||
var me=M.spellsById[id];
|
||||
me.icon=me.icon||[28,12];
|
||||
var cost=Beautify(M.getSpellCost(me));
|
||||
var costBreakdown=M.getSpellCostBreakdown(me);
|
||||
if (cost!=costBreakdown) costBreakdown=' <small>('+costBreakdown+')</small>'; else costBreakdown='';
|
||||
var backfire=M.getFailChance(me);
|
||||
var str='<div style="padding:8px 4px;min-width:350px;">'+
|
||||
'<div class="icon" style="float:left;margin-left:-8px;margin-top:-8px;background-position:'+(-me.icon[0]*48)+'px '+(-me.icon[1]*48)+'px;"></div>'+
|
||||
'<div class="name">'+me.name+'</div>'+
|
||||
'<div>Magic cost : <b style="color:#'+(cost<=M.magic?'6f6':'f66')+';">'+cost+'</b>'+costBreakdown+'</div>'+
|
||||
(me.fail?('<div><small>Chance to backfire : <b style="color:#f66">'+Math.ceil(100*backfire)+'%</b></small></div>'):'')+
|
||||
'<div class="line"></div><div class="description"><b>Effect :</b> '+me.desc+(me.failDesc?('<div style="height:8px;"></div><b>Backfire :</b> '+me.failDesc):'')+'</div></div>';
|
||||
return str;
|
||||
};
|
||||
}
|
||||
|
||||
var str='';
|
||||
str+='<style>'+
|
||||
'#grimoireBG{background:url(img/shadedBorders.png),url(img/grimoireBG.png);background-size:100% 100%,auto;position:absolute;left:0px;right:0px;top:0px;bottom:16px;}'+
|
||||
'#grimoireContent{position:relative;box-sizing:border-box;padding:4px 24px;}'+
|
||||
'#grimoireBar{max-width:95%;margin:4px auto;height:16px;}'+
|
||||
'#grimoireBarFull{transform:scale(1,2);transform-origin:50% 0;height:50%;}'+
|
||||
'#grimoireBarText{transform:scale(1,0.8);width:100%;position:absolute;left:0px;top:0px;text-align:center;color:#fff;text-shadow:-1px 1px #000,0px 0px 4px #000,0px 0px 6px #000;margin-top:2px;}'+
|
||||
'#grimoireSpells{text-align:center;width:100%;padding:8px;box-sizing:border-box;}'+
|
||||
'.grimoireIcon{pointer-events:none;margin:2px 6px 0px 6px;width:48px;height:48px;opacity:0.8;position:relative;}'+
|
||||
'.grimoirePrice{pointer-events:none;}'+
|
||||
'.grimoireSpell{box-shadow:4px 4px 4px #000;cursor:pointer;position:relative;color:#f33;opacity:0.8;text-shadow:0px 0px 4px #000,0px 0px 6px #000;font-weight:bold;font-size:12px;display:inline-block;width:60px;height:74px;background:url(img/spellBG.png);}'+
|
||||
'.grimoireSpell.ready{color:rgba(255,255,255,0.8);opacity:1;}'+
|
||||
'.grimoireSpell.ready:hover{color:#fff;}'+
|
||||
'.grimoireSpell:hover{box-shadow:6px 6px 6px 2px #000;z-index:1000000001;top:-1px;}'+
|
||||
'.grimoireSpell:active{top:1px;}'+
|
||||
'.grimoireSpell.ready .grimoireIcon{opacity:1;}'+
|
||||
'.grimoireSpell:hover{background-position:0px -74px;} .grimoireSpell:active{background-position:0px 74px;}'+
|
||||
'.grimoireSpell:nth-child(4n+1){background-position:-60px 0px;} .grimoireSpell:nth-child(4n+1):hover{background-position:-60px -74px;} .grimoireSpell:nth-child(4n+1):active{background-position:-60px 74px;}'+
|
||||
'.grimoireSpell:nth-child(4n+2){background-position:-120px 0px;} .grimoireSpell:nth-child(4n+2):hover{background-position:-120px -74px;} .grimoireSpell:nth-child(4n+2):active{background-position:-120px 74px;}'+
|
||||
'.grimoireSpell:nth-child(4n+3){background-position:-180px 0px;} .grimoireSpell:nth-child(4n+3):hover{background-position:-180px -74px;} .grimoireSpell:nth-child(4n+3):active{background-position:-180px 74px;}'+
|
||||
|
||||
'.grimoireSpell:hover .grimoireIcon{top:-1px;}'+
|
||||
'.grimoireSpell.ready:hover .grimoireIcon{animation-name:bounce;animation-iteration-count:infinite;animation-duration:0.8s;}'+
|
||||
|
||||
'#grimoireLumpRefill{cursor:pointer;width:48px;height:48px;position:absolute;left:-40px;top:-17px;transform:scale(0.5);z-index:1000;transition:transform 0.05s;}'+
|
||||
'#grimoireLumpRefill:hover{transform:scale(1);}'+
|
||||
'#grimoireLumpRefill:active{transform:scale(0.4);}'+
|
||||
|
||||
'#grimoireInfo{text-align:center;font-size:11px;margin-top:12px;color:rgba(255,255,255,0.75);text-shadow:-1px 1px 0px #000;}'+
|
||||
'</style>';
|
||||
str+='<div id="grimoireBG"></div>';
|
||||
str+='<div id="grimoireContent">';
|
||||
str+='<div id="grimoireSpells">';//did you know adding class="shadowFilter" to this cancels the "z-index:1000000001" that displays the selected spell above the tooltip? stacking orders are silly https://philipwalton.com/articles/what-no-one-told-you-about-z-index/
|
||||
for (var i in M.spells)
|
||||
{
|
||||
var me=M.spells[i];
|
||||
var icon=me.icon||[28,12];
|
||||
str+='<div class="grimoireSpell titleFont" id="grimoireSpell'+me.id+'" '+Game.getDynamicTooltip('Game.ObjectsById['+M.parent.id+'].minigame.spellTooltip('+me.id+')','this')+'><div class="usesIcon shadowFilter grimoireIcon" style="background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div><div class="grimoirePrice" id="grimoirePrice'+me.id+'">-</div></div>';
|
||||
}
|
||||
str+='</div>';
|
||||
var icon=[29,14];
|
||||
str+='<div id="grimoireBar" class="smallFramed meterContainer"><div '+Game.getTooltip('<div style="padding:8px;width:300px;font-size:11px;text-align:center;">Click to refill <b>100 units</b> of your magic meter<br>for <span class="price lump">1 sugar lump</span>.</div>')+' id="grimoireLumpRefill" class="usesIcon shadowFilter" style="background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div><div id="grimoireBarFull" class="meter filling"></div><div id="grimoireBarText" class="titleFont"></div><div '+Game.getTooltip('<div style="padding:8px;width:300px;font-size:11px;text-align:center;">This is your magic meter. Each spell costs magic to use.<div class="line"></div>Your maximum amount of magic varies depending on your amount of <b>Wizard towers</b>, and their level.<div class="line"></div>Magic refills over time. The lower your magic meter, the slower it refills.</div>')+' style="position:absolute;left:0px;top:0px;right:0px;bottom:0px;"></div></div>';
|
||||
str+='<div id="grimoireInfo"></div>';
|
||||
str+='</div>';
|
||||
div.innerHTML=str;
|
||||
M.magicBarL=l('grimoireBar');
|
||||
M.magicBarFullL=l('grimoireBarFull');
|
||||
M.magicBarTextL=l('grimoireBarText');
|
||||
M.lumpRefill=l('grimoireLumpRefill');
|
||||
M.infoL=l('grimoireInfo');
|
||||
for (var i in M.spells)
|
||||
{
|
||||
var me=M.spells[i];
|
||||
AddEvent(l('grimoireSpell'+me.id),'click',function(spell){return function(){PlaySound('snd/tick.mp3');M.castSpell(spell);}}(me));
|
||||
}
|
||||
|
||||
AddEvent(M.lumpRefill,'click',function(){
|
||||
if (Game.lumps>=1 && M.magic<M.magicM)
|
||||
{
|
||||
M.magic+=100;
|
||||
M.magic=Math.min(M.magic,M.magicM);
|
||||
Game.lumps-=1;
|
||||
PlaySound('snd/pop'+Math.floor(Math.random()*3+1)+'.mp3',0.75);
|
||||
}
|
||||
});
|
||||
|
||||
M.computeMagicM();
|
||||
M.magic=M.magicM;
|
||||
M.spellsCast=0;
|
||||
M.spellsCastTotal=0;
|
||||
|
||||
//M.parent.switchMinigame(1);
|
||||
}
|
||||
M.save=function()
|
||||
{
|
||||
//output cannot use ",", ";" or "|"
|
||||
var str=''+
|
||||
parseFloat(M.magic)+' '+
|
||||
parseInt(Math.floor(M.spellsCast))+' '+
|
||||
parseInt(Math.floor(M.spellsCastTotal))
|
||||
;
|
||||
return str;
|
||||
}
|
||||
M.load=function(str)
|
||||
{
|
||||
//interpret str; called after .init
|
||||
//note : not actually called in the Game's load; see "minigameSave" in main.js
|
||||
if (!str) return false;
|
||||
var i=0;
|
||||
var spl=str.split(' ');
|
||||
M.computeMagicM();
|
||||
M.magic=parseFloat(spl[i++]||M.magicM);
|
||||
M.spellsCast=parseInt(spl[i++]||0);
|
||||
M.spellsCastTotal=parseInt(spl[i++]||0);
|
||||
}
|
||||
M.reset=function()
|
||||
{
|
||||
M.computeMagicM();
|
||||
M.magic=M.magicM;
|
||||
M.spellsCast=0;
|
||||
}
|
||||
M.logic=function()
|
||||
{
|
||||
//run each frame
|
||||
if (Game.T%5==0) {M.computeMagicM();}
|
||||
M.magicPS=Math.max(0.002,Math.pow(M.magic/Math.max(M.magicM,100),0.5))*0.002;
|
||||
M.magic+=M.magicPS;
|
||||
M.magic=Math.min(M.magic,M.magicM);
|
||||
if (Game.T%5==0)
|
||||
{
|
||||
for (var i in M.spells)
|
||||
{
|
||||
var me=M.spells[i];
|
||||
var cost=M.getSpellCost(me);
|
||||
l('grimoirePrice'+me.id).innerHTML=Beautify(cost);
|
||||
if (M.magic<cost) l('grimoireSpell'+me.id).className='grimoireSpell titleFont';
|
||||
else l('grimoireSpell'+me.id).className='grimoireSpell titleFont ready';
|
||||
}
|
||||
}
|
||||
}
|
||||
M.draw=function()
|
||||
{
|
||||
//run each draw frame
|
||||
M.magicBarTextL.innerHTML=Math.min(Math.floor(M.magicM),Beautify(M.magic))+'/'+Beautify(Math.floor(M.magicM))+(M.magic<M.magicM?(' (+'+Beautify((M.magicPS||0)*Game.fps,2)+'/s)'):'');
|
||||
M.magicBarFullL.style.width=((M.magic/M.magicM)*100)+'%';
|
||||
M.magicBarL.style.width=(M.magicM*3)+'px';
|
||||
M.infoL.innerHTML='Spells cast : '+Beautify(M.spellsCast)+' (total : '+Beautify(M.spellsCastTotal)+')';
|
||||
}
|
||||
M.init(l('rowSpecial'+M.parent.id));
|
||||
}
|
||||
var M=0;
|
|
@ -1,500 +0,0 @@
|
|||
var M={};
|
||||
M.parent=Game.Objects['Temple'];
|
||||
M.parent.minigame=M;
|
||||
M.launch=function()
|
||||
{
|
||||
var M=this;
|
||||
M.name=M.parent.minigameName;
|
||||
M.init=function(div)
|
||||
{
|
||||
//populate div with html and initialize values
|
||||
|
||||
M.gods={
|
||||
'asceticism':{
|
||||
name:'Holobore, Spirit of Asceticism',
|
||||
icon:[21,18],
|
||||
desc1:'+15% base CpS.',
|
||||
desc2:'+10% base CpS.',
|
||||
desc3:'+5% base CpS.',
|
||||
descAfter:'If a golden cookie is clicked, this spirit is unslotted and all worship swaps will be used up.',
|
||||
quote:'An immortal life spent focusing on the inner self, away from the distractions of material wealth.',
|
||||
},
|
||||
'decadence':{
|
||||
name:'Vomitrax, Spirit of Decadence',
|
||||
icon:[22,18],
|
||||
desc1:'Golden and wrath cookie effect duration +7%, but buildings grant -7% CpS.',
|
||||
desc2:'Golden and wrath cookie effect duration +5%, but buildings grant -5% CpS.',
|
||||
desc3:'Golden and wrath cookie effect duration +2%, but buildings grant -2% CpS.',
|
||||
quote:'This sleazy spirit revels in the lust for quick easy gain and contempt for the value of steady work.',
|
||||
},
|
||||
'ruin':{
|
||||
name:'Godzamok, Spirit of Ruin',
|
||||
icon:[23,18],
|
||||
descBefore:'Selling buildings triggers a buff boosted by how many buildings were sold.',
|
||||
desc1:'Buff boosts clicks by +1% for every building sold for 10 seconds.',
|
||||
desc2:'Buff boosts clicks by +0.5% for every building sold for 10 seconds.',
|
||||
desc3:'Buff boosts clicks by +0.25% for every building sold for 10 seconds.',
|
||||
quote:'The embodiment of natural disasters. An impenetrable motive drives the devastation caused by this spirit.',
|
||||
},
|
||||
'ages':{
|
||||
name:'Cyclius, Spirit of Ages',
|
||||
icon:[24,18],
|
||||
activeDescFunc:function()
|
||||
{
|
||||
var godLvl=Game.hasGod('ages');
|
||||
var mult=1;
|
||||
if (godLvl==1) mult*=0.15*Math.sin((Date.now()/1000/(60*60*3))*Math.PI*2);
|
||||
else if (godLvl==2) mult*=0.15*Math.sin((Date.now()/1000/(60*60*12))*Math.PI*2);
|
||||
else if (godLvl==3) mult*=0.15*Math.sin((Date.now()/1000/(60*60*24))*Math.PI*2);
|
||||
return 'Current bonus : '+(mult<0?'-':'+')+Beautify(Math.abs(mult)*100,2)+'%.';
|
||||
},
|
||||
descBefore:'CpS bonus fluctuating between +15% and -15% over time.',
|
||||
desc1:'Effect cycles over 3 hours.',
|
||||
desc2:'Effect cycles over 12 hours.',
|
||||
desc3:'Effect cycles over 24 hours.',
|
||||
quote:'This spirit knows about everything you\'ll ever do, and enjoys dispensing a harsh judgement.',
|
||||
},
|
||||
'seasons':{
|
||||
name:'Selebrak, Spirit of Festivities',
|
||||
icon:[25,18],
|
||||
descBefore:'Some seasonal effects are boosted.',
|
||||
desc1:'Large boost. Switching seasons is 100% pricier.',
|
||||
desc2:'Medium boost. Switching seasons is 50% pricier.',
|
||||
desc3:'Small boost. Switching seasons is 25% pricier.',
|
||||
quote:'This is the spirit of merry getaways and regretful Monday mornings.',
|
||||
},
|
||||
'creation':{
|
||||
name:'Dotjeiess, Spirit of Creation',
|
||||
icon:[26,18],
|
||||
desc1:'Buildings are 7% cheaper, but heavenly chips have 30% less effect.',
|
||||
desc2:'Buildings are 5% cheaper, but heavenly chips have 20% less effect.',
|
||||
desc3:'Buildings are 2% cheaper, but heavenly chips have 10% less effect.',
|
||||
quote:'All things that be and ever will be were scripted long ago by this spirit\'s inscrutable tendrils.',
|
||||
},
|
||||
'labor':{
|
||||
name:'Muridal, Spirit of Labor',
|
||||
icon:[27,18],
|
||||
desc1:'Clicks are 15% more powerful, but buildings produce 3% less.',
|
||||
desc2:'Clicks are 10% more powerful, but buildings produce 2% less.',
|
||||
desc3:'Clicks are 5% more powerful, but buildings produce 1% less.',
|
||||
quote:'This spirit enjoys a good cheese after a day of hard work.',
|
||||
},
|
||||
'industry':{
|
||||
name:'Jeremy, Spirit of Industry',
|
||||
icon:[28,18],
|
||||
desc1:'Buildings produce 10% more cookies, but golden and wrath cookies appear 10% less.',
|
||||
desc2:'Buildings produce 6% more cookies, but golden and wrath cookies appear 6% less.',
|
||||
desc3:'Buildings produce 3% more cookies, but golden and wrath cookies appear 3% less.',
|
||||
quote:'While this spirit has many regrets, helping you rule the world through constant industrialization is not one of them.',
|
||||
},
|
||||
'mother':{
|
||||
name:'Mokalsium, Mother Spirit',
|
||||
icon:[29,18],
|
||||
desc1:'Milk is 10% more powerful, but golden and wrath cookies appear 15% less.',
|
||||
desc2:'Milk is 5% more powerful, but golden and wrath cookies appear 10% less.',
|
||||
desc3:'Milk is 3% more powerful, but golden and wrath cookies appear 5% less.',
|
||||
quote:'A caring spirit said to contain itself, inwards infinitely.',
|
||||
},
|
||||
'scorn':{
|
||||
name:'Skruuia, Spirit of Scorn',
|
||||
icon:[21,19],
|
||||
descBefore:'All golden cookies are wrath cookies with a greater chance of a negative effect.',
|
||||
desc1:'Wrinklers appear 150% faster and digest 15% more cookies.',
|
||||
desc2:'Wrinklers appear 100% faster and digest 10% more cookies.',
|
||||
desc3:'Wrinklers appear 50% faster and digest 5% more cookies.',
|
||||
quote:'This spirit enjoys poking foul beasts and watching them squirm, but has no love for its own family.',
|
||||
},
|
||||
'order':{
|
||||
name:'Rigidel, Spirit of Order',
|
||||
icon:[22,19],
|
||||
activeDescFunc:function()
|
||||
{
|
||||
if (Game.BuildingsOwned%10==0) return 'Buildings owned : '+Beautify(Game.BuildingsOwned)+'.<br>Effect is active.';
|
||||
else return 'Buildings owned : '+Beautify(Game.BuildingsOwned)+'.<br>Effect is inactive.';
|
||||
},
|
||||
desc1:'Sugar lumps ripen an hour sooner.',
|
||||
desc2:'Sugar lumps ripen 40 minutes sooner.',
|
||||
desc3:'Sugar lumps ripen 20 minutes sooner.',
|
||||
descAfter:'Effect is only active when your total amount of buildings ends with 0.',
|
||||
quote:'You will find that life gets just a little bit sweeter if you can motivate this spirit with tidy numbers and properly-filled tax returns.',
|
||||
},
|
||||
};
|
||||
M.godsById=[];var n=0;
|
||||
for (var i in M.gods){M.gods[i].id=n;M.gods[i].slot=-1;M.godsById[n]=M.gods[i];n++;}
|
||||
|
||||
|
||||
M.slot=[];
|
||||
M.slot[0]=-1;//diamond socket
|
||||
M.slot[1]=-1;//ruby socket
|
||||
M.slot[2]=-1;//jade socket
|
||||
|
||||
M.slotNames=[
|
||||
'Diamond','Ruby','Jade'
|
||||
];
|
||||
|
||||
M.swaps=3;//swaps left
|
||||
M.swapT=Date.now();//the last time we swapped
|
||||
|
||||
M.lastSwapT=0;//frames since last swap
|
||||
|
||||
M.godTooltip=function(id)
|
||||
{
|
||||
return function(){
|
||||
var me=M.godsById[id];
|
||||
me.icon=me.icon||[0,0];
|
||||
var str='<div style="padding:8px 4px;min-width:350px;">'+
|
||||
'<div class="icon" style="float:left;margin-left:-8px;margin-top:-8px;background-position:'+(-me.icon[0]*48)+'px '+(-me.icon[1]*48)+'px;"></div>'+
|
||||
'<div class="name">'+me.name+'</div>'+
|
||||
'<div class="line"></div><div class="description"><div style="margin:6px 0px;font-weight:bold;">Effects :</div>'+
|
||||
(me.descBefore?('<div class="templeEffect">'+me.descBefore+'</div>'):'')+
|
||||
(me.desc1?('<div class="templeEffect templeEffect1"><div class="usesIcon shadowFilter templeGem templeGem1"></div>'+me.desc1+'</div>'):'')+
|
||||
(me.desc2?('<div class="templeEffect templeEffect2"><div class="usesIcon shadowFilter templeGem templeGem2"></div>'+me.desc2+'</div>'):'')+
|
||||
(me.desc3?('<div class="templeEffect templeEffect3"><div class="usesIcon shadowFilter templeGem templeGem3"></div>'+me.desc3+'</div>'):'')+
|
||||
(me.descAfter?('<div class="templeEffect">'+me.descAfter+'</div>'):'')+
|
||||
(me.quote?('<q>'+me.quote+'</q>'):'')+
|
||||
'</div></div>';
|
||||
return str;
|
||||
};
|
||||
}
|
||||
|
||||
M.slotTooltip=function(id)
|
||||
{
|
||||
return function(){
|
||||
if (M.slot[id]!=-1)
|
||||
{
|
||||
var me=M.godsById[M.slot[id]];
|
||||
me.icon=me.icon||[0,0];
|
||||
}
|
||||
var str='<div style="padding:8px 4px;min-width:350px;">'+
|
||||
(M.slot[id]!=-1?(
|
||||
'<div class="name templeEffect" style="margin-bottom:12px;"><div class="usesIcon shadowFilter templeGem templeGem'+(parseInt(id)+1)+'"></div>'+M.slotNames[id]+' slot</div>'+
|
||||
'<div class="icon" style="float:left;margin-left:-8px;margin-top:-8px;background-position:'+(-me.icon[0]*48)+'px '+(-me.icon[1]*48)+'px;"></div>'+
|
||||
'<div class="name">'+me.name+'</div>'+
|
||||
'<div class="line"></div><div class="description"><div style="margin:6px 0px;font-weight:bold;">Effects :</div>'+
|
||||
(me.activeDescFunc?('<div class="templeEffect templeEffectOn" style="padding:8px 4px;text-align:center;">'+me.activeDescFunc()+'</div>'):'')+
|
||||
(me.descBefore?('<div class="templeEffect">'+me.descBefore+'</div>'):'')+
|
||||
(me.desc1?('<div class="templeEffect templeEffect1'+(me.slot==0?' templeEffectOn':'')+'"><div class="usesIcon shadowFilter templeGem templeGem1"></div>'+me.desc1+'</div>'):'')+
|
||||
(me.desc2?('<div class="templeEffect templeEffect2'+(me.slot==1?' templeEffectOn':'')+'"><div class="usesIcon shadowFilter templeGem templeGem2"></div>'+me.desc2+'</div>'):'')+
|
||||
(me.desc3?('<div class="templeEffect templeEffect3'+(me.slot==2?' templeEffectOn':'')+'"><div class="usesIcon shadowFilter templeGem templeGem3"></div>'+me.desc3+'</div>'):'')+
|
||||
(me.descAfter?('<div class="templeEffect">'+me.descAfter+'</div>'):'')+
|
||||
(me.quote?('<q>'+me.quote+'</q>'):'')+
|
||||
'</div>'
|
||||
):
|
||||
('<div class="name templeEffect"><div class="usesIcon shadowFilter templeGem templeGem'+(parseInt(id)+1)+'"></div>'+M.slotNames[id]+' slot (empty)</div><div class="line"></div><div class="description">'+
|
||||
((M.slotHovered==id && M.dragging)?'Release to assign <b>'+M.dragging.name+'</b> to this slot.':'Drag a spirit onto this slot to assign it.')+
|
||||
'</div>')
|
||||
)+
|
||||
'</div>';
|
||||
return str;
|
||||
};
|
||||
}
|
||||
|
||||
M.useSwap=function(n)
|
||||
{
|
||||
M.swapT=Date.now();
|
||||
M.swaps-=n;
|
||||
if (M.swaps<0) M.swaps=0;
|
||||
}
|
||||
|
||||
M.slotGod=function(god,slot)
|
||||
{
|
||||
if (slot==god.slot) return false;
|
||||
if (slot!=-1 && M.slot[slot]!=-1)
|
||||
{
|
||||
M.godsById[M.slot[slot]].slot=god.slot;//swap
|
||||
M.slot[god.slot]=M.slot[slot];
|
||||
}
|
||||
else if (god.slot!=-1) M.slot[god.slot]=-1;
|
||||
if (slot!=-1) M.slot[slot]=god.id;
|
||||
god.slot=slot;
|
||||
Game.recalculateGains=true;
|
||||
}
|
||||
|
||||
M.dragging=false;
|
||||
M.dragGod=function(what)
|
||||
{
|
||||
M.dragging=what;
|
||||
var div=l('templeGod'+what.id);
|
||||
var box=div.getBoundingClientRect();
|
||||
var box2=l('templeDrag').getBoundingClientRect();
|
||||
div.className='ready templeGod titleFont templeDragged';
|
||||
l('templeDrag').appendChild(div);
|
||||
var x=box.left-box2.left;
|
||||
var y=box.top-box2.top;
|
||||
div.style.transform='translate('+(x)+'px,'+(y)+'px)';
|
||||
l('templeGodPlaceholder'+M.dragging.id).style.display='inline-block';
|
||||
PlaySound('snd/tick.mp3');
|
||||
}
|
||||
M.dropGod=function()
|
||||
{
|
||||
if (!M.dragging) return;
|
||||
var div=l('templeGod'+M.dragging.id);
|
||||
div.className='ready templeGod titleFont';
|
||||
div.style.transform='none';
|
||||
if (M.slotHovered!=-1 && (M.swaps==0 || M.dragging.slot==M.slotHovered))//dropping on a slot but no swaps left, or slot is the same as the original
|
||||
{
|
||||
if (M.dragging.slot!=-1) l('templeSlot'+M.dragging.slot).appendChild(div);
|
||||
else l('templeGodPlaceholder'+(M.dragging.id)).parentNode.insertBefore(div,l('templeGodPlaceholder'+(M.dragging.id)));
|
||||
PlaySound('snd/sell1.mp3',0.75);
|
||||
}
|
||||
else if (M.slotHovered!=-1)//dropping on a slot
|
||||
{
|
||||
M.useSwap(1);
|
||||
M.lastSwapT=0;
|
||||
|
||||
var prev=M.slot[M.slotHovered];//id of the god already in the slot
|
||||
if (prev!=-1)
|
||||
{
|
||||
prev=M.godsById[prev];
|
||||
var prevDiv=l('templeGod'+prev.id);
|
||||
if (M.dragging.slot!=-1)//swap with god's previous slot
|
||||
{
|
||||
l('templeSlot'+M.dragging.slot).appendChild(prevDiv);
|
||||
}
|
||||
else//swap back to roster
|
||||
{
|
||||
var other=l('templeGodPlaceholder'+(prev.id));
|
||||
other.parentNode.insertBefore(prevDiv,other);
|
||||
}
|
||||
}
|
||||
l('templeSlot'+M.slotHovered).appendChild(div);
|
||||
M.slotGod(M.dragging,M.slotHovered);
|
||||
|
||||
PlaySound('snd/tick.mp3');
|
||||
PlaySound('snd/spirit.mp3',0.5);
|
||||
|
||||
var rect=div.getBoundingClientRect();
|
||||
Game.SparkleAt((rect.left+rect.right)/2,(rect.top+rect.bottom)/2-24);
|
||||
}
|
||||
else//dropping back to roster
|
||||
{
|
||||
var other=l('templeGodPlaceholder'+(M.dragging.id));
|
||||
other.parentNode.insertBefore(div,other);
|
||||
other.style.display='none';
|
||||
M.slotGod(M.dragging,-1);
|
||||
PlaySound('snd/sell1.mp3',0.75);
|
||||
}
|
||||
M.dragging=false;
|
||||
}
|
||||
|
||||
M.slotHovered=-1;
|
||||
M.hoverSlot=function(what)
|
||||
{
|
||||
M.slotHovered=what;
|
||||
if (M.dragging)
|
||||
{
|
||||
if (M.slotHovered==-1) l('templeGodPlaceholder'+M.dragging.id).style.display='inline-block';
|
||||
else l('templeGodPlaceholder'+M.dragging.id).style.display='none';
|
||||
PlaySound('snd/clickb'+Math.floor(Math.random()*7+1)+'.mp3',0.75);
|
||||
}
|
||||
}
|
||||
|
||||
//external
|
||||
Game.hasGod=function(what)
|
||||
{
|
||||
var god=M.gods[what];
|
||||
for (var i=0;i<3;i++)
|
||||
{
|
||||
if (M.slot[i]==god.id) return (i+1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Game.forceUnslotGod=function(god)
|
||||
{
|
||||
var god=M.gods[god];
|
||||
if (god.slot==-1) return false;
|
||||
var div=l('templeGod'+god.id);
|
||||
var other=l('templeGodPlaceholder'+(god.id));
|
||||
other.parentNode.insertBefore(div,other);
|
||||
other.style.display='none';
|
||||
M.slotGod(god,-1);
|
||||
return true;
|
||||
}
|
||||
Game.useSwap=M.useSwap;
|
||||
|
||||
|
||||
var str='';
|
||||
str+='<style>'+
|
||||
'#templeBG{background:url(img/shadedBorders.png),url(img/pantheonBG.png);background-size:100% 100%,auto;position:absolute;left:0px;right:0px;top:0px;bottom:16px;}'+
|
||||
'#templeContent{position:relative;box-sizing:border-box;padding:4px 24px;text-align:center;}'+
|
||||
'#templeGods{text-align:center;width:100%;padding:8px;box-sizing:border-box;}'+
|
||||
'.templeIcon{pointer-events:none;margin:12px 6px 0px 6px;width:48px;height:48px;opacity:0.8;position:relative;}'+
|
||||
'.templeSlot .templeIcon{margin:2px 6px 0px 6px;}'+
|
||||
'.templeGod{box-shadow:4px 4px 4px #000;cursor:pointer;position:relative;color:#f33;opacity:0.8;text-shadow:0px 0px 4px #000,0px 0px 6px #000;font-weight:bold;font-size:12px;display:inline-block;width:60px;height:74px;background:url(img/spellBG.png);}'+
|
||||
'.templeGod.ready{color:rgba(255,255,255,0.8);opacity:1;}'+
|
||||
'.templeGod.ready:hover{color:#fff;}'+
|
||||
'.templeGod:hover,.templeDragged{box-shadow:6px 6px 6px 2px #000;z-index:1000000001;top:-1px;}'+
|
||||
'.templeGod:active{top:1px;}'+
|
||||
'.templeGod.ready .templeIcon{opacity:1;}'+
|
||||
'.templeGod:hover{background-position:0px -74px;} .templeGod:active{background-position:0px 74px;}'+
|
||||
'.templeGod1{background-position:-60px 0px;} .templeGod1:hover{background-position:-60px -74px;} .templeGod1:active{background-position:-60px 74px;}'+
|
||||
'.templeGod2{background-position:-120px 0px;} .templeGod2:hover{background-position:-120px -74px;} .templeGod2:active{background-position:-120px 74px;}'+
|
||||
'.templeGod3{background-position:-180px 0px;} .templeGod3:hover{background-position:-180px -74px;} .templeGod3:active{background-position:-180px 74px;}'+
|
||||
|
||||
'.templeGod:hover .templeIcon{top:-1px;}'+
|
||||
'.templeGod.ready:hover .templeIcon{animation-name:bounce;animation-iteration-count:infinite;animation-duration:0.8s;}'+
|
||||
|
||||
'.templeGem{z-index:100;width:24px;height:24px;}'+
|
||||
'.templeEffect{font-weight:bold;font-size:11px;position:relative;margin:0px -12px;padding:4px;padding-left:28px;}'+
|
||||
'.description .templeEffect{border-top:1px solid rgba(255,255,255,0.15);background:linear-gradient(to top,rgba(255,255,255,0.1),rgba(255,255,255,0));}'+
|
||||
'.templeEffect .templeGem{position:absolute;left:0px;top:0px;}'+
|
||||
'.templeEffectOn{text-shadow:0px 0px 6px rgba(255,255,255,0.75);color:#fff;}'+
|
||||
'.templeGod .templeGem{position:absolute;left:18px;bottom:8px;pointer-events:none;}'+
|
||||
'.templeGem1{background-position:-1104px -720px;}'+
|
||||
'.templeGem2{background-position:-1128px -720px;}'+
|
||||
'.templeGem3{background-position:-1104px -744px;}'+
|
||||
|
||||
'.templeSlot .templeGod,.templeSlot .templeGod:hover,.templeSlot .templeGod:active{background:none;}'+
|
||||
|
||||
'.templeSlotDrag{position:absolute;left:0px;top:0px;right:0px;bottom:0px;background:#999;opacity:0;cursor:pointer;}'+
|
||||
|
||||
'#templeDrag{position:absolute;left:0px;top:0px;z-index:1000000000000;}'+
|
||||
'.templeGod{transition:transform 0.1s;}'+
|
||||
'#templeDrag .templeGod{position:absolute;left:0px;top:0px;}'+
|
||||
'.templeDragged{pointer-events:none;}'+
|
||||
|
||||
'.templeGodPlaceholder{background:red;opacity:0;display:none;width:60px;height:74px;}'+
|
||||
|
||||
'#templeSlots{margin:4px auto;text-align:center;}'+
|
||||
'#templeSlot0{top:-4px;}'+
|
||||
'#templeSlot1{top:0px;}'+
|
||||
'#templeSlot2{top:4px;}'+
|
||||
|
||||
'#templeLumpRefill{cursor:pointer;width:48px;height:48px;position:absolute;left:-6px;top:-10px;transform:scale(0.5);z-index:1000;transition:transform 0.05s;}'+
|
||||
'#templeLumpRefill:hover{transform:scale(1);}'+
|
||||
'#templeLumpRefill:active{transform:scale(0.4);}'+
|
||||
|
||||
'#templeInfo{position:relative;display:inline-block;margin:8px auto 0px auto;padding:8px 16px;padding-left:32px;text-align:center;font-size:11px;color:rgba(255,255,255,0.75);text-shadow:-1px 1px 0px #000;background:rgba(0,0,0,0.75);border-radius:16px;}'+
|
||||
'</style>';
|
||||
str+='<div id="templeBG"></div>';
|
||||
str+='<div id="templeContent">';
|
||||
str+='<div id="templeDrag"></div>';
|
||||
str+='<div id="templeSlots">';
|
||||
for (var i in M.slot)
|
||||
{
|
||||
var me=M.slot[i];
|
||||
str+='<div class="ready templeGod templeGod'+(i%4)+' templeSlot titleFont" id="templeSlot'+i+'" '+Game.getDynamicTooltip('Game.ObjectsById['+M.parent.id+'].minigame.slotTooltip('+i+')','this')+'><div class="usesIcon shadowFilter templeGem templeGem'+(parseInt(i)+1)+'"></div></div>';
|
||||
}
|
||||
str+='</div>';
|
||||
var icon=[29,14];
|
||||
str+='<div id="templeInfo"><div '+Game.getTooltip('<div style="padding:8px;width:300px;font-size:11px;text-align:center;">Click to refill all your worship swaps for <span class="price lump">1 sugar lump</span>.</div>')+' id="templeLumpRefill" class="usesIcon shadowFilter" style="background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div><div id="templeSwaps" '+Game.getTooltip('<div style="padding:8px;width:350px;font-size:11px;text-align:center;">Each time you slot a spirit, you use up one worship swap.<div class="line"></div>If you have 0 swaps left, you will get one after 16 hours.<br>If you have 1 swap left, the next one will refill after 4 hours.<br>If you have 2 swaps left, the next one will refill after 1 hour.<div class="line"></div>Unslotting a spirit costs no swaps.</div>')+'>-</div></div>';
|
||||
str+='<div id="templeGods">';
|
||||
for (var i in M.gods)
|
||||
{
|
||||
var me=M.gods[i];
|
||||
var icon=me.icon||[0,0];
|
||||
str+='<div class="ready templeGod templeGod'+(me.id%4)+' titleFont" id="templeGod'+me.id+'" '+Game.getDynamicTooltip('Game.ObjectsById['+M.parent.id+'].minigame.godTooltip('+me.id+')','this')+'><div class="usesIcon shadowFilter templeIcon" style="background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div><div class="templeSlotDrag" id="templeGodDrag'+me.id+'"></div></div>';
|
||||
str+='<div class="templeGodPlaceholder" id="templeGodPlaceholder'+me.id+'"></div>';
|
||||
}//<div class="usesIcon shadowFilter templeGem templeGem'+(me.id%3+1)+'"></div>
|
||||
str+='</div>';
|
||||
str+='</div>';
|
||||
div.innerHTML=str;
|
||||
M.swapsL=l('templeSwaps');
|
||||
M.lumpRefill=l('templeLumpRefill');
|
||||
|
||||
for (var i in M.gods)
|
||||
{
|
||||
var me=M.gods[i];
|
||||
AddEvent(l('templeGodDrag'+me.id),'mousedown',function(what){return function(){M.dragGod(what);}}(me));
|
||||
AddEvent(l('templeGodDrag'+me.id),'mouseup',function(what){return function(){M.dropGod(what);}}(me));
|
||||
}
|
||||
for (var i in M.slot)
|
||||
{
|
||||
var me=M.slot[i];
|
||||
AddEvent(l('templeSlot'+i),'mouseover',function(what){return function(){M.hoverSlot(what);}}(i));
|
||||
AddEvent(l('templeSlot'+i),'mouseout',function(what){return function(){M.hoverSlot(-1);}}(i));
|
||||
}
|
||||
|
||||
AddEvent(document,'mouseup',M.dropGod);
|
||||
|
||||
AddEvent(M.lumpRefill,'click',function(){
|
||||
if (Game.lumps>=1 && M.swaps<3)
|
||||
{
|
||||
M.swaps=3;
|
||||
M.swapT=Date.now();
|
||||
Game.lumps-=1;
|
||||
PlaySound('snd/pop'+Math.floor(Math.random()*3+1)+'.mp3',0.75);
|
||||
}
|
||||
});
|
||||
|
||||
//M.parent.switchMinigame(1);
|
||||
}
|
||||
M.save=function()
|
||||
{
|
||||
//output cannot use ",", ";" or "|"
|
||||
var str='';
|
||||
for (var i in M.slot)
|
||||
{str+=parseFloat(M.slot[i])+'/';}
|
||||
str=str.slice(0,-1);
|
||||
str+=' '+parseFloat(M.swaps)+' '+parseFloat(M.swapT);
|
||||
return str;
|
||||
}
|
||||
M.load=function(str)
|
||||
{
|
||||
//interpret str; called after .init
|
||||
//note : not actually called in the Game's load; see "minigameSave" in main.js
|
||||
if (!str) return false;
|
||||
var i=0;
|
||||
var spl=str.split(' ');
|
||||
var bit=spl[i++].split('/')||[];
|
||||
for (var ii in M.slot)
|
||||
{
|
||||
if (parseFloat(bit[ii])!=-1)
|
||||
{
|
||||
var god=M.godsById[parseFloat(bit[ii])];
|
||||
M.slotGod(god,ii);
|
||||
l('templeSlot'+god.slot).appendChild(l('templeGod'+god.id));
|
||||
}
|
||||
}
|
||||
M.swaps=parseFloat(spl[i++]||3);
|
||||
M.swapT=parseFloat(spl[i++]||Date.now());
|
||||
}
|
||||
M.reset=function()
|
||||
{
|
||||
M.swaps=3;
|
||||
M.swapT=Date.now();
|
||||
for (var i in M.slot) {M.slot[i]=-1;}
|
||||
for (var i in M.gods)
|
||||
{
|
||||
var me=M.gods[i];
|
||||
me.slot=-1;
|
||||
var other=l('templeGodPlaceholder'+(me.id));
|
||||
other.parentNode.insertBefore(l('templeGod'+me.id),other);
|
||||
other.style.display='none';
|
||||
}
|
||||
}
|
||||
M.logic=function()
|
||||
{
|
||||
//run each frame
|
||||
var t=1000*60*60;
|
||||
if (M.swaps==0) t=1000*60*60*16;
|
||||
else if (M.swaps==1) t=1000*60*60*4;
|
||||
var t2=M.swapT+t-Date.now();
|
||||
if (t2<=0 && M.swaps<3) {M.swaps++;M.swapT=Date.now();}
|
||||
M.lastSwapT++;
|
||||
}
|
||||
M.draw=function()
|
||||
{
|
||||
//run each draw frame
|
||||
if (M.dragging)
|
||||
{
|
||||
var box=l('templeDrag').getBoundingClientRect();
|
||||
var x=Game.mouseX-box.left-60/2;
|
||||
var y=Game.mouseY-box.top;
|
||||
if (M.slotHovered!=-1)//snap to slots
|
||||
{
|
||||
var box2=l('templeSlot'+M.slotHovered).getBoundingClientRect();
|
||||
x=box2.left-box.left;
|
||||
y=box2.top-box.top;
|
||||
}
|
||||
l('templeGod'+M.dragging.id).style.transform='translate('+(x)+'px,'+(y)+'px)';
|
||||
}
|
||||
var t=1000*60*60;
|
||||
if (M.swaps==0) t=1000*60*60*16;
|
||||
else if (M.swaps==1) t=1000*60*60*4;
|
||||
var t2=M.swapT+t-Date.now();
|
||||
M.swapsL.innerHTML='Worship swaps : <span class="titleFont" style="color:'+(M.swaps>0?'#fff':'#c00')+';">'+M.swaps+'/'+(3)+'</span>'+((M.swaps<3)?' (next in '+Game.sayTime((t2/1000+1)*Game.fps,-1)+')':'');
|
||||
}
|
||||
M.init(l('rowSpecial'+M.parent.id));
|
||||
}
|
||||
var M=0;
|
196
v10466.html
Normal file
|
@ -0,0 +1,196 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
//window.cookieconsent_options = {"message":"Unsurprisingly, this website uses cookies for ads and traffic analysis.","dismiss":"Got it!","learnMore":"Learn more","link":"http://orteil.dashnet.org/cookieconsentpolicy.html","target":"_blank","theme":"http://orteil.dashnet.org/cookieconsent.css","domain":"dashnet.org"};
|
||||
</script>
|
||||
<!--<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/1.0.9/cookieconsent.min.js"></script>-->
|
||||
|
||||
<title>Cookie Clicker</title>
|
||||
<!--
|
||||
Code and graphics copyright Orteil, 2013-2014
|
||||
Feel free to alter this code to your liking, but please do not re-host it, do not profit from it and do not present it as your own.
|
||||
|
||||
-TODO :
|
||||
-milk toys
|
||||
-temple building
|
||||
-gambling
|
||||
-better prestige
|
||||
-more dungeons
|
||||
-more zebras
|
||||
-->
|
||||
|
||||
<link rel="shortcut icon" href="favicon.ico" />
|
||||
<link href="http://fonts.googleapis.com/css?family=Kavoon&subset=latin,latin-ext" rel="stylesheet" type="text/css">
|
||||
<link href="style.css?v=1.77" rel="stylesheet" type="text/css">
|
||||
<!--->
|
||||
<meta name="viewport"
|
||||
content="initial-scale=2.0,
|
||||
maximum-scale=2.0,
|
||||
minimum-scale=2.0,
|
||||
height=device-height,
|
||||
width=device-width,
|
||||
target-densityDpi=device-dpi"/>
|
||||
<!---->
|
||||
<!--<meta name="viewport" content="width=250"/>-->
|
||||
<!--<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=250, height=device-height, target-densitydpi=device-dpi"/>-->
|
||||
|
||||
<!--[if lt IE9]><script src="excanvas.compiled.js"></script><![endif]-->
|
||||
<script src="base64.js"></script>
|
||||
<script src="ajax.js"></script>
|
||||
<script src="DungeonGen.js"></script>
|
||||
<script src="dungeons.js?v=1.5044"></script>
|
||||
<script src="main.js?v=1.792"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="wrapper">
|
||||
|
||||
<div id="topBar">
|
||||
<div>
|
||||
<b>Cookie Clicker</b> © <a href="http://orteil.dashnet.org" target="_blank">Orteil</a>, 2014 - <a href="http://dashnet.org" target="_blank">DashNet</a> | <a href="http://twitter.com/orteil42" target="_blank">twitter</a> | <a href="http://orteil42.tumblr.com" target="_blank">tumblr</a> | <a href="http://forum.dashnet.org" target="_blank">forum</a> | <a href="http://forum.dashnet.org/discussion/277/irc-chat-channel/p1" target="_blank">IRC</a> | <a href="http://www.redbubble.com/people/dashnet" target="_blank" style="color:#6cf;">Cookie Clicker shirts, stickers and hoodies</a>! | Check out our new game, <a href="http://aqdragons.com/" target="_blank" style="color:#fc6;">AQ Dragons</a>!
|
||||
<div id="links" style="display:block;position:absolute;right:8px;top:0px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="game">
|
||||
<div id="javascriptError">
|
||||
<div style="padding:64px 128px;">
|
||||
<div class="title">Oops, looks like the game isn't loading right!</div>
|
||||
<div>Please make sure your javascript is enabled, then refresh.<br>
|
||||
This could also be caused by a problem on our side, in which case - wait a moment, then refresh!</div>
|
||||
<!--<div class="title">Oops, looks like we've got a problem.</div>
|
||||
<div>Please bear with us while we fix it.<br>Your save is safe, don't worry!</div>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<canvas id="backgroundCanvas"></canvas>
|
||||
|
||||
<div id="goldenCookie" class="goldenCookie"></div>
|
||||
<div id="seasonPopup" class="seasonPopup"></div>
|
||||
<div id="alert"></div>
|
||||
<div id="particles"></div>
|
||||
<div id="notes"></div>
|
||||
<div id="darken"></div>
|
||||
<div id="promptAnchor"><div id="prompt" class="framed"><div id="promptContent"></div><div class="close" onclick="Game.ClosePrompt();">x</div></div></div>
|
||||
<div id="versionNumber" class="title"></div>
|
||||
<div id="timers"></div>
|
||||
|
||||
<div id="sectionLeft" class="inset">
|
||||
<canvas id="backgroundLeftCanvas" style="z-index:5;"></canvas>
|
||||
<div class="blackFiller"></div>
|
||||
<div class="blackGradient"></div>
|
||||
<div id="sectionLeftInfo"></div>
|
||||
<div id="cookies" class="title"></div>
|
||||
<div id="bakeryNameAnchor"><div id="bakeryName" class="title"></div></div>
|
||||
<div id="cookieAnchor">
|
||||
<div id="bigCookie"></div>
|
||||
<div id="cookieNumbers"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="separatorLeft"></div>
|
||||
<div class="separatorRight"></div>
|
||||
|
||||
<div id="sectionMiddle" class="inset">
|
||||
<div id="comments" class="inset title">
|
||||
<div id="prefsButton" class="button">Menu</div>
|
||||
<div id="statsButton" class="button">Stats</div>
|
||||
<div id="logButton" class="button" style="font-size:80%;">Updates</div>
|
||||
<div id="commentsText" class="commentsText"></div>
|
||||
<div class="separatorBottom"></div>
|
||||
</div>
|
||||
<div id="buildingsTitle" class="inset title zoneTitle">Buildings</div>
|
||||
<div id="rows"></div>
|
||||
<div id="menu"></div>
|
||||
<div id="donateBox">
|
||||
<form target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post" id="donate" style="margin:0px 16px;">
|
||||
<input type="hidden" name="cmd" value="_s-xclick">
|
||||
<input type="hidden" name="hosted_button_id" value="BBN2WL3TC6QH4">
|
||||
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
|
||||
<img alt="" border="0" src="https://www.paypalobjects.com/nl_NL/i/scr/pixel.gif" width="1" height="1">
|
||||
</form>
|
||||
Help us keep developing the game!
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="sectionRight" class="inset">
|
||||
<div id="store">
|
||||
<div id="storeTitle" class="inset title zoneTitle">Store</div>
|
||||
<div id="upgrades" class="storeSection"></div>
|
||||
<div id="products" class="storeSection"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="support" style="margin-top:130px;">
|
||||
<div class="supportComment">v Sponsored links v</div>
|
||||
<div style="position:relative;">
|
||||
|
||||
<div style="position:relative;z-index:100;min-height:250px;">
|
||||
|
||||
<!--<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>-->
|
||||
<!-- Cookie Clicker Responsive -->
|
||||
<ins class="adsbygoogle"
|
||||
style="display:block;margin:auto;"
|
||||
data-ad-client="ca-pub-8491708950677704"
|
||||
data-ad-slot="9780186019"
|
||||
data-ad-format="auto"
|
||||
data-full-width-responsive="true"></ins>
|
||||
<script>
|
||||
//(adsbygoogle = window.adsbygoogle || []).push({});
|
||||
</script>
|
||||
|
||||
<div style="height:16px;"></div>
|
||||
|
||||
<!-- AdventureQuest Worlds banner -->
|
||||
<!--<a class="ad" id="aqad" href="http://www.aq.com/landing/cookie/?utm_campaign=AQW_CookieClicker&utm_source=CookieClicker" target="_blank" title="AdventureQuest Worlds" style="background:url(img/aqworldsbanner.jpg) no-repeat;width:300px;height:64px;display:block;position:relative;margin:0px auto;">
|
||||
</a>-->
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--
|
||||
<div id="sectionAd" class="inset">
|
||||
|
||||
<div class="supportComment">Sponsored links</div>
|
||||
<div style="position:relative;">
|
||||
<div class="supportPlaceholder">
|
||||
<div>(Normally, there would be an ad here. It's fine if you want to block it, but remember - Cookie Clicker only happens because of ad revenue!)</div>
|
||||
</div>
|
||||
<div style="position:relative;z-index:100;">
|
||||
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
||||
<ins class="adsbygoogle"
|
||||
style="display:inline-block;width:160px;height:600px"
|
||||
data-ad-client="ca-pub-8491708950677704"
|
||||
data-ad-slot="8643839697"></ins>
|
||||
<script>
|
||||
(adsbygoogle = window.adsbygoogle || []).push({});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div id="focusButtons">
|
||||
<div id="focusLeft" class="title">Cookie</div>
|
||||
<div id="focusMiddle" class="title" style="font-size:80%;padding-top:18px;padding-bottom:14px;">Buildings</div>
|
||||
<div id="focusRight" class="title">Store</div>
|
||||
<div id="focusMenu" class="title">Menu</div>
|
||||
</div>
|
||||
<div id="compactOverlay" class="title">
|
||||
<div id="compactCommentsText" class="commentsText"></div>
|
||||
<div id="compactCookies"></div>
|
||||
<div class="separatorBottom"></div>
|
||||
</div>
|
||||
|
||||
<div id="tooltipAnchor"><div id="tooltip" class="framed" onMouseOut="Game.tooltip.hide();"></div></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|