diff --git a/components/GameTab.vue b/components/GameTab.vue index 31c1761..2dd91ac 100644 --- a/components/GameTab.vue +++ b/components/GameTab.vue @@ -4,7 +4,7 @@ :class="[colorClasses, { active }]" :to="tabData.route" > - + diff --git a/components/ProgressButton.vue b/components/ProgressButton.vue index d7a8dfb..10ccc57 100644 --- a/components/ProgressButton.vue +++ b/components/ProgressButton.vue @@ -17,6 +17,7 @@ / L{{ maxText }} + p.created) .forEach((process, index) => { @@ -65,6 +66,14 @@ export default { this.$store.commit('tickProcess', { process }) }) + + // Energy ticks + if ( + this.$store.getters.isTabUnlocked('Time Machine') && + this.$store.state.energy < this.$store.state.energyMax + ) { + this.$store.commit('tickEnergy') + } }, }, } diff --git a/pages/Apprentices.vue b/pages/Apprentices.vue index f705979..be406e5 100644 --- a/pages/Apprentices.vue +++ b/pages/Apprentices.vue @@ -12,7 +12,7 @@ export default { computed: { unlocked() { - return this.$store.state.processes.filter((p) => p.unlocked) + return this.$store.state.processes.filter((p) => p.unlocked && p.created) }, }, } diff --git a/pages/Missions.vue b/pages/Missions.vue index 444b2e2..2e71d02 100644 --- a/pages/Missions.vue +++ b/pages/Missions.vue @@ -68,9 +68,25 @@ export default { methods: { complete(mission) { this.$store.commit('completeMission', mission.name) + if (mission.completionCriteria.unit === 'spareTime') { this.$store.commit('spendCurrency', mission.completionCriteria.value) } + + if (mission.name === 'Study Time Magic') { + this.$store.commit('unlockTab', 'Time Magic') + } + + if (mission.name === 'Create the Time Machine') { + this.$store.commit('unlockTab', 'Time Machine') + } + + if (mission.name === 'Time to Cheat Death') { + this.$store.commit('unlockTab', 'Wisdom') + this.$store.commit('setPlayerAge', { year: 30 }) + this.$store.commit('timeTravel', { year: 1400 }) + this.$store.commit('tickLifetime') + } }, }, } diff --git a/pages/TimeMachine.vue b/pages/TimeMachine.vue index 6bebde0..ac47b51 100644 --- a/pages/TimeMachine.vue +++ b/pages/TimeMachine.vue @@ -1,3 +1,69 @@ + + + + diff --git a/pages/TimeMagic.vue b/pages/TimeMagic.vue index e302a61..c12d857 100644 --- a/pages/TimeMagic.vue +++ b/pages/TimeMagic.vue @@ -1,3 +1,3 @@ diff --git a/pages/Wisdom.vue b/pages/Wisdom.vue index d98f12f..28b87c8 100644 --- a/pages/Wisdom.vue +++ b/pages/Wisdom.vue @@ -13,8 +13,8 @@ >
- Total lifetimes{{ $store.state.totalLifetimes }} + Completed lifetimes{{ $store.state.lifetimes }}
Longest lifetime ({ darkColor: 'amber-900', color: 'amber-400', lightColor: 'amber-200', - locked: false, + unlocked: true, }, { route: '/apprentices', @@ -19,7 +19,7 @@ export const state = () => ({ darkColor: 'rose-900', color: 'rose-400', lightColor: 'rose-200', - locked: false, + unlocked: false, }, { route: '/missions', @@ -28,7 +28,7 @@ export const state = () => ({ darkColor: 'sky-900', color: 'sky-400', lightColor: 'sky-200', - locked: false, + unlocked: false, }, { route: '/timemachine', @@ -37,7 +37,7 @@ export const state = () => ({ darkColor: 'lime-900', color: 'lime-400', lightColor: 'lime-200', - locked: false, + unlocked: false, }, { route: '/timemagic', @@ -46,7 +46,7 @@ export const state = () => ({ darkColor: 'violet-900', color: 'violet-400', lightColor: 'violet-200', - locked: false, + unlocked: false, }, { route: '/wisdom', @@ -55,11 +55,16 @@ export const state = () => ({ darkColor: 'teal-900', color: 'teal-400', lightColor: 'teal-100', - locked: false, + unlocked: false, }, ], - currency: new Decimal(0), + + currency: new Decimal(10000), currencyTotal: new Decimal(0), + + energy: 0, + energyMax: 600, // 60 seconds + processes: [ { instrument: 'Atlantean Clock', @@ -390,8 +395,8 @@ export const state = () => ({ 'Write a book to pass your knowedge to your younger self through the time machine. ' + "Now where's your pen...", unlockCriteria: { - unit: 'timeJumpsBackwards', - value: 1, + unit: 'missionsCompleted', + value: ['Create the Time Machine'], }, completionCriteria: { unit: 'maxAge', @@ -421,7 +426,7 @@ export const state = () => ({ resetOnPrestige: false, }, { - name: 'Time to Cheat Death... Again', + name: 'Cheat Death... Again', description: 'Another life well lived. ' + 'Add a few chapters to the tome you received and send it back again.', @@ -439,13 +444,41 @@ export const state = () => ({ }, ], + timeMachineActions: [ + { + name: 'Activate!', + description: 'Will it work?? Only one way to find out!', + cost: 600, + unlocked: true, + }, + { + name: 'Jump Forwards a Lot', + description: 'This time is boring. You yearn for more interesting times.', + cost: 1000, + unlocked: true, + }, + { + name: 'Loop Back Around', + description: '...', + cost: 2000, + unlocked: true, + }, + { + name: 'Jump Forwards a Little', + description: + 'Visit your apprentices a few years into the future to benefit from the fruits of their labor.', + cost: 300, + unlocked: true, + }, + ], + gameDate: 1400 * 12, playerAge: 30 * 12, playerAgeMax: 60 * 12, playerLivedTotal: 0, wisdomGained: 0, // wisdom gained so far on this run, not applied until player sends the book. wisdomApplied: 0, // wisdom from previous runs - totalLifetimes: 1, + lifetimes: 0, // comleted lifetimes timeJumpsBackwards: 0, }) @@ -456,6 +489,9 @@ export const getters = { (tab) => tab.route === $nuxt.$route.path ) }, + isTabUnlocked: (state) => (title) => { + return state.tabs.find((t) => t.title === title).unlocked + }, canTimeTravel: (state) => { if (state.playerAge.year < state.playerAgeMax.year) return true if (state.playerAge.year > state.playerAgeMax.year) return false @@ -539,6 +575,10 @@ export const mutations = { value = Decimal.mul(value, -1) state.currency = Decimal.add(state.currency, value) }, + unlockTab: (state, title) => { + const index = state.tabs.findIndex((t) => t.title === title) + Vue.set(state.tabs[index], 'unlocked', true) + }, createInstrument: (state, instrument) => { const index = state.processes.findIndex((p) => p.instrument === instrument) Vue.set(state.processes[index], 'created', true) @@ -587,6 +627,18 @@ export const mutations = { state.playerAge += 1 if (!(state.playerAge % 12)) state.wisdomGained++ }, + tickEnergy: (state) => { + state.energy += 1 + }, + spendEnergy: (state, amount) => { + if (amount <= state.energy) { + state.energy -= amount + } + }, + unlockTimeMachineAction: (state, name) => { + const index = state.timeMachineActions.findIndex((t) => t.name === name) + Vue.set(state.tabs[index], 'unlocked', true) + }, travelGameDate: (state, month) => { state.gameDate = month }, @@ -594,7 +646,7 @@ export const mutations = { state.currency = new Decimal(0) state.wisdomApplied += state.wisdomGained state.wisdomGained = 0 - state.totalLifetimes += 1 + state.lifetimes += 1 state.timeJumpsBackwards += 1 state.playerLivedTotal += state.playerAge // TODO: refactor next 3 lines if getters can be used in mutators: missionIsCompleted('Time Travel Precision') @@ -610,5 +662,19 @@ export const mutations = { state.gameDate = 1378 * 12 } }, - doTimeTravel: (state, monthNumber) => {}, + timeTravel: (state, { year, month = 0 }) => { + const newYear = year * 12 + month + + if (newYear < state.gameDate) { + state.timeJumpsBackwards += 1 + } + + state.gameDate = newYear + }, + setPlayerAge: (state, { year, month = 0 }) => { + state.playerAge = year * 12 + month + }, + tickLifetime: (state) => { + state.lifetimes += 1 + }, }