Add IXP levels
This commit is contained in:
parent
ef304dedb9
commit
ba11c7c62f
@ -41,7 +41,7 @@ const next = computed(() => state.levels[state.ui.selectedLevel + 1])
|
|||||||
<h3 class="pt-3">Power Up</h3>
|
<h3 class="pt-3">Power Up</h3>
|
||||||
<p>Each power up doubles the number of {{ previous.units }} created every second</p>
|
<p>Each power up doubles the number of {{ previous.units }} created every second</p>
|
||||||
<UpgradeBuyer :cost="data.multiplierCost" :available="data.count"
|
<UpgradeBuyer :cost="data.multiplierCost" :available="data.count"
|
||||||
:units="data.units" @buy="data.upgradeMultiplier()"></UpgradeBuyer>
|
:units="data.units" @buy="data.upgradeMultiplier(state)"></UpgradeBuyer>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="(state.ui.selectedLevel != (state.count - 1)) && next.count >= 1">
|
<template v-if="(state.ui.selectedLevel != (state.count - 1)) && next.count >= 1">
|
||||||
<h3 class="pt-3">Bandwidth Efficiency</h3>
|
<h3 class="pt-3">Bandwidth Efficiency</h3>
|
||||||
|
@ -8,8 +8,9 @@ import UpgradeBuyer from './UpgradeBuyer.vue'
|
|||||||
const state = useState()
|
const state = useState()
|
||||||
const time = computed(() => state.services.time)
|
const time = computed(() => state.services.time)
|
||||||
const auto = computed(() => state.services.auto)
|
const auto = computed(() => state.services.auto)
|
||||||
|
const upgrade = computed(() => state.services.upgrade)
|
||||||
const anyUnlocked = computed(() => {
|
const anyUnlocked = computed(() => {
|
||||||
return (state.services.time.unlocked || state.services.auto.unlocked)
|
return (state.services.time.unlocked || state.services.auto.unlocked || state.services.upgrade.unlocked)
|
||||||
})
|
})
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
@ -20,6 +21,17 @@ const anyUnlocked = computed(() => {
|
|||||||
<h1>Services</h1>
|
<h1>Services</h1>
|
||||||
<p>Gain upgrades by introducing new services.</p>
|
<p>Gain upgrades by introducing new services.</p>
|
||||||
<template v-if="anyUnlocked">
|
<template v-if="anyUnlocked">
|
||||||
|
<div v-if="upgrade.unlocked">
|
||||||
|
<h2 class="mt-3">DN42 IXP</h2>
|
||||||
|
<p v-if="upgrade.level >= 2">You have purchased all the IXP based upgrades.</p>
|
||||||
|
<template v-else>
|
||||||
|
<p>Create a DN42 IXP to get more peers.</p>
|
||||||
|
<p class="m-0" v-if="upgrade.level == 0">More IXP traffic increases bandwidth efficiency.</p>
|
||||||
|
<p class="m-0" v-if="upgrade.level == 1">Your IXP becomes a metro wan providing a power up bonus.</p>
|
||||||
|
<UpgradeBuyer :cost="state.services.uCost()" :available="state.services.uValue(state)"
|
||||||
|
:units="state.services.uUnits(state)" @buy="state.services.uUpgrade(state)"></UpgradeBuyer>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
<div v-if="time.unlocked">
|
<div v-if="time.unlocked">
|
||||||
<h2 class="mt-3">Time Control</h2>
|
<h2 class="mt-3">Time Control</h2>
|
||||||
<p v-if="time.level >= 2">You have purchased all the time based upgrades.</p>
|
<p v-if="time.level >= 2">You have purchased all the time based upgrades.</p>
|
||||||
|
@ -24,7 +24,7 @@ export class Autobuyer {
|
|||||||
|
|
||||||
if (this.levels) {
|
if (this.levels) {
|
||||||
state.levels.forEach(l => {
|
state.levels.forEach(l => {
|
||||||
if (l.shouldAutobuy()) { l.upgradeMultiplier() }
|
if (l.shouldAutobuy()) { l.upgradeMultiplier(state) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,10 +52,20 @@ export class LevelTemplate {
|
|||||||
return this.count >= (this.multiplierCost * 2n)
|
return this.count >= (this.multiplierCost * 2n)
|
||||||
}
|
}
|
||||||
|
|
||||||
upgradeMultiplier() {
|
upgradeMultiplier(state) {
|
||||||
this.count -= this.multiplierCost
|
this.count -= this.multiplierCost
|
||||||
this.multiplier *= 2n
|
this.multiplier *= 2n
|
||||||
this.multiplierCost *= 12n
|
if (state.services.upgrade.level >=2) {
|
||||||
|
for(let i = state.levels.length - 1; i >= 0; i--) {
|
||||||
|
if (state.levels[i].unlocked) {
|
||||||
|
let multiplier = ((state.levels.length - i)*2) + 1
|
||||||
|
this.multiplierCost *= BigInt(multiplier)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.multiplierCost *= 11n
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
upgradeEfficiency(state) {
|
upgradeEfficiency(state) {
|
||||||
@ -65,7 +75,7 @@ export class LevelTemplate {
|
|||||||
let nextLevel = state.levels[this.index + 1]
|
let nextLevel = state.levels[this.index + 1]
|
||||||
nextLevel.count -= this.efficiencyCost
|
nextLevel.count -= this.efficiencyCost
|
||||||
this.efficiency *= 2n
|
this.efficiency *= 2n
|
||||||
this.efficiencyCost *= 11n
|
this.efficiencyCost *= (state.services.upgrade.level >= 1) ? 7n : 13n
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate max unit cost as percentage of previous level units
|
// calculate max unit cost as percentage of previous level units
|
||||||
|
@ -13,6 +13,10 @@ export class Services {
|
|||||||
unlocked: false,
|
unlocked: false,
|
||||||
level: 0
|
level: 0
|
||||||
}
|
}
|
||||||
|
this.upgrade = {
|
||||||
|
unlocked: false,
|
||||||
|
level: 0
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,7 +24,8 @@ export class Services {
|
|||||||
save() {
|
save() {
|
||||||
let save_data = {
|
let save_data = {
|
||||||
time: this.time,
|
time: this.time,
|
||||||
auto: this.auto
|
auto: this.auto,
|
||||||
|
upgrade: this.upgrade
|
||||||
}
|
}
|
||||||
return save_data
|
return save_data
|
||||||
}
|
}
|
||||||
@ -32,6 +37,7 @@ export class Services {
|
|||||||
tick(state, interval) {
|
tick(state, interval) {
|
||||||
if (state.levels[2].count > 0) { this.auto.unlocked = true }
|
if (state.levels[2].count > 0) { this.auto.unlocked = true }
|
||||||
if (state.levels[3].count > 0) { this.time.unlocked = true }
|
if (state.levels[3].count > 0) { this.time.unlocked = true }
|
||||||
|
if (state.levels[5].count > 0) { this.upgrade.unlocked = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
// time costs
|
// time costs
|
||||||
@ -47,15 +53,15 @@ export class Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tUnits(state) {
|
tUnits(state) {
|
||||||
return state.levels[(this.time.level*2)+3].units
|
return state.levels[(this.time.level * 2) + 3].units
|
||||||
}
|
}
|
||||||
|
|
||||||
tValue(state) {
|
tValue(state) {
|
||||||
return state.levels[(this.time.level*2)+3].count
|
return state.levels[(this.time.level * 2) + 3].count
|
||||||
}
|
}
|
||||||
|
|
||||||
tUpgrade(state) {
|
tUpgrade(state) {
|
||||||
state.levels[(this.time.level*2)+3].count -= this.tCost()
|
state.levels[(this.time.level * 2) + 3].count -= this.tCost()
|
||||||
this.time.level++
|
this.time.level++
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,18 +78,43 @@ export class Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
aUnits(state) {
|
aUnits(state) {
|
||||||
return state.levels[(this.auto.level*2)+2].units
|
return state.levels[(this.auto.level * 2) + 2].units
|
||||||
}
|
}
|
||||||
|
|
||||||
aValue(state) {
|
aValue(state) {
|
||||||
return state.levels[(this.auto.level*2)+2].count
|
return state.levels[(this.auto.level * 2) + 2].count
|
||||||
}
|
}
|
||||||
|
|
||||||
aUpgrade(state) {
|
aUpgrade(state) {
|
||||||
state.levels[(this.auto.level*2)+2].count -= this.aCost()
|
state.levels[(this.auto.level * 2) + 2].count -= this.aCost()
|
||||||
this.auto.level++
|
this.auto.level++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// auto costs
|
||||||
|
uCost() {
|
||||||
|
switch (this.upgrade.level) {
|
||||||
|
case 0:
|
||||||
|
return 1000000n
|
||||||
|
case 1:
|
||||||
|
return 1000000000n
|
||||||
|
default:
|
||||||
|
return 0n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uUnits(state) {
|
||||||
|
return state.levels[this.upgrade.level + 6].units
|
||||||
|
}
|
||||||
|
|
||||||
|
uValue(state) {
|
||||||
|
return state.levels[this.upgrade.level + 6].count
|
||||||
|
}
|
||||||
|
|
||||||
|
uUpgrade(state) {
|
||||||
|
state.levels[this.upgrade.level + 6].count -= this.uCost()
|
||||||
|
this.upgrade.level++
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -67,6 +67,12 @@ export const useState = defineStore('state', () => {
|
|||||||
|
|
||||||
// don't load older versions
|
// don't load older versions
|
||||||
if (version > save_data.version) { return }
|
if (version > save_data.version) { return }
|
||||||
|
if (typeof save_data.services.upgrade === 'undefined') {
|
||||||
|
save_data.services.upgrade = {
|
||||||
|
unlocked: false,
|
||||||
|
level: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ui.elapsed = save_data.elapsed
|
ui.elapsed = save_data.elapsed
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user