Skip to content

Commit

Permalink
minor fixes/features
Browse files Browse the repository at this point in the history
  • Loading branch information
lvandeve committed Nov 10, 2022
1 parent 50a00df commit 42445e0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 21 deletions.
12 changes: 5 additions & 7 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,7 @@ function precomputeField_(prefield, opt_pretend_fullgrown) {
for(var dir = 0; dir < dirs.length; dir++) { // get the neighbors N,E,S,W
var x2 = x + dirs[dir][0];
var y2 = y + dirs[dir][1];
var diag = dirs[dir][2];
if(x2 < 0 || x2 >= w || y2 < 0 || y2 >= h) continue;
var f2 = state.field[y2][x2];
if(f2.index == FIELD_MULTIPART) {
Expand All @@ -1771,7 +1772,7 @@ function precomputeField_(prefield, opt_pretend_fullgrown) {
var c2 = f2.getCrop();
if(!c2) continue;
if(score_ignore_templates && !c2.isReal()) continue;
if(dir >= 4 && c2.type != CROPTYPE_BRASSICA) continue; // diagonal directions are currently only for diagonal brassica
if(diag && c2.type != CROPTYPE_BRASSICA) continue; // diagonal directions are currently only for diagonal brassica
var p2 = prefield[y2][x2];

if(c.type == CROPTYPE_BERRY || c.type == CROPTYPE_PUMPKIN) {
Expand Down Expand Up @@ -1814,6 +1815,7 @@ function precomputeField_(prefield, opt_pretend_fullgrown) {
for(var dir = 0; dir < dirs.length; dir++) { // get the neighbors N,E,S,W
var x2 = x + dirs[dir][0];
var y2 = y + dirs[dir][1];
var diag = dirs[dir][2];
if(x2 < 0 || x2 >= w || y2 < 0 || y2 >= h) continue;
var f2 = state.field[y2][x2];
if(f2.index == FIELD_MULTIPART) {
Expand All @@ -1824,7 +1826,7 @@ function precomputeField_(prefield, opt_pretend_fullgrown) {
var c2 = f2.getCrop();
if(!c2) continue;
if(score_ignore_templates && !c2.isReal()) continue;
if(dir >= 4 && c2.type != CROPTYPE_BRASSICA) continue; // diagonal directions are currently only for diagonal brassica
if(diag && c2.type != CROPTYPE_BRASSICA) continue; // diagonal directions are currently only for diagonal brassica
var p2 = prefield[y2][x2];
if(c.type == CROPTYPE_MUSH) {
if(c2.type == CROPTYPE_FLOWER) score_flower += (1 + p.num_bee);
Expand Down Expand Up @@ -4027,16 +4029,12 @@ var update = function(opt_ignorePause) {
state.g_numplanted3--;
}
state.g_numunplanted3++;
if(!action.silent) showMessage('deleted ethereal ' + c.name + ', got back ' + recoup.toString());
if(!action.silent) showMessage('deleted infinity ' + c.name + ', got back ' + recoup.toString());
f.index = 0;
f.growth = 0;
computeDerived(state); // need to recompute this now to get the correct "recoup" cost of a plant which depends on the derived stat
state.res.addInPlace(recoup);

if(isdelete && !freedelete && candelete == 2) {
state.lastEtherealDeleteTime = state.time;
}

if(type == ACTION_DELETE3) computeDerived(state); // correctly update derived stats based on changed field state (replace will do it below)
store_undo = true;
} else if(f.index == FIELD_REMAINDER) {
Expand Down
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
var version_major = 0; // 0..61
var version_minor = 7; // 0..4095
var version_patch = 4; // 0..63
var version_sub = 0; // 0=no suffix, 1=b, 2=c, ...
var version_sub = 1; // 0=no suffix, 1=b, 2=c, ...

var version = 262144 * (version_major + 2) + 64 * version_minor + version_patch;

Expand Down
9 changes: 5 additions & 4 deletions state.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,14 @@ function diagConnected(x0, y0, x1, y1, field) {
return !(m2 == m0 || m2 == m1 || m3 == m0 || m3 == m1);
}

var neighbors_1x1 = [[0, -1], [1, 0], [0, 1], [-1, 0]];
var neighbors_1x1_diag = [[-1, -1], [0, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1]];
var neighbors_2x2 = [[0, -1], [1, -1], [-1, 0], [2, 0], [-1, 1], [2, 1], [0, 2], [1, 2]];
var neighbors_2x2_diag = [[-1, -1], [0, -1], [1, -1], [2, -1], [-1, 0], [2, 0], [-1, 1], [2, 1], [-1, 2], [0, 2], [1, 2], [2, 2]];
var neighbors_1x1 = [[0, -1, false], [1, 0, false], [0, 1, false], [-1, 0, false]];
var neighbors_1x1_diag = [[-1, -1, true], [0, -1, false], [1, -1, true], [-1, 0, false], [1, 0, false], [-1, 1, true], [0, 1, false], [1, 1, true]];
var neighbors_2x2 = [[0, -1, false], [1, -1, false], [-1, 0, false], [2, 0, false], [-1, 1, false], [2, 1, false], [0, 2, false], [1, 2, false]];
var neighbors_2x2_diag = [[-1, -1, true], [0, -1, false], [1, -1, false], [2, -1, true], [-1, 0, false], [2, 0, false], [-1, 1, false], [2, 1, false], [-1, 2, true], [0, 2, false], [1, 2, false], [2, 2, true]];

// returns list of neighbors from this crop, based on its shape (1x1 or 2x2). Does not filter out out-of-bounds cells, returns fixed possible arrays of relative coordinates.
// must still bound-check, and possibly use diagConnected, when iterating through those relative coordinates
// each returned direction has a third value, a boolean indicating whether it represents a diagonal direction. When include_diag is true, some of the values will have this true
Cell.prototype.getNeighborDirsFrom = function(include_diag) {
var c = this.getCrop(false);
if(c && c.quad) {
Expand Down
2 changes: 1 addition & 1 deletion ui_automaton.js
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ function updateAutomatonUI() {
flex.div.textEl.innerText = 'Clear infinity field';
flex.div.style.textShadow = '0px 0px 5px #88f';
addButtonAction(flex.div, deleteInfinityField);
registerTooltip(flex.div, 'Delete all crops from the ethereal field. Only succeeds if deleting is possible at this time. As usual, all resin is refunded. Note that this will also delete the automaton itself, so this will disable the automaton tab until you place the automaton back.');
registerTooltip(flex.div, 'Immediately delete all crops from the infinity field. All infinity seeds will be refunded as usual.');
x = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions ui_field3.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ function getCropInfoHTML3(f, c, opt_detailed) {
}

result += 'Production per second: ' + prod.toString();
if(prod.infseeds.neqr(0) && prod.infseeds.ltr(0.1) && prod.infseeds.gtr(-0.1)) result += ' (' + prod.infseeds.mulr(3600).toString() + '/h)';
/*if(prod.infseeds.neqr(0) && prod.infseeds.ltr(0.1) && prod.infseeds.gtr(-0.1))*/ result += ' (' + prod.infseeds.mulr(3600).toString() + '/h)';
var baseprod = c.getProd(undefined);
if(baseprod.infseeds.neq(prod.infseeds)) {
result += '<br/>';
result += 'Base production/s: ' + baseprod.toString();
if(baseprod.infseeds.neqr(0) && baseprod.infseeds.ltr(0.1) && baseprod.infseeds.gtr(-0.1)) result += ' (' + baseprod.infseeds.mulr(3600).toString() + '/h)';
/*if(baseprod.infseeds.neqr(0) && baseprod.infseeds.ltr(0.1) && baseprod.infseeds.gtr(-0.1))*/ result += ' (' + baseprod.infseeds.mulr(3600).toString() + '/h)';
}
result += '<br/><br/>';
}
Expand Down
2 changes: 1 addition & 1 deletion ui_help.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ registerHelpDialog(42, 'Infinity field', 'You unlocked the infinity field!',
<br><br>
Unlike the ethereal field, the infinity field is more focused on growing and improving itself slowly over time with its own resource, rather than merely boosting the basic field.
<br><br>
The first crop, a brassica, is not a permanent crop (similar to brassica in basic field, but without the copying ability and longer lifespan), and will need to be planted multiple times to collect enough infinity seeds for better crops. Eventually there will be permanent crops too.
The first crop, a brassica, is not a permanent crop (similar to brassica in basic field, but without the copying ability and longer lifespan), and will need to be planted multiple times to collect enough infinity seeds for better crops. After that, permanent crops will unlock too.
`,
image_pond,
undefined,
Expand Down
13 changes: 8 additions & 5 deletions ui_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ function prodBreakdown3(index) {
}

// computes how many infinity seeds currently spent in the infinity field, what you'd get back from all recoups
// returns array of 2 values: total amount in the field, and amount in finite-lifespan crops (watercress)
function computeField3InfinitySeeds() {
var result = Num(0);
var total = Num(0);
var watercress = Num(0);
var o = {};
for(var y = 0; y < state.numh3; y++) {
for(var x = 0; x < state.numw3; x++) {
Expand All @@ -113,11 +115,12 @@ function computeField3InfinitySeeds() {
if(!o[index]) o[index] = 0;
o[index]++;
var recoup = c.getRecoup(f, -o[index] + 1);
result.addInPlace(recoup.infseeds);
total.addInPlace(recoup.infseeds);
if(c.type == CROPTYPE_BRASSICA) watercress.addInPlace(recoup.infseeds);
}
}
}
return result;
return [total, watercress];
}


Expand Down Expand Up @@ -320,8 +323,8 @@ function getResourceDetails(i, special, index) {
text += 'Current amount: ' + res.toString() + '<br/>';
if(index == 5) {
var infield = computeField3InfinitySeeds();
text += 'In field: ' + infield.toString() + '<br>';
text += 'Total (field + current): ' + infield.add(state.res.infseeds).toString() + '<br>';
text += 'In field: ' + infield[0].toString() + ' (brassica: ' + infield[1].toString() + ')<br>';
text += 'Total (field + current): ' + infield[0].add(state.res.infseeds).toString() + '<br>';
text += 'Total earned ever: ' + state.g_res.infseeds.toString() + '<br>'; // this can be more than total because some seeds are spent on brassicas that wither
}
text += '<br/>';
Expand Down

0 comments on commit 42445e0

Please sign in to comment.