*only increase chance of goal items if you haven't already met the goal.
*make increase chance work for "special" things!!! (eg. white cat) *stop increasing goal progress once we hit the required amount *seperate goal names and goal associated things
This commit is contained in:
parent
62f7b20a88
commit
b5dedbe0ad
89
cat.html
89
cat.html
|
@ -96,6 +96,10 @@ var GOALVERB = {
|
|||
'whitecat': 'Attack',
|
||||
};
|
||||
|
||||
var GOALNAME = {
|
||||
'whitecat': 'white cat',
|
||||
};
|
||||
|
||||
var prizetypes = [
|
||||
"tissues", "shears", "magiccarpet",
|
||||
];
|
||||
|
@ -1390,7 +1394,15 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
|
|||
//console.log("progress()");
|
||||
for (i = 0 ; i < this.levels[curlevel].goals.length; i++ ) {
|
||||
//console.log("this goal type is " + this.levels[curlevel].goals[i].type);
|
||||
|
||||
// already met the goal?
|
||||
if (this.levels[curlevel].goals[i].progress >= this.levels[curlevel].goals[i].count) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// goal matches what we just progressed in?
|
||||
if (this.levels[curlevel].goals[i].type == type) {
|
||||
// increase progress.
|
||||
this.levels[curlevel].goals[i].progress += amt;
|
||||
if (this.levels[curlevel].goals[i].progress >= this.levels[curlevel].goals[i].count) {
|
||||
|
||||
|
@ -1404,8 +1416,6 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
calcstars : function (lev, points) {
|
||||
var i;
|
||||
for (i = 2; i >= 0; i--) {
|
||||
|
@ -1881,6 +1891,7 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
|
|||
var x,y;
|
||||
var margin = 10;
|
||||
var indent = 50;
|
||||
var progindent = 25;
|
||||
var boxindent = 20;
|
||||
//ctx = this.context;
|
||||
|
||||
|
@ -1931,15 +1942,23 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
|
|||
goalcol = "#aaee00";
|
||||
}
|
||||
|
||||
// goal name
|
||||
// goal description
|
||||
var ess = "s";
|
||||
if (this.levels[curlevel].goals[n].count == 1) {
|
||||
ess = "";
|
||||
}
|
||||
|
||||
|
||||
var goalname;
|
||||
if (GOALNAME[this.levels[curlevel].goals[n].type] == undefined) {
|
||||
goalname = this.levels[curlevel].goals[n].type;
|
||||
} else {
|
||||
goalname = GOALNAME[this.levels[curlevel].goals[n].type];
|
||||
}
|
||||
|
||||
var goaltext = GOALVERB[this.levels[curlevel].goals[n].type] + " " +
|
||||
this.levels[curlevel].goals[n].count + " " +
|
||||
this.levels[curlevel].goals[n].type + ess;
|
||||
goalname + ess;
|
||||
|
||||
var progtext = "[" + this.levels[curlevel].goals[n].progress + " / " +
|
||||
this.levels[curlevel].goals[n].count + "]";
|
||||
|
@ -1950,7 +1969,8 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
|
|||
|
||||
ctx.textAlign = "right";
|
||||
ctx.textBaseline = "top";
|
||||
shadowtext(ctx, progtext, GOALTEXTSIZE,goalcol, SCREENW-indent, y);
|
||||
|
||||
shadowtext(ctx, progtext, GOALTEXTSIZE,goalcol, SCREENW-progindent, y);
|
||||
|
||||
// completed?
|
||||
if (goalmet) {
|
||||
|
@ -4080,6 +4100,8 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
|
|||
ctx.stroke();
|
||||
|
||||
// right: bags
|
||||
|
||||
var SMALLBAGAMT = 0.2;
|
||||
if (game.levels[curlevel].bags != undefined) {
|
||||
for (i = 0; i < game.levels[curlevel].bags.length; i++) {
|
||||
var bagh,thisbag;
|
||||
|
@ -4087,8 +4109,8 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
|
|||
x = BOARDX + (GRIDW * GRIDSIZE);
|
||||
y = BOARDY + (thisbag.y * GRIDSIZE);
|
||||
if (thisbag.cats < thisbag.capacity) {
|
||||
bagh = THINGSIZE*0.1; // base height
|
||||
bagh += (thisbag.cats / thisbag.capacity) * (THINGSIZE*0.9); // increase based on fullness
|
||||
bagh = THINGSIZE*SMALLBAGAMT; // base height
|
||||
bagh += (thisbag.cats / thisbag.capacity) * (THINGSIZE*(1-SMALLBAGAMT)); // increase based on fullness
|
||||
ctx.drawImage(image['bag'], x, y + GRIDSIZE/2 - bagh/2, THINGSIZE, bagh);
|
||||
} else if (thisbag.prize != "") { // not collected yet
|
||||
var size = SCREENW - (GRIDW*GRIDSIZE + BOARDX) ;
|
||||
|
@ -4173,6 +4195,15 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
|
|||
console.log("chear() - ending game");
|
||||
game.setstate("gameover");
|
||||
game.cheat = 1;
|
||||
} else if (ch == 'i') {
|
||||
var what;
|
||||
what = getthingxy(lastmx, lastmy);
|
||||
if (what != undefined) {
|
||||
|
||||
console.log("info for " + what.name);
|
||||
console.log(what);
|
||||
}
|
||||
|
||||
} else if (ch == 'c') {
|
||||
playerdata.clearall();
|
||||
} else if (ch == 'f') {
|
||||
|
@ -4821,7 +4852,7 @@ function getrandomtype() {
|
|||
}
|
||||
|
||||
// construct a list of permitted special things
|
||||
var poss = [ "sunlight", "toad", "whitecat" ] ;
|
||||
var poss = [ "door", "sunlight", "toad", "whitecat" ] ;
|
||||
for (i in poss ) {
|
||||
if (!game.isbanned(curlevel, poss[i])) {
|
||||
if (speciallist == undefined) {
|
||||
|
@ -4839,7 +4870,7 @@ function getrandomtype() {
|
|||
|
||||
// default thinglist
|
||||
// must be sorted from low to high!
|
||||
if (!game.isbanned(curlevel, 'door')) thinglist.push({ type: 'door', pct: 10 } );
|
||||
//if (!game.isbanned(curlevel, 'door')) thinglist.push({ type: 'door', pct: 10 } );
|
||||
if (speciallist != undefined) {
|
||||
if (dodb) console.log("specials are possible");
|
||||
thinglist.push({ type: 'special', pct: 5 } );
|
||||
|
@ -4850,6 +4881,7 @@ function getrandomtype() {
|
|||
if (!game.isbanned(curlevel, 'cat')) thinglist.push({ type: 'cat', pct: 45 } );
|
||||
}
|
||||
|
||||
|
||||
// increase the chance of something appearing if
|
||||
// a. it's a goal
|
||||
// b. we don't have any
|
||||
|
@ -4857,16 +4889,41 @@ function getrandomtype() {
|
|||
var n;
|
||||
for (i = 0; i < thinglist.length; i++) {
|
||||
for (n = 0 ; n < game.levels[curlevel].goals.length; n++ ) {
|
||||
if (game.levels[curlevel].goals[n].type == thinglist[i].type) {
|
||||
var matchesgoal = false;
|
||||
var thingtype = thinglist[i].type
|
||||
var goaltype = game.levels[curlevel].goals[n].type;
|
||||
var lookforthing;
|
||||
|
||||
if (game.levels[curlevel].goals[n].progress < game.levels[curlevel].goals[n].count) {
|
||||
if (goaltype == thingtype) {
|
||||
matchesgoal = true;
|
||||
lookforthing = thingtype;
|
||||
} else if ((thingtype == "special") &&
|
||||
speciallist.indexOf(goaltype) != -1) {
|
||||
// change it.
|
||||
lookforthing = goaltype;
|
||||
matchesgoal = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchesgoal) {
|
||||
var count;
|
||||
console.log("****** " + thinglist[i].type + " matches goal.");
|
||||
console.log("****** " + thingtype + " matches goal.");
|
||||
// check if any exist
|
||||
count = countalivethingsoftype(thinglist[i].type);
|
||||
count = countalivethingsoftype(lookforthing);
|
||||
if (count <= 1) {
|
||||
console.log("****** no things of type " + thinglist[i].type);
|
||||
console.log("****** no things of type " + lookforthing);
|
||||
// extra chance!
|
||||
thinglist[i].pct *= 3;
|
||||
console.log("double chance of " + thinglist[i].type);
|
||||
thinglist[i].pct *= 4;
|
||||
console.log("extra chance of " + thingtype + "(" + lookforthing + ")");
|
||||
|
||||
// if the thing in question is 'special',
|
||||
// cheat on the random check later to make sure we
|
||||
// only get the right kind of special thing.
|
||||
if (thingtype == "special") {
|
||||
speciallist.splice(0, speciallist.length);
|
||||
speciallist.push(goaltype);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5054,7 +5111,7 @@ function thing(gridx, gridy, type, text, col) {
|
|||
this.canfall = function() {
|
||||
// doors can't fall after their initial drop
|
||||
if (this.type == "door") {
|
||||
if ((this.gridy >= 0) && (this.new == false)) {
|
||||
if ((this.gridy >= 0) && (this.isnew == false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
22
todo
22
todo
|
@ -9,24 +9,24 @@ https://www.smashingmagazine.com/2012/10/design-your-own-mobile-game/
|
|||
https://www.smashingmagazine.com/2012/10/design-your-own-mobile-game/
|
||||
--- check here for ios
|
||||
|
||||
-------------------
|
||||
|
||||
*special: toad - slap to make it drop down and clear objects below.
|
||||
*special: white cat : destroys stuff around it
|
||||
*increase changes of a goal things appearing if none exist.
|
||||
*only increase chance of goal items if you haven't already met the goal.
|
||||
*make increase chance work for "special" things!!! (eg. white cat)
|
||||
*stop increasing goal progress once we hit the required amount
|
||||
*seperate goal names and goal associated things
|
||||
|
||||
make increasechance work for "special" things!!!
|
||||
OBSTACLES on later levels
|
||||
fixed position.
|
||||
|
||||
|
||||
separate goal names and goal associated things
|
||||
|
||||
other colour cat
|
||||
|
||||
more goals:
|
||||
form x parades of length y
|
||||
other colour cats
|
||||
|
||||
|
||||
--------------
|
||||
|
||||
more goals:
|
||||
form x parades of length y
|
||||
|
||||
more prizes: ???
|
||||
mouse - place to clear all cats in grid/column
|
||||
whitecat - place to clear 3 x 3 grid around it
|
||||
|
|
Loading…
Reference in New Issue