Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework Lizard Ecologists #107

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,7 @@ dojo.declare("com.nuclearunicorn.game.ui.BuildingBtnController", com.nuclearunic
}
}

this.metadataHasChanged(model);
this.game.upgrade(building.upgrades);
this.game.render();
},
Expand Down
42 changes: 41 additions & 1 deletion js/buildings.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan
effect = effectValue * bld.val;
} else {
effect = effectValue * bld.on;
if (bld.name == "magneto" && effectName == "magnetoRatio") {
effect += effectValue * bld.getPhantomMagnetos(bld, game);
}
}

//probably not the best place to handle this mechanics
Expand Down Expand Up @@ -438,7 +441,10 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan
effects["energyProduction"] *= 1 + game.getEffect("hydroPlantRatio");
stageMeta.effects = effects;
}
}
},
upgrades: {
buildings: ["magneto"]
}
},
//----------------------------------- Population ----------------------------------------
{
Expand Down Expand Up @@ -1323,11 +1329,38 @@ dojo.declare("classes.managers.BuildingsManager", com.nuclearunicorn.core.TabMan
"magnetoRatio": 0.02,
"cathPollutionPerTickProd": 5
},
calculateEffects: function(self, game) {
var maxPhantoms = self.getMaxPhantoms(self, game);
if (maxPhantoms > 0) {
self.description = $I("buildings.magneto.desc") + "<br>" + $I("buildings.magneto.phantoms", [maxPhantoms]);
} else {
self.description = $I("buildings.magneto.desc");
}
},
action: function(self, game){
var oil = game.resPool.get("oil");
if (oil.value + self.effects["oilPerTick"] <= 0){
self.on--;//Turn off one per tick until oil flow is sufficient
}
},
getMaxPhantoms: function(self, game) {
var hydroPlant = game.bld.getBuildingExt("aqueduct").meta;
if (hydroPlant.stage == 1 && game.science.getPolicy("lizardRelationsEcologists").researched) {
return Math.floor(Math.min(hydroPlant.on / 3, self.val * 0.8));
}
//Else, policy isn't active
return 0;
},
//Phantom Magnetos contribute to production bonus without consuming resources or producing pollution.
//Maybe this was a bad name. They're not like phantom Tradeposts.
//These ones have to be built & turned off.
getPhantomMagnetos: function(self, game) {
if (self.on == 0) {
//At least 1 real Magneto must be on to benefit from phantoms.
return 0;
}
//Can't benefit from more phantoms than there are inactive Magnetos
return Math.min(self.getMaxPhantoms(self, game), self.val - self.on);
}
},
{
Expand Down Expand Up @@ -2957,6 +2990,13 @@ dojo.declare("classes.ui.btn.BuildingBtnModernController", com.nuclearunicorn.ga

getName: function(model) {
var meta = model.metadata;
if (meta.name == "magneto") {
var phantoms = meta.getPhantomMagnetos(meta, this.game);
if (phantoms) {
return meta.label + " (" + meta.on + "+" + phantoms + "/" + meta.val + ")";
}
}

var name = this.inherited(arguments);

var sim = this.game.village.sim;
Expand Down
7 changes: 5 additions & 2 deletions js/science.js
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,10 @@ dojo.declare("classes.managers.ScienceManager", com.nuclearunicorn.core.TabManag
blocked: false,
isRelation: true,
blocks:["lizardRelationsPriests", "lizardRelationsDiplomats"],
calculateEffects: function(self,game){
upgrades: {
buildings: ["magneto"]
},
/*calculateEffects: function(self,game){
var cathPollution = Math.floor(game.bld.cathPollution);
if (cathPollution < 0.5e9) {
var boostRatio = Math.round(((0.5e9 - cathPollution) * 2 / 0.5e10) * 1e2) / 1e2;
Expand All @@ -1354,7 +1357,7 @@ dojo.declare("classes.managers.ScienceManager", com.nuclearunicorn.core.TabManag
}
game.upgrade({buildings: ["pasture", "aqueduct"]});

},
},*/
evaluateLocks: function(game){
return game.science.checkRelation("lizards", 20);
}
Expand Down
3 changes: 2 additions & 1 deletion res/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
"buildings.lumberMill.flavor": "Best log analysing tool",
"buildings.magneto.label": "Magneto",
"buildings.magneto.desc": "Improves your total resource production by 2%. Every Steamworks will boost this effect by 15%. Consumes oil.",
"buildings.magneto.phantoms": "Up to {0} inactive Magnetos can contribute to the production bonus.",
"buildings.mansion.label": "Mansion",
"buildings.mansion.desc": "A spacy mansion (each has a space for 1 kitten)",
"buildings.mansion.flavor": "The best shipping container available",
Expand Down Expand Up @@ -853,7 +854,7 @@
"policy.lizardRelationsDiplomats.label" : "Lizard Relations: Diplomats",
"policy.lizardRelationsDiplomats.desc" : "Lizards are a peaceful race. If you want to befriend the races of Cath, they are more than willing to contribute.<br>Each embassy with any race will now grant a 0.04% culture bonus, up to 15%.",
"policy.lizardRelationsEcologists.label" : "Lizard Relations: Ecologists",
"policy.lizardRelationsEcologists.desc" : "The lizards love nature and want to protect it. Their ecologists are experts on preventing pollution and at low pollution levels they can tune some of your green energy buildings, increasing their effectiveness.",
"policy.lizardRelationsEcologists.desc" : "The lizards love nature and want to protect it. Their ecologists are experts on operating green energy buildings. Depending on how many Hydro Plants are active, some of your Magnetos will still boost resource production even if turned off.",
"policy.lizardRelationsPriests.label" : "Lizard Relations: Priests",
"policy.lizardRelationsPriests.desc" : "The lizards share the kittens' love of the sun. Their priests would be happy to help The Order of the Sun.<br>Manuscripts will grant a small bonus to faith.",
"policy.openWoodlands.label" : "Open Woodlands",
Expand Down
Loading