mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
store multipliers as 10x for exactness
This commit is contained in:
parent
57678664d4
commit
b9c92d90c1
@ -55,11 +55,12 @@ export class HubGoals extends BasicSerializableObject {
|
|||||||
for (const upgradeId in upgrades) {
|
for (const upgradeId in upgrades) {
|
||||||
const tiers = upgrades[upgradeId];
|
const tiers = upgrades[upgradeId];
|
||||||
const level = this.upgradeLevels[upgradeId] || 0;
|
const level = this.upgradeLevels[upgradeId] || 0;
|
||||||
let totalImprovement = 1;
|
let totalImprovement = 10;
|
||||||
for (let i = 0; i < level; ++i) {
|
for (let i = 0; i < level; ++i) {
|
||||||
totalImprovement += tiers[i].improvement;
|
totalImprovement += tiers[i].improvement;
|
||||||
}
|
}
|
||||||
this.upgradeImprovements[upgradeId] = totalImprovement;
|
this.upgradeImprovements[upgradeId] =
|
||||||
|
(this.upgradeImprovementsExact[upgradeId] = totalImprovement) / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute current goal
|
// Compute current goal
|
||||||
@ -100,11 +101,18 @@ export class HubGoals extends BasicSerializableObject {
|
|||||||
*/
|
*/
|
||||||
this.upgradeImprovements = {};
|
this.upgradeImprovements = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores 10x the improvements for all upgrades, to be exact
|
||||||
|
* @type {Object<string, number>}
|
||||||
|
*/
|
||||||
|
this.upgradeImprovementsExact = {};
|
||||||
|
|
||||||
// Reset levels first
|
// Reset levels first
|
||||||
const upgrades = this.root.gameMode.getUpgrades();
|
const upgrades = this.root.gameMode.getUpgrades();
|
||||||
for (const key in upgrades) {
|
for (const key in upgrades) {
|
||||||
this.upgradeLevels[key] = 0;
|
this.upgradeLevels[key] = 0;
|
||||||
this.upgradeImprovements[key] = 1;
|
this.upgradeImprovements[key] = 1;
|
||||||
|
this.upgradeImprovementsExact[key] = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.computeNextGoal();
|
this.computeNextGoal();
|
||||||
@ -347,7 +355,8 @@ export class HubGoals extends BasicSerializableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.upgradeLevels[upgradeId] = (this.upgradeLevels[upgradeId] || 0) + 1;
|
this.upgradeLevels[upgradeId] = (this.upgradeLevels[upgradeId] || 0) + 1;
|
||||||
this.upgradeImprovements[upgradeId] += tierData.improvement;
|
this.upgradeImprovements[upgradeId] =
|
||||||
|
(this.upgradeImprovementsExact[upgradeId] += tierData.improvement) / 10;
|
||||||
|
|
||||||
this.root.signals.upgradePurchased.dispatch(upgradeId);
|
this.root.signals.upgradePurchased.dispatch(upgradeId);
|
||||||
|
|
||||||
|
@ -98,11 +98,12 @@ export class HUDSandboxController extends BaseHUDPart {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Compute improvement
|
// Compute improvement
|
||||||
let improvement = 1;
|
let improvement = 10;
|
||||||
for (let i = 0; i < this.root.hubGoals.upgradeLevels[id]; ++i) {
|
for (let i = 0; i < this.root.hubGoals.upgradeLevels[id]; ++i) {
|
||||||
improvement += upgradeTiers[i].improvement;
|
improvement += upgradeTiers[i].improvement;
|
||||||
}
|
}
|
||||||
this.root.hubGoals.upgradeImprovements[id] = improvement;
|
this.root.hubGoals.upgradeImprovements[id] =
|
||||||
|
(this.root.hubGoals.upgradeImprovementsExact[id] = improvement) / 10;
|
||||||
this.root.signals.upgradePurchased.dispatch(id);
|
this.root.signals.upgradePurchased.dispatch(id);
|
||||||
this.root.hud.signals.notification.dispatch(
|
this.root.hud.signals.notification.dispatch(
|
||||||
"Upgrade '" + id + "' is now at tier " + (this.root.hubGoals.upgradeLevels[id] + 1),
|
"Upgrade '" + id + "' is now at tier " + (this.root.hubGoals.upgradeLevels[id] + 1),
|
||||||
|
@ -99,7 +99,7 @@ export class HUDShop extends BaseHUDPart {
|
|||||||
// Set description
|
// Set description
|
||||||
handle.elemDescription.innerText = T.shopUpgrades[upgradeId].description
|
handle.elemDescription.innerText = T.shopUpgrades[upgradeId].description
|
||||||
.replace("<currentMult>", formatBigNumber(currentTierMultiplier))
|
.replace("<currentMult>", formatBigNumber(currentTierMultiplier))
|
||||||
.replace("<newMult>", formatBigNumber(currentTierMultiplier + tierHandle.improvement));
|
.replace("<newMult>", formatBigNumber(currentTierMultiplier + tierHandle.improvement / 10));
|
||||||
|
|
||||||
tierHandle.required.forEach(({ shape, amount }) => {
|
tierHandle.required.forEach(({ shape, amount }) => {
|
||||||
const container = makeDiv(handle.elemRequirements, null, ["requirement"]);
|
const container = makeDiv(handle.elemRequirements, null, ["requirement"]);
|
||||||
|
@ -79,7 +79,8 @@ function generateUpgrades(limitedVersion = false) {
|
|||||||
return upgradesCache[limitedVersion];
|
return upgradesCache[limitedVersion];
|
||||||
}
|
}
|
||||||
|
|
||||||
const fixedImprovements = [0.5, 0.5, 1, 1, 2, 1, 1];
|
// 10x actual amount so all numbers are exact
|
||||||
|
const fixedImprovements = [5, 5, 10, 10, 20, 10, 10];
|
||||||
const numEndgameUpgrades = limitedVersion ? 0 : 1000 - fixedImprovements.length - 1;
|
const numEndgameUpgrades = limitedVersion ? 0 : 1000 - fixedImprovements.length - 1;
|
||||||
|
|
||||||
function generateInfiniteUnlocks() {
|
function generateInfiniteUnlocks() {
|
||||||
@ -96,13 +97,13 @@ function generateUpgrades(limitedVersion = false) {
|
|||||||
// Fill in endgame upgrades
|
// Fill in endgame upgrades
|
||||||
for (let i = 0; i < numEndgameUpgrades; ++i) {
|
for (let i = 0; i < numEndgameUpgrades; ++i) {
|
||||||
if (i < 20) {
|
if (i < 20) {
|
||||||
fixedImprovements.push(0.1);
|
fixedImprovements.push(1);
|
||||||
} else if (i < 50) {
|
} else if (i < 50) {
|
||||||
fixedImprovements.push(0.05);
|
fixedImprovements.push(0.5);
|
||||||
} else if (i < 100) {
|
} else if (i < 100) {
|
||||||
fixedImprovements.push(0.025);
|
fixedImprovements.push(0.25);
|
||||||
} else {
|
} else {
|
||||||
fixedImprovements.push(0.0125);
|
fixedImprovements.push(0.125);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user