feat: magic game flow 1

This commit is contained in:
pskfyi 2022-01-13 21:38:19 -08:00 committed by pskfyi
parent 45fc84b3db
commit 5029bb70fb
5 changed files with 278 additions and 61 deletions

View File

@ -0,0 +1,50 @@
<template>
<progress-button
:label="action.name"
:description="action.description"
:max="100"
:value="$store.state.mana"
:current="current"
:next="next"
@click="doAction"
/>
</template>
<script>
export default {
props: {
action: { type: Object, required: true },
},
computed: {
current() {
return this.action.name === 'Empower the Stone'
? this.$store.state.philosophersStoneIncrement
: undefined
},
next() {
return this.action.name === 'Empower the Stone'
? this.$store.state.philosophersStoneIncrement + 6
: undefined
},
},
methods: {
doAction() {
this.$store.commit('spendMana', 100)
if (this.action.name === 'Empower the Stone') {
this.$store.commit('increasePhilosophersStoneIncrement', 6)
} else if (this.action.name === 'Forever Young') {
this.$store.commit(
'decreaseAge',
this.$store.state.philosophersStoneIncrement
)
} else if (this.action.name === 'Necromancy') {
this.$store.commit(
'extendLifespan',
this.$store.state.philosophersStoneIncrement
)
}
},
},
}
</script>

View File

@ -0,0 +1,34 @@
<template>
<progress-button
:label="spell.name"
:description="spell.description"
:max="100"
:value="$store.state.mana"
:current="current"
:next="next"
@click="doAction"
/>
</template>
<script>
export default {
props: {
spell: { type: Object, required: true },
},
computed: {
current() {
//
return undefined
},
next() {
//
return undefined
},
},
methods: {
cast() {
//
},
},
}
</script>

View File

@ -41,6 +41,10 @@ export default {
return unlockCriteria.value.every((name) =>
this.$store.getters.missionIsCompleted(name)
)
} else if (unlockCriteria.unit === 'eraVisited') {
return this.$store.state.processes.find(
(p) => p.unlockEra === unlockCriteria.value
).visited
} else if (unlockCriteria.unit === 'timeJumpsBackwards') {
return unlockCriteria.value <= this.$store.state.timeJumpsBackwards
} else {
@ -77,6 +81,10 @@ export default {
this.$store.commit('timeTravel', { year: 1400, era: 'Early Modern' })
this.$store.commit('tickLifetime')
}
if (mission.name === 'Live Forever') {
this.$store.commit('unlockPhilosophersStone')
}
},
},
}

View File

@ -27,9 +27,46 @@
now also gains
<b><span class="fas fa-star text-base" /> Mana</b>
</p>
<h2 class="text-xl font-semibold text-center pt-8">Spells</h2>
<responsive-grid min="1" mid="1" max="1" class="pt-2 md:pt-4 text-center">
<p>Spells coming soon!</p>
</responsive-grid>
<h2 class="text-xl font-semibold text-center pt-8">Philosopher's Stone</h2>
<responsive-grid class="pt-2 md:pt-4">
<philosophers-stone-button
v-for="action in $store.state.philosophersStoneActions"
:key="action.name"
:action="action"
/>
</responsive-grid>
</div>
</template>
<script>
import PhilosophersStoneButton from '~/components/PhilosophersStoneButton.vue'
export default {
components: { PhilosophersStoneButton },
data() {
return {
riteOfChronosTime: 300,
}
},
methods: {
castSpell(name) {
this.$store.commit('spendMana', 100)
if (name === 'Rite of Chronos') {
//
}
},
},
}
</script>
<style scoped>
.mana-bar {
width: 75%;

View File

@ -62,13 +62,17 @@ export const state = () => ({
currency: new Decimal(10000),
currencyTotal: new Decimal(0),
energy: 0,
energyMax: 600, // 60 seconds
fluxCapacitorLevel: 1,
nextFluxCapacitorCost: 500,
gameDate: 1400 * 12,
gameEra: 'Early Modern',
mana: 0,
manaMax: 100,
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
lifetimes: 0, // comleted lifetimes
timeJumpsBackwards: 0,
processes: [
{
@ -354,6 +358,7 @@ export const state = () => ({
},
],
// Missions
missions: [
{
name: 'Train an Apprentice',
@ -365,37 +370,20 @@ export const state = () => ({
},
completionCriteria: {
unit: 'apprenticeLevels',
value: 5,
value: 3,
},
unlocked: true,
viewed: false,
complete: false,
resetOnPrestige: false,
},
{
name: 'Study Time Magic',
description:
"As time ticks away you begin to ponder the mysteries of time's origins and possibilities.",
unlockCriteria: {
unit: 'apprenticeLevels',
value: 1,
},
completionCriteria: {
unit: 'spareTime',
value: 250,
},
unlocked: true,
viewed: false,
complete: false,
resetOnPrestige: true,
},
{
name: 'Create the Time Machine',
description:
'Your magnum opus. Soon you will be able to control time itself.',
unlockCriteria: {
unit: 'missionsCompleted',
value: ['Train an Apprentice', 'Study Time Magic'],
value: ['Train an Apprentice'],
},
completionCriteria: {
unit: 'spareTime',
@ -406,6 +394,23 @@ export const state = () => ({
complete: false,
resetOnPrestige: false,
},
{
name: 'Study Time Magic',
description:
"As time ticks away you begin to ponder the mysteries of time's origins and possibilities.",
unlockCriteria: {
unit: 'eraVisited',
value: 'Middle Ages',
},
completionCriteria: {
unit: 'spareTime',
value: 250,
},
unlocked: true,
viewed: false,
complete: false,
resetOnPrestige: true,
},
{
name: 'Time to Cheat Death',
description:
@ -424,25 +429,42 @@ export const state = () => ({
complete: false,
resetOnPrestige: false,
},
{
// update doPrestige (mutation) if this is renamed
name: 'Time Travel Precision',
description:
'The time machine could target a certain month instead of a decade, ' +
'with the proper calibration.',
unlockCriteria: {
unit: 'missionsCompleted',
value: ['Time to Cheat Death', 'Create the Time Machine'],
},
completionCriteria: {
unit: 'spareTime',
value: 10000,
},
unlocked: false,
viewed: false,
complete: false,
resetOnPrestige: false,
},
// {
// // update doPrestige (mutation) if this is renamed
// name: 'Time Travel Precision',
// description:
// 'The time machine could target a certain month instead of a decade, ' +
// 'with the proper calibration.',
// unlockCriteria: {
// unit: 'missionsCompleted',
// value: ['Time to Cheat Death', 'Create the Time Machine'],
// },
// completionCriteria: {
// unit: 'spareTime',
// value: 10000,
// },
// unlocked: false,
// viewed: false,
// complete: false,
// resetOnPrestige: false,
// },
// {
// name: 'Live Forever',
// description:
// "Seek out the philosopher's stone so that you can extend your lifespan.",
// unlockCriteria: {
// unit: 'eraVisited',
// value: 'Middle Ages',
// },
// completionCriteria: {
// unit: 'spareTime',
// value: 2000,
// },
// unlocked: false,
// viewed: false,
// complete: false,
// resetOnPrestige: false,
// },
{
name: 'Cheat Death... Again',
description:
@ -462,6 +484,12 @@ export const state = () => ({
},
],
// Time Machine
energy: 599,
energyMax: 600, // 60 seconds
fluxCapacitorLevel: 1,
nextFluxCapacitorCost: 500,
timeMachineActions: [
{
name: 'Activate!',
@ -490,15 +518,55 @@ export const state = () => ({
},
],
gameDate: 1400 * 12,
gameEra: 'Early Modern',
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
lifetimes: 0, // comleted lifetimes
timeJumpsBackwards: 0,
// Time Magic
mana: 99,
manaMax: 100,
philosophersStoneUnlocked: false,
spells: [
{
name: 'Chrono Deluge',
description:
'For 30 seconds, your taps gain additional spare time equal to the total level of your Apprentices. (x{{apprenticeLevels}})',
cost: 100,
duration: 300,
elapsed: 0,
unlocked: true,
},
{
name: 'Electric Touch',
description: 'For 15 seconds, your taps gain 5 energy as well.',
cost: 100,
duration: 150,
elapsed: 0,
unlocked: false,
},
{
name: 'Thermodynamic Loophole',
description: 'For 60 seconds, your taps gain triple mana.',
cost: 100,
duration: 600,
elapsed: 0,
unlocked: false,
},
],
philosophersStoneActions: [
{
name: 'Empower the Stone',
description:
'Increase the number of months the stone adds or subtracts to your lifespan.',
},
{
name: 'Forever Young',
description: 'Decrease curreny age.',
},
{
name: 'Necromancy',
description: 'Increase maximum lifespan.',
},
],
philosophersStoneIncrement: 6,
})
export const getters = {
@ -693,14 +761,6 @@ export const mutations = {
state.fluxCapacitorLevel += 1
state.nextFluxCapacitorCost *= 2
},
tickMana: (state) => {
state.mana += 1
},
spendMana: (state, amount) => {
if (amount <= state.mana) {
state.mana -= amount
}
},
unlockTimeMachineAction: (state, name) => {
const index = state.timeMachineActions.findIndex((t) => t.name === name)
Vue.set(state.tabs[index], 'unlocked', true)
@ -747,4 +807,32 @@ export const mutations = {
tickLifetime: (state) => {
state.lifetimes += 1
},
// Time Magic
unlockSpell: (state, name) => {
const index = state.spells.findIndex((s) => s.name === name)
Vue.set(state.spells[index], 'unlocked', true)
},
tickMana: (state) => {
state.mana += 1
},
spendMana: (state, amount) => {
if (amount <= state.mana) {
state.mana -= amount
}
},
// Philosper's Stone
unlockPhilosophersStone: (state) => {
state.philosophersStoneUnlocked = true
},
increasePhilosophersStoneIncrement: (state, months) => {
state.philosophersStoneIncrement += months
},
extendLifespan: (state, months) => {
state.playerAgeMax += months
},
decreaseAge: (state, months) => {
state.playerAge -= months
},
}