Open eternaldensity opened 10 years ago
This is desperately needed: if you Glass Saw away your Tool Factory chips then AA goes back into serious bog-down mode.
As requested the code is now here...
==================================================================================================================
// Change in philosophy -
// The department flags is only used for a few boosts where the logic to award the boost is distant from its use
// There is an array AvailRewards that is fairly static (updated when needed and the ReCheckDoRD flag is set)
// and is used for most awards, when Automation level is needed the boosts it could also allow (crate key and PP
// are appended to a copy for the choice to be made.
// Many of the tests in CheckStaticDoRD are arranged to minimise the load (particularly in advanced games)
// tested to the level it does not crash and appears to work (only)
==================================================================================================================
// New Code for castle.js (or data.js)
Molpy.AvailRewards = [];
Molpy.ReCheckDoRD = 1;
Molpy.AwardDoRD = function(automationLevel)
{
var Rewards = [];
if (Molpy.ReCheckDoRD) Molpy.CheckStaticDoRD();
if (automationLevel > 8) // whatever is the lowest value in the code below
{
Rewards = Molpy.AvailRewards.slice(); // This does an array copy
if (!Molpy.Got('Crate Key') && (key.logic&&automationLevel>=10&&Math.floor(Math.random()*3)==0&&Molpy.Got('Keygrinder'))) Rewards.push(Molpy.Boosts['Crate Key']);
if (automationLevel>8&&Molpy.redactedClicks>2500&&Molpy.Got('Caged Logicat')&&Molpy.Boosts['Caged Logicat'].bought<4&&Math.floor(Math.random()*4)==0) Rewards.push(Molpy.Boosts['Panther Poke']);
}
else
{
Rewards = Molpy.AvailRewards
}
if (!Rewards.length) return 0;
var red=GLRschoice(Rewards);
if((EvalMaybeFunction(red.sandPrice,red)+EvalMaybeFunction(red.castlePrice,red)+EvalMaybeFunction(red.glassPrice,red)))
{
Molpy.Notify('The DoRD has produced:',1);
Molpy.UnlockBoost(red.aka);
}else{
Molpy.Notify('The DoRD has provided:',1);
Molpy.GiveTempBoost(red.aka,red.startPower,red.startCountdown);
}
return 1;
}
===========================================================================
// Replace the following part of RewardRedacted in castle.js
Molpy.CheckRewards(automationLevel);
var availRewards=[];
for(var i in Molpy.Boosts)
{
var me=Molpy.Boosts[i];
if(!me.unlocked&&me.department)
{
availRewards.push(me);
}
}
if(availRewards.length)
{
var red=GLRschoice(availRewards);
if((EvalMaybeFunction(red.sandPrice,red)+EvalMaybeFunction(red.castlePrice,red)+EvalMaybeFunction(red.glassPrice,red)))
{
Molpy.Notify('The DoRD has produced:',1);
Molpy.UnlockBoost(red.aka);
}else{
Molpy.Notify('The DoRD has provided:',1);
Molpy.GiveTempBoost(red.aka,red.startPower,red.startCountdown);
}
return;
}
// With:
if (Molpy.AwardDoRD(automationLevel)) return;
========================================================================
// New code replaces CheckRewards in data.js
Molpy.CheckStaticDoRD=function()
{
Molpy.AvailRewards = [];
Molpy.ReCheckDoRD = 0;
if (!Molpy.Got('Blast Furnace') && Molpy.Got('Factory Automation')) Molpy.AvailRewards.push(Molpy.Boosts['Blast Furnace']);
if (!Molpy.Got('Castle Crusher') && Molpy.Got('SBTF')) Molpy.AvailRewards.push(Molpy.Boosts['Castle Crusher']);
if (!Molpy.Got('Ninja League') && Molpy.Earned('Ninja Omnipresence') && Molpy.Got('Active Ninja')) Molpy.AvailRewards.push(Molpy.Boosts['Ninja League']);
if (!Molpy.Got('Ninja Legion') && Molpy.Earned('Ninja Pact') && Molpy.Got('Ninja League')) Molpy.AvailRewards.push(Molpy.Boosts['Ninja Legion']);
if (!Molpy.Got('RRR') && Molpy.Boosts['Panther Salve'].power > 200) Molpy.AvailRewards.push(Molpy.Boosts['RRR']);
if (!Molpy.Got('Phonesaw') && Molpy.Boosts['VJ'].power >=88) Molpy.AvailRewards.push(Molpy.Boosts['Phonesaw']);
if (!Molpy.Got('Facebugs') && (Molpy.groupBadgeCounts.discov>20&&Molpy.Got('Ch*rpies'))) Molpy.AvailRewards.push(Molpy.Boosts['Facebugs']);
if (!Molpy.Got('Badgers') && (Molpy.groupBadgeCounts.monums>20&&Molpy.Got('Facebugs'))) Molpy.AvailRewards.push(Molpy.Boosts['Badgers']);
if (!Molpy.Got('Fractal Fractals') && (Molpy.Boosts['Fractal Sandcastles'].power>=120)) Molpy.AvailRewards.push(Molpy.Boosts['Fractal Fractals']);
if (!Molpy.Got('Schizoblitz') && (Molpy.Got('Air Drop'))) Molpy.AvailRewards.push(Molpy.Boosts['Schizoblitz']);
if (!Molpy.Got('Glass Ceiling 0') && (Molpy.Got('Free Advice'))) Molpy.AvailRewards.push(Molpy.Boosts['Glass Ceiling 0']);
if (!Molpy.Got('BBC') && Molpy.Got('Free Advice') && (Molpy.Earned('Beachomancer'))) Molpy.AvailRewards.push(Molpy.Boosts['BBC']);
if (!Molpy.Got('Ruthless Efficiency') && (Molpy.Boosts['Glass Chiller'].power>=1234)) Molpy.AvailRewards.push(Molpy.Boosts['Ruthless Efficiency']);
if (!Molpy.Got('Break the Mould') && (Molpy.Boosts['Break the Mould'].power>=100)) Molpy.AvailRewards.push(Molpy.Boosts['Break the Mould']);
if (!Molpy.Got('PC') && (Molpy.Got('Tool Factory')&&Molpy.CastleTools['NewPixBot'].amount>=5000)) Molpy.AvailRewards.push(Molpy.Boosts['PC']);
if (!Molpy.Got('GM') && (Molpy.chipsManual>=1e6)) Molpy.AvailRewards.push(Molpy.Boosts['GM']);
if (!Molpy.Got('GL') && (Molpy.chipsManual>=5e6)) Molpy.AvailRewards.push(Molpy.Boosts['GL']);
if (!Molpy.Got('Logicat') && (Molpy.redactedClicks>=776)) Molpy.AvailRewards.push(Molpy.Boosts['Logicat']);
if (!Molpy.Got('Technicolour Dream Cat') && (Molpy.redactedClicks>=431)) Molpy.AvailRewards.push(Molpy.Boosts['Technicolour Dream Cat']);
if (Molpy.Earned('Ceiling Broken'))
{
var i = 10;
while(i--)
{
if (!Molpy.Got('Glass Ceiling '+i)) Molpy.AvailRewards.push(Molpy.Boosts['Glass Ceiling '+i]);
}
}
if (Molpy.Earned('Ceiling Disintegrated'))
{
if (!Molpy.Got('Glass Ceiling 10')) Molpy.AvailRewards.push(Molpy.Boosts['Glass Ceiling 10']);
if (!Molpy.Got('Glass Ceiling 11')) Molpy.AvailRewards.push(Molpy.Boosts['Glass Ceiling 11']);
}
if (!Molpy.Earned('Machine Learning'))
{
var found=0;
for(var i in Molpy.jDipBoosts)
{
var me = Molpy.Boosts[Molpy.jDipBoosts[i]];
if (!Molpy.Got(me.aka))
{
if (me.department) Molpy.AvailRewards.push(me);
}
else
{
found++;
}
}
if(found==Molpy.jDipBoosts.length) Molpy.EarnBadge('Machine Learning');
}
if(Molpy.newpixNumber > 240)
{
if (!Molpy.Got('Doublepost')) Molpy.AvailRewards.push(Molpy.Boosts['Doublepost']);
if (!Molpy.Got('Active Ninja')) Molpy.AvailRewards.push(Molpy.Boosts['Active Ninja']);
if (!Molpy.Got('Furnace Crossfeed') && (Molpy.Got('Glass Furnace'))) Molpy.AvailRewards.push(Molpy.Boosts['Furnace Crossfeed']);
if (!Molpy.Got('Furnace Multitasking') && (Molpy.Got('Furnace Crossfeed'))) Molpy.AvailRewards.push(Molpy.Boosts['Furnace Multitasking']);
if (!Molpy.Got('Redunception') && (Molpy.redactedClicks>=320 && (Molpy.Got('Overcompensating') || Molpy.Got('Doublepost')))) Molpy.AvailRewards.push(Molpy.Boosts['Redunception']);
}
if (!Molpy.Got('Kitties Galore') && (Molpy.redactedClicks>=64)) Molpy.AvailRewards.push(Molpy.Boosts['Kitties Galore']);
if (!Molpy.Got('BFJ') && Molpy.Boosts['BKJ'].power>24) Molpy.AvailRewards.push(Molpy.Boosts['BFJ']);
// Department is not used much now ...
if (Molpy.Boosts['Double or Nothing'].department) Molpy.AvailRewards.push(Molpy.Boosts['Double or Nothing']);
if (Molpy.Boosts['Temporal Rift'].department) Molpy.AvailRewards.push(Molpy.Boosts['Temporal Rift']);
if (!Molpy.Got('Flux Capacitor') && Molpy.Boosts['Flux Capacitor'].department) Molpy.AvailRewards.push(Molpy.Boosts['Flux Capacitor']);
if (!Molpy.Got('Blackprints') && Molpy.CheckBlackprintDepartment()) Molpy.AvailRewards.push(Molpy.Boosts['Blackprints']);
if (Molpy.CheckASHF()) Molpy.AvailRewards.push(Molpy.Boosts['ASHF']);
// Crate Key and Panther Poke are deliberatly not here as they depend on Automation level
// if (!Molpy.Got('') && ) Molpy.AvailRewards.push(Molpy.Boosts['']);
}
====================================================================================
// Change the start of Molpy.HandlePeriods in castle.js to this (some redundancy removed and all the short/longpix stuff is here):
Molpy.HandlePeriods=function()
{
//check length of current newpic
if(Molpy.newpixNumber <= 240)
{
Molpy.NPlength=1800;
Molpy.LockBoost('Overcompensating');
Molpy.LockBoost('Doublepost');
Molpy.LockBoost('Active Ninja');
Molpy.LockBoost('Furnace Crossfeed');
Molpy.LockBoost('Redunception');
var fa = Molpy.Boosts['Factory Automation'];
if(fa.power>0 &&!Molpy.Got('SG'))
{
fa.power=0;
Molpy.Notify('Factory Automation Downgraded',1);
}
}else
{
Molpy.NPlength=3600;
}
// Rest as before
// Replace ============================================================== in data.js
Molpy.CheckBlackprintDepartment=function()
{
var pages = Molpy.Boosts['Blackprints'].power;
if(!pages)return 0;
for(var i in Molpy.blackprintOrder)
{
var print=Molpy.blackprintOrder[i];
var pboost=Molpy.Boosts[print];
if(!pboost.unlocked) return 1;
}
}
// Replace ========================================================== in data.js
Molpy.CheckASHF=function()
{
if(Molpy.BoostsInShop.length) return 1;
if(!isFinite(Molpy.castles)) return 0;
for(var i in Molpy.SandTools)
{
if(isFinite(Molpy.priceFactor*Molpy.SandTools[i].price)) return 1;
}
for(var i in Molpy.CastleTools)
{
if(isFinite(Molpy.priceFactor*Molpy.CastleTools[i].price)) return 1;
}
}
==============================================================
Delete from Molpy.ClickRedacted these 2 lines:
if(Molpy.redactedClicks>=64)
Molpy.Boosts['Kitties Galore'].department=1;
Delete from RewardBlitzing this line:
if(BKJ.power>24) Molpy.Boosts['BFJ'].department=1;
==============================================================
// Setting the ReCheckDoRD flag:
Molpy.ReCheckDoRD = 1;
// Add this in the following 6 locations:
// 1: To Molpy.Boost.buy (where the purchase happens)
// 2: To Molpy.ClickRedacted (at the end)
// 3: To Molpy.TTT (where the travel happens anywhere)
// 4: To Molpy.ONG (After the newpixnumber has been changed)
// 5: To RewardBlitzing (Replacing the line that was deleted above)
// 6: To Molpy.FromNeedlePulledThing (Probably after the version checks)
This doesn't seem to be so necessary now, since it turns out the main issue was tool price recalculation. But it still looks like a good thing to do at some point.
It's called whenever the DoRD or Logicats give out rewards, and skipping it is a major reason why the changes to AA help, I think.
Anyhow, there's a lot which really doesn't need to be recalculated every single time.