Skip to content

Commit

Permalink
platinum infinity and octopus
Browse files Browse the repository at this point in the history
  • Loading branch information
lvandeve committed Mar 27, 2023
1 parent 339df24 commit cdf41aa
Show file tree
Hide file tree
Showing 10 changed files with 281 additions and 86 deletions.
9 changes: 9 additions & 0 deletions changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
function getChangeLog() {
var text = '';

text += '0.9.1 (2023-03-27):';
text += '<br/>• Added platinum infinity crops.';
text += '<br/>• New fish type added.';
text += '<br/>• Bees in infinity field now also give a slight boost to infinity mushrooms.';
text += '<br/>• Autumn now also makes mushrooms consume less seeds.';
text += '<br/>• Reordered how some resources are shown at the top, to line up resin/twigs, seeds/infinity seeds and spores/infinity spores.';
text += '<br/>• Various tweaks.'; // includes attempt at fix with mushroom priority heuristics for auto-plant and egg drop tweaks
text += '<br/><br/>';

text += '0.9.0 (2023-03-23):';
text += '<br/>• New infinity crop: golden mushroom.';
text += '<br/>• Added ability to place fishes in the infinity pond, available once you have infinity mushrooms. Only a few fish types added in this first version of it.';
Expand Down
111 changes: 91 additions & 20 deletions data.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function getCropTypeHelp3(type, opt_have_fishes) {
case CROPTYPE_STINGING: return '';
case CROPTYPE_BRASSICA: return 'Produces seeds, but has a limited lifespan. Produces more seeds than its initial cost over its lifespan.';
case CROPTYPE_MISTLETOE: return '';
case CROPTYPE_BEE: return 'Boosts orthogonally neighboring flowers.';
case CROPTYPE_BEE: return opt_have_fishes ? 'Boosts neighboring flowers. For the flower boost to mushrooms, also has a small effect based on tier.' : 'Boosts neighboring flowers.';
case CROPTYPE_CHALLENGE: return '';
case CROPTYPE_FERN2: return '';
case CROPTYPE_NUT: return '';
Expand Down Expand Up @@ -388,7 +388,7 @@ var infernal_mush_upgrade_base = Num.pow(Num(infernal_mush_tier_mul), Num(1.0 /

// used for multiple possible aspects, such as production, boost if this is a flower, etc...
// f is field, similar to in Crop.prototype.getProd
// result is change in-place and may be either Num or Res. Nothing is returned.
// result is changed in-place and may be either Num or Res. Nothing is returned.
Crop.prototype.addSeasonBonus_ = function(result, season, f, breakdown) {
// posmul is used:
// Unlike other multipliers, this one does not affect negative production. This is a good thing in the crop's good season, but extra harsh in a bad season (e.g. winter)
Expand Down Expand Up @@ -417,10 +417,12 @@ Crop.prototype.addSeasonBonus_ = function(result, season, f, breakdown) {
if(season == 2 && this.type == CROPTYPE_MUSH) {
var bonus = getAutumnMushroomBonus();
result.posmulInPlace(bonus);
var reduction = Num(1).sub(getAutumnMushroomConsumptionReduction());
result.negmulInPlace(reduction);
if(breakdown) breakdown.push([seasonNames[season], true, bonus, result.clone()]);
}

// with ethereal upgrades, autumn also benefits mushrooms a bit, to catch up with other seasons ethereal upgrades
// with ethereal upgrades, autumn also benefits berries a bit, to catch up with other seasons ethereal upgrades
if(season == 2 && (this.type == CROPTYPE_BERRY || this.type == CROPTYPE_PUMPKIN)) {
var bonus = getAutumnBerryBonus();
result.posmulInPlace(bonus);
Expand Down Expand Up @@ -2998,8 +3000,8 @@ var watercress_choice0 = registerChoiceUpgrade('brassica choice',
upgrades[watercress_choice0].istreebasedupgrade = true;


var resin_choice0_resin_bonus = 0.2;
var resin_choice0_production_bonus = 0.2;
var resin_choice0_resin_bonus = 0.25;
var resin_choice0_production_bonus = 0.25;

var resin_choice0 = registerChoiceUpgrade('resin choice',
function() {
Expand Down Expand Up @@ -6248,6 +6250,11 @@ function getAutumnMushroomBonus() {
return bonus;
}

// returns percentage to subtract, e.g. if this returns 0.3, then the consumption is 70% of the original consumption
function getAutumnMushroomConsumptionReduction() {
return new Num(0.5);
}

function getAutumnBerryBonus() {
return getAutumnMushroomBonus().subr(bonus_season_autumn_mushroom).mulr(bonus_season_autumn_berry).addr(1);
}
Expand Down Expand Up @@ -7398,10 +7405,20 @@ Crop3.prototype.getProd = function(f, breakdown) {
if(breakdown) breakdown.push(['goldfish', true, mul, result.clone()]);
}

// octopus
if(this.type == CROPTYPE_MUSH && state.fishcount[octopus_0]) {
var num = state.fishcount[octopus_0];
var mul = new Num(1 + octopus_0_bonus * num);
result.mulInPlace(mul);
if(breakdown) breakdown.push(['octopus', true, mul, result.clone()]);
}

// flower boost for mushroom: does not use getInfBoost, but depends on relative tier
if(f && this.type == CROPTYPE_MUSH) {
var flowermul = new Num(1);
var num = 0;
var floweronlymul = new Num(1);
var flowerbeemul = new Num(1);
var num = 0; // flowers
var num2 = 0; // bees through flowers

for(var dir = 0; dir < 4; dir++) { // get the neighbors N,E,S,W
var x2 = f.x + (dir == 1 ? 1 : (dir == 3 ? -1 : 0));
Expand All @@ -7411,19 +7428,50 @@ Crop3.prototype.getProd = function(f, breakdown) {
if(n.hasCrop() /*&& n.isFullGrown()*/ && crops3[n.cropIndex()].type == CROPTYPE_FLOWER) {
var c2 = crops3[n.cropIndex()];
if(c2.tier >= this.tier - 1) {
var boost = Num(1);
if(c2.tier <= this.tier - 1) boost = Num(0.5);
if(c2.tier >= this.tier + 1) boost = Num(1.5);
var boost = new Num(1);
if(c2.tier <= this.tier - 1) boost = new Num(0.5);
if(c2.tier >= this.tier + 1) boost = new Num(1.5);
if(boost.neqr(0)) {
flowermul.addInPlace(boost);
floweronlymul.addInPlace(boost);
num++;
}

var beeboost = new Num(1);
// bees neighboring the flower add another, albeit small, boost
for(var dir2 = 0; dir2 < 4; dir2++) { // get the neighbors N,E,S,W
var x3 = x2 + (dir2 == 1 ? 1 : (dir2 == 3 ? -1 : 0));
var y3 = y2 + (dir2 == 2 ? 1 : (dir2 == 0 ? -1 : 0));
if(x3 < 0 || x3 >= state.numw3 || y3 < 0 || y3 >= state.numh3) continue;
var n2 = state.field3[y3][x3];
if(n2.hasCrop() /*&& n.isFullGrown()*/ && crops3[n2.cropIndex()].type == CROPTYPE_BEE) {
var c3 = crops3[n2.cropIndex()];
if(c3.tier >= this.tier - 1) {
var boost2 = new Num(0.5);
if(c3.tier <= this.tier - 1) boost2 = new Num(0.25);
if(c3.tier >= this.tier + 1) boost2 = new Num(0.75);
if(boost2.neqr(0)) {
beeboost.addInPlace(boost2);
num2++;
}
}
}
}
boost.mulInPlace(beeboost);
flowerbeemul.addInPlace(boost);
} // end of 'boost.neqr(0)' for flower
}
}
}
if(num) {
result.mulInPlace(flowermul);
if(breakdown) breakdown.push(['flower tiers (' + num + ')', true, flowermul, result.clone()]);
// the below is same as doing just flowerbeemul, but, separately show flowers and bees in the breakdown, hence this mechanism
// NOTE: to understand the numbers: say there's one flower givin 100% boost (so doing x2), and one beehive giving 50% boost (so doing x1.5),
// then the breakdown will show +100% for flowers, +25% for bees (instead of +50%). Reason: bee gives 50% to flower's boost, so flower now gives 150% boost total (doing x2.5).
// therefore, you now get x2.5 instead of x2, which is 25% more. That's because all is expressed as bonus percentages to the mushroom, not to the flower.
// in case of multiple flowers/bees, this is all aggregated together.
var beeonlymul = flowerbeemul.div(floweronlymul);
result.mulInPlace(floweronlymul);
if(breakdown) breakdown.push(['flower tiers (' + num + ')', true, floweronlymul, result.clone()]);
result.mulInPlace(beeonlymul);
if(breakdown) breakdown.push(['bee tiers (' + num + ')', true, beeonlymul, result.clone()]);
}
}

Expand Down Expand Up @@ -7596,6 +7644,7 @@ var brassica3_1 = registerBrassica3('bronze watercress', 1, Res({infseeds:25000}
var brassica3_2 = registerBrassica3('silver watercress', 2, Res({infseeds:5e7}), Res({infseeds:5e7 * 4 / (3 * 24 * 3600)}), Num(0.05), 3 * 24 * 3600, metalifyPlantImages(images_watercress, metalheader2, 0));
var brassica3_3 = registerBrassica3('electrum watercress', 3, Res({infseeds:2e12}), Res({infseeds:2e12 * 2 / (24 * 3600)}), Num(0.05), 1 * 24 * 3600, metalifyPlantImages(images_watercress, metalheader3, 4));
var brassica3_4 = registerBrassica3('gold watercress', 4, Res({infseeds:100e15}), Res({infseeds:500e9}), Num(0.05), 5 * 24 * 3600, metalifyPlantImages(images_watercress, metalheader4, 0));
var brassica3_5 = registerBrassica3('platinum watercress', 5, Res({infseeds:25e21}), Res({infseeds:100e15}), Num(0.05), 7 * 24 * 3600, metalifyPlantImages(images_watercress, metalheader5, 5, 6, 1, 1.045));

crop3_register_id = 300;
var berry3_0 = registerBerry3('zinc blackberry', 0, Res({infseeds:400}), Res({infseeds:200 / (24 * 3600)}), Num(0.075), default_crop3_growtime, metalifyPlantImages(blackberry, metalheader0));
Expand All @@ -7605,21 +7654,25 @@ var berry3_2 = registerBerry3('silver blackberry', 2, Res({infseeds:2e9}), Res({
// more division since better flowers and beehives now
var berry3_3 = registerBerry3('electrum blackberry', 3, Res({infseeds:100e12}), Res({infseeds:(100e12 / 32 / (24 * 3600))}), Num(0.2), default_crop3_growtime, metalifyPlantImages(blackberry, metalheader3, 4, 2));
var berry3_4 = registerBerry3('gold blackberry', 4, Res({infseeds:5e18}), Res({infseeds:50e9}), Num(0.4), default_crop3_growtime, metalifyPlantImages(blackberry, metalheader4, 2));
var berry3_5 = registerBerry3('platinum blackberry', 5, Res({infseeds:500e21}), Res({infseeds:50e12}), Num(0.75), default_crop3_growtime, metalifyPlantImages(blackberry, metalheader5, 5, 1, undefined, 1.1));

crop3_register_id = 600;
var mush3_4 = registerMushroom3('gold champignon', 4, Res({infseeds:500e18}), Res({infspores:1}), Num(0.5), default_crop3_growtime, metalifyPlantImages(champignon, metalheader4, 2));
var mush3_5 = registerMushroom3('platinum champignon', 5, Res({infseeds:20e24}), Res({infspores:25}), Num(1), default_crop3_growtime, metalifyPlantImages(champignon, metalheader5, 6));

crop3_register_id = 900;
var flower3_0 = registerFlower3('zinc anemone', 0, Res({infseeds:2500}), Num(0.5), Num(0.1), default_crop3_growtime, metalifyPlantImages(images_anemone, metalheader0, 1));
var flower3_1 = registerFlower3('bronze anemone', 1, Res({infseeds:2.5e6}), Num(1), Num(0.15), default_crop3_growtime, metalifyPlantImages(images_anemone, metalheader1));
var flower3_2 = registerFlower3('silver anemone', 2, Res({infseeds:20e9}), Num(3), Num(0.2), default_crop3_growtime, metalifyPlantImages(images_anemone, metalheader2, 0));
var flower3_2 = registerFlower3('silver anemone', 2, Res({infseeds:20e9}), Num(3), Num(0.2), default_crop3_growtime, metalifyPlantImages(images_anemone, metalheader2, 1, undefined, undefined, 0.9));
var flower3_3 = registerFlower3('electrum anemone', 3, Res({infseeds:1e15}), Num(12), Num(0.3), default_crop3_growtime, metalifyPlantImages(images_anemone, metalheader3, 4));
var flower3_4 = registerFlower3('gold anemone', 4, Res({infseeds:200e18}), Num(200), Num(0.6), default_crop3_growtime, metalifyPlantImages(images_anemone, metalheader4, 0));
var flower3_5 = registerFlower3('platinum anemone', 5, Res({infseeds:20e24}), Num(2500), Num(1), default_crop3_growtime, metalifyPlantImages(images_anemone, metalheader5, 5));

crop3_register_id = 1200;
var bee3_2 = registerBee3('silver bee nest', 2, Res({infseeds:200e9}), Num(4), Num(0.5), default_crop3_growtime, metalifyPlantImages(images_beenest, metalheader2, 0));
var bee3_3 = registerBee3('electrum bee nest', 3, Res({infseeds:10e15}), Num(32), Num(0.75), default_crop3_growtime, metalifyPlantImages(images_beenest, metalheader3, 4));
var bee3_4 = registerBee3('gold bee nest', 4, Res({infseeds:5e21}), Num(256), Num(1.5), default_crop3_growtime, metalifyPlantImages(images_beenest, metalheader4, 0));
var bee3_5 = registerBee3('platinum bee nest', 5, Res({infseeds:500e24}), Num(2048), Num(4), default_crop3_growtime, metalifyPlantImages(images_beenest, metalheader5, 1, 5, 6, 1.05));

// Time that runestone, or crops next to it, cannot be deleted. Reason for this long no-deletion time: to not make it so that you want to change layout of infinity field all the time between basic field or infinity field focused depending on whether you get some actual production in basic field
// the reason for 20 instead of 24 hours is to allow taking action slightly earlier next day, rather than longer
Expand All @@ -7639,12 +7692,14 @@ function haveInfinityField() {
////////////////////////////////////////////////////////////////////////////////

var fishtype_index = 0;
var FISHTYPE_GOLDFISH = fishtype_index++; // infinity field production bonus
var FISHTYPE_KOI = fishtype_index++; // infinity field to basic field bonus
var FISHTYPE_GOLDFISH = fishtype_index++; // infinity berry production bonus
var FISHTYPE_KOI = fishtype_index++; // runestone basic field boost bonus
var FISHTYPE_OCTOPUS = fishtype_index++; // infinity mushroom production bonus

function getFishTypeName(type) {
if(type == FISHTYPE_GOLDFISH) return 'Goldfish';
if(type == FISHTYPE_KOI) return 'Koi';
if(type == FISHTYPE_GOLDFISH) return 'goldfish';
if(type == FISHTYPE_KOI) return 'koi';
if(type == FISHTYPE_OCTOPUS) return 'octopus';
return 'unknown';
}

Expand Down Expand Up @@ -7725,14 +7780,24 @@ function registerKoi(name, tier, cost, effect_description, image, opt_tagline) {
return index;
}

function registerOctopus(name, tier, cost, effect_description, image, opt_tagline) {
var index = registerFish(name, FISHTYPE_OCTOPUS, tier, cost, effect_description, image, opt_tagline);
//var fish = fishes[index];
return index;
}

fish_register_id = 100;
var goldfish_0_bonus = 0.1;
var goldfish_0 = registerGoldfish('goldfish', 0, Res({infspores:5000}), 'Improves infinity seeds production by ' + Num(goldfish_0_bonus).toPercentString(), image_goldfish0);
var goldfish_0 = registerGoldfish('goldfish', 0, Res({infspores:5000}), 'Improves infinity berry production by ' + Num(goldfish_0_bonus).toPercentString(), image_goldfish0);

fish_register_id = 200;
var koi_0_bonus = 0.2;
var koi_0 = registerKoi('koi', 0, Res({infspores:20000}), 'Improves runestone bonus by ' + Num(koi_0_bonus).toPercentString(), image_koi0);

fish_register_id = 300;
var octopus_0_bonus = 0.25;
var octopus_0 = registerOctopus('octopus', 0, Res({infspores:100000}), 'Improves infinity mushroom production by ' + Num(octopus_0_bonus).toPercentString(), image_octopus0);

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -8601,6 +8666,12 @@ registerPlantTypeMedal3(brassica3_4);
registerPlantTypeMedal3(berry3_4);
registerPlantTypeMedal3(flower3_4);
registerPlantTypeMedal3(bee3_4);
registerPlantTypeMedal3(mush3_4);
registerPlantTypeMedal3(brassica3_5);
registerPlantTypeMedal3(berry3_5);
registerPlantTypeMedal3(flower3_5);
registerPlantTypeMedal3(bee3_5);
registerPlantTypeMedal3(mush3_5);



Expand Down
31 changes: 23 additions & 8 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,7 @@ function PreCell(x, y) {
this.flowerneighbor = false;

// how many flower neighbors of highest tier
// ideally heuristics are tier-independent, however there is a system for alternating whether flowers are upgraded next to berries and mushrooms and that needs to know the tiers
this.bestflowers = 0;

// set of relevant neighbor types brassica has, set in brassica cells, as bit flags: 1 = berry, 2 = mushroom, 4 = nuts
Expand Down Expand Up @@ -1846,7 +1847,8 @@ function precomputeField_(prefield, opt_pretend) {
var p = prefield[y][x];

var score_flower = 0;
var score_num = 0;
var score_num = 0; // num berries
var score_num_good = 0; // num berries with highest tier flower
var score_mul = 1;
var score_malus = 1;

Expand All @@ -1871,12 +1873,15 @@ function precomputeField_(prefield, opt_pretend) {
if(c2.type == CROPTYPE_FLOWER) score_flower += (1 + p.num_bee);
if(c2.type == CROPTYPE_BRASSICA) score_mul *= ((state.cropcount[brassica_0] > 4) ? 1.25 : 2) * (have_brassica_fruit ? 3 : 1);
if(c2.type == CROPTYPE_STINGING) score_mul++;
if((c2.type == CROPTYPE_BERRY || c2.type == CROPTYPE_PUMPKIN) && p2.bestflowers) score_num++;
if(c2.type == CROPTYPE_BERRY || c2.type == CROPTYPE_PUMPKIN) {
score_num++;
if(p2.bestflowers) score_num_good++;
}
}
}
if(c.type == CROPTYPE_MUSH) {
if(winter && !p.treeneighbor) score_malus *= 0.5;
p.score = (1 + score_flower) * score_mul * (score_num ? 1 : 0) * score_malus;
p.score = (1 + score_flower) * score_mul * (score_num ? 1 : 0) * (score_num_good ? 1.5 : 1) * score_malus;
}
}
}
Expand Down Expand Up @@ -2346,13 +2351,21 @@ function maybeUnlockInfinityCrops() {
if(state.crops3[berry3_4].had) unlockInfinityCrop(flower3_4);
if(state.crops3[flower3_4].had) unlockInfinityCrop(bee3_4);
if(state.crops3[berry3_4].had) unlockInfinityCrop(mush3_4);

if(state.crops3[berry3_4].had) unlockInfinityCrop(brassica3_5);
if(state.crops3[brassica3_5].had) unlockInfinityCrop(berry3_5);
if(state.crops3[berry3_5].had) unlockInfinityCrop(flower3_5);
if(state.crops3[flower3_5].had) unlockInfinityCrop(bee3_5);
if(state.crops3[berry3_5].had) unlockInfinityCrop(mush3_5);
}

// may only be called if the fishes feature in the infinity field is already unlocked (haveFishes() returns true)
function maybeUnlockFishes() {
var first_fish_unlocked = state.fishes[goldfish_0].unlocked;
unlockFish(goldfish_0);
unlockFish(koi_0);
//if(state.crops3[koi_0].had) unlockFish(octopus_0);
unlockFish(octopus_0);

var first_fish_unlocked2 = state.fishes[goldfish_0].unlocked;
if(!first_fish_unlocked && first_fish_unlocked2) showRegisteredHelpDialog(43);
Expand Down Expand Up @@ -5211,7 +5224,7 @@ var update = function(opt_ignorePause) {
if(g.seeds.lt(starter.seeds)) g.seeds = Num.max(g.seeds, starter.seeds);
if(g.seeds.ltr(10)) g.seeds = Num.max(g.seeds, Num(10));
var presentres = new Res({seeds:g.seeds});
if(basic) presentres = presentres.mulr(0.2);
if(basic) presentres = presentres.mulr(0.3);
if(holidayEventActive() == 1) {
showMessage('That present contained: ' + presentres.toString(), C_PRESENT, 38753631, 0.8, true);
} else {
Expand All @@ -5220,10 +5233,12 @@ var update = function(opt_ignorePause) {
actualgain.addInPlace(presentres);
} else if(effect == 2) {
// spores
var g = computeFernGain().mulr(60 * 5);
if(g.spores.ltr(1)) g.spores = Num.max(g.spores, Num(1));
var presentres = new Res({spores:g.spores});
if(basic) presentres = presentres.mulr(0.2);
var g = computeFernGain().spores.mulr(60 * 5);
var g2 = state.c_res.spores.mulr(0.0035); // in case there is no spore production, e.g. no mushrooms, give something based on spores produced so far anyway
if(g.lt(g2)) g = g2;
if(basic) g = g.mulr(0.3);
if(g.ltr(1)) g = Num.max(g, Num(1));
var presentres = new Res({spores:g});
if(holidayEventActive() == 1) {
showMessage('That present contained: ' + presentres.toString(), C_PRESENT, 38753631, 0.8, true);
} else {
Expand Down
Loading

0 comments on commit cdf41aa

Please sign in to comment.