2022-01-07 21:10:23 +00:00
|
|
|
import Decimal from 'break_infinity.js'
|
2022-01-07 22:28:21 +00:00
|
|
|
import Vue from 'vue'
|
2022-01-07 21:10:23 +00:00
|
|
|
|
2022-01-07 01:17:26 +00:00
|
|
|
export const state = () => ({
|
|
|
|
tabs: [
|
|
|
|
{
|
2022-01-08 23:42:22 +00:00
|
|
|
route: '/',
|
|
|
|
label: 'fas fa-clock',
|
|
|
|
title: 'Timekeeping Instruments',
|
2022-01-09 08:04:24 +00:00
|
|
|
darkColor: 'amber-900',
|
2022-01-10 06:08:59 +00:00
|
|
|
color: 'amber-400',
|
2022-01-09 08:04:24 +00:00
|
|
|
lightColor: 'amber-200',
|
2022-01-08 20:45:07 +00:00
|
|
|
locked: false,
|
2022-01-07 01:17:26 +00:00
|
|
|
},
|
|
|
|
{
|
2022-01-08 23:42:22 +00:00
|
|
|
route: '/apprentices',
|
|
|
|
label: 'fas fa-user-friends',
|
|
|
|
title: 'Apprentices',
|
2022-01-09 08:04:24 +00:00
|
|
|
darkColor: 'rose-900',
|
2022-01-10 06:08:59 +00:00
|
|
|
color: 'rose-400',
|
2022-01-09 08:04:24 +00:00
|
|
|
lightColor: 'rose-200',
|
2022-01-08 20:45:07 +00:00
|
|
|
locked: false,
|
2022-01-07 01:17:26 +00:00
|
|
|
},
|
|
|
|
{
|
2022-01-08 23:42:22 +00:00
|
|
|
route: '/missions',
|
|
|
|
label: 'fas fa-th-list',
|
2022-01-08 03:46:33 +00:00
|
|
|
title: 'Missions',
|
2022-01-09 08:04:24 +00:00
|
|
|
darkColor: 'sky-900',
|
2022-01-10 06:08:59 +00:00
|
|
|
color: 'sky-400',
|
2022-01-09 08:04:24 +00:00
|
|
|
lightColor: 'sky-200',
|
2022-01-08 23:42:22 +00:00
|
|
|
locked: false,
|
2022-01-07 01:17:26 +00:00
|
|
|
},
|
|
|
|
{
|
2022-01-08 23:42:22 +00:00
|
|
|
route: '/timemachine',
|
|
|
|
label: 'fas fa-fast-forward',
|
2022-01-08 03:46:33 +00:00
|
|
|
title: 'Time Machine',
|
2022-01-09 08:04:24 +00:00
|
|
|
darkColor: 'lime-900',
|
2022-01-10 06:08:59 +00:00
|
|
|
color: 'lime-400',
|
2022-01-07 01:17:26 +00:00
|
|
|
lightColor: 'lime-200',
|
2022-01-08 23:42:22 +00:00
|
|
|
locked: false,
|
2022-01-07 01:17:26 +00:00
|
|
|
},
|
|
|
|
{
|
2022-01-08 23:42:22 +00:00
|
|
|
route: '/timemagic',
|
|
|
|
label: 'fas fa-eye',
|
2022-01-08 03:46:33 +00:00
|
|
|
title: 'Time Magic',
|
2022-01-09 08:04:24 +00:00
|
|
|
darkColor: 'violet-900',
|
2022-01-10 06:08:59 +00:00
|
|
|
color: 'violet-400',
|
2022-01-09 08:04:24 +00:00
|
|
|
lightColor: 'violet-200',
|
2022-01-08 23:42:22 +00:00
|
|
|
locked: false,
|
2022-01-07 01:17:26 +00:00
|
|
|
},
|
|
|
|
{
|
2022-01-08 23:42:22 +00:00
|
|
|
route: '/wisdom',
|
|
|
|
label: 'fas fa-book-open',
|
|
|
|
title: 'Wisdom',
|
2022-01-09 08:04:24 +00:00
|
|
|
darkColor: 'teal-900',
|
2022-01-10 06:08:59 +00:00
|
|
|
color: 'teal-400',
|
2022-01-09 08:04:24 +00:00
|
|
|
lightColor: 'teal-100',
|
2022-01-08 23:42:22 +00:00
|
|
|
locked: false,
|
2022-01-07 01:17:26 +00:00
|
|
|
},
|
|
|
|
],
|
2022-01-07 21:10:23 +00:00
|
|
|
currency: new Decimal(0),
|
|
|
|
currencyTotal: new Decimal(0),
|
|
|
|
processes: [
|
|
|
|
{
|
2022-01-10 10:16:25 +00:00
|
|
|
instrument: 'Mechanical Clock',
|
|
|
|
worker: 'Engineer',
|
|
|
|
|
2022-01-11 05:48:15 +00:00
|
|
|
unlocked: true,
|
2022-01-10 10:16:25 +00:00
|
|
|
cost: 10,
|
|
|
|
created: false,
|
|
|
|
|
|
|
|
completion: 0, // how close it is to giving currency. 10 gained per second.
|
|
|
|
completionRequired: 10, // should be divisible by 10
|
|
|
|
baseReward: 5, // currency added when the bar is completed
|
|
|
|
|
|
|
|
workerLevel: 0, // 0 = not hired; 1+ = hired
|
2022-01-11 05:48:15 +00:00
|
|
|
nextWorkerCost: 50, // currency cost of next worker
|
2022-01-10 10:16:25 +00:00
|
|
|
nextWorkerFactor: 1.5, // worker cost *= this factor after each purchase
|
|
|
|
|
2022-01-07 21:10:23 +00:00
|
|
|
unlockThreshold: { tech: null, currency: 0 },
|
|
|
|
},
|
|
|
|
{
|
2022-01-10 10:16:25 +00:00
|
|
|
instrument: 'Hourglass',
|
|
|
|
worker: 'Glassblower',
|
|
|
|
|
2022-01-11 05:48:15 +00:00
|
|
|
unlocked: false,
|
|
|
|
minDateUnlocked: 1100 * 12,
|
2022-01-10 10:16:25 +00:00
|
|
|
cost: 100,
|
|
|
|
created: false,
|
|
|
|
|
2022-01-07 22:28:21 +00:00
|
|
|
completion: 0,
|
2022-01-10 10:16:25 +00:00
|
|
|
completionRequired: 20,
|
|
|
|
baseReward: 35,
|
|
|
|
|
|
|
|
workerLevel: 0,
|
2022-01-11 05:48:15 +00:00
|
|
|
nextWorkerCost: 250,
|
2022-01-09 17:52:17 +00:00
|
|
|
nextWorkerFactor: 1.6,
|
2022-01-10 10:16:25 +00:00
|
|
|
|
2022-01-07 21:10:23 +00:00
|
|
|
unlockThreshold: { tech: null, currency: 10000 },
|
|
|
|
},
|
|
|
|
{
|
2022-01-10 10:16:25 +00:00
|
|
|
instrument: 'Pocket Watch',
|
|
|
|
worker: 'Miniaturist',
|
|
|
|
|
2022-01-11 05:48:15 +00:00
|
|
|
unlocked: false,
|
|
|
|
minDateUnlocked: 1600 * 12,
|
2022-01-10 10:16:25 +00:00
|
|
|
cost: 1000,
|
|
|
|
created: false,
|
|
|
|
|
2022-01-07 22:28:21 +00:00
|
|
|
completion: 0,
|
2022-01-10 10:16:25 +00:00
|
|
|
completionRequired: 30,
|
|
|
|
baseReward: 80,
|
|
|
|
|
|
|
|
workerLevel: 0,
|
2022-01-11 05:48:15 +00:00
|
|
|
nextWorkerCost: 500,
|
2022-01-09 17:52:17 +00:00
|
|
|
nextWorkerFactor: 1.8,
|
2022-01-10 10:16:25 +00:00
|
|
|
|
2022-01-07 21:10:23 +00:00
|
|
|
unlockThreshold: { tech: 0, currency: new Decimal(10e5) },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
upgrades: [
|
|
|
|
{
|
|
|
|
name: 'Mathematics',
|
|
|
|
price: 100,
|
|
|
|
purchased: false,
|
|
|
|
},
|
|
|
|
],
|
2022-01-08 03:46:33 +00:00
|
|
|
|
|
|
|
missions: [
|
2022-01-11 05:48:15 +00:00
|
|
|
{
|
|
|
|
name: 'Train an Apprentice',
|
|
|
|
description:
|
|
|
|
'One man can only spend so much time staring at clocks each day. Hiring a second may make this easier.',
|
|
|
|
unlockCriteria: {
|
|
|
|
unit: 'instruments',
|
|
|
|
value: 1,
|
|
|
|
},
|
|
|
|
completionCriteria: {
|
|
|
|
unit: 'apprenticeLevels',
|
|
|
|
value: 5,
|
|
|
|
},
|
|
|
|
unlocked: true,
|
|
|
|
viewed: false,
|
|
|
|
complete: 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,
|
|
|
|
},
|
2022-01-08 03:46:33 +00:00
|
|
|
{
|
|
|
|
name: 'Create the Time Machine',
|
2022-01-11 05:48:15 +00:00
|
|
|
description:
|
|
|
|
'Your magnum opus. Soon you will be able to control time itself.',
|
|
|
|
unlockCriteria: {
|
|
|
|
unit: 'missionsCompleted',
|
|
|
|
value: ['Train an Apprentice', 'Study Time Magic'],
|
|
|
|
},
|
2022-01-08 03:46:33 +00:00
|
|
|
completionCriteria: {
|
2022-01-11 05:48:15 +00:00
|
|
|
unit: 'spareTime',
|
|
|
|
value: 1000,
|
2022-01-08 03:46:33 +00:00
|
|
|
},
|
2022-01-11 05:48:15 +00:00
|
|
|
unlocked: false,
|
2022-01-08 03:46:33 +00:00
|
|
|
viewed: false,
|
|
|
|
complete: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Time To Cheat Death',
|
|
|
|
description:
|
|
|
|
'Your body seems to be failing you. ' +
|
|
|
|
'Write a book to pass your knowedge to your younger self through the time machine. ' +
|
|
|
|
"Now where's your pen...",
|
2022-01-11 05:48:15 +00:00
|
|
|
unlockCriteria: {
|
|
|
|
unit: 'timeJumpsBackwards',
|
|
|
|
value: 1,
|
2022-01-08 03:46:33 +00:00
|
|
|
},
|
2022-01-09 18:12:52 +00:00
|
|
|
completionCriteria: {
|
2022-01-11 05:48:15 +00:00
|
|
|
unit: 'maxAge',
|
2022-01-09 18:12:52 +00:00
|
|
|
},
|
2022-01-11 05:48:15 +00:00
|
|
|
unlocked: false,
|
2022-01-08 03:46:33 +00:00
|
|
|
viewed: false,
|
|
|
|
complete: false,
|
|
|
|
},
|
|
|
|
],
|
2022-01-11 05:48:15 +00:00
|
|
|
|
|
|
|
gameDate: 1400 * 12,
|
|
|
|
playerAge: 30 * 12,
|
|
|
|
playerAgeMax: 60 * 12,
|
2022-01-10 23:19:34 +00:00
|
|
|
playerLivedTotal: 0,
|
2022-01-09 23:29:13 +00:00
|
|
|
wisdomGained: 0, // wisdom gained so far on this run, not applied until player sends the book.
|
|
|
|
wisdomApplied: 0, // wisdom from previous runs
|
2022-01-10 00:29:57 +00:00
|
|
|
totalLifetimes: 1,
|
2022-01-11 05:48:15 +00:00
|
|
|
timeJumpsBackwards: 0,
|
2022-01-07 01:17:26 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
export const getters = {
|
2022-01-10 03:28:09 +00:00
|
|
|
activeTab(state) {
|
|
|
|
return state.tabs.find(
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
(tab) => tab.route === $nuxt.$route.path
|
|
|
|
)
|
2022-01-07 01:17:26 +00:00
|
|
|
},
|
2022-01-09 23:29:13 +00:00
|
|
|
canTimeTravel: (state) => {
|
2022-01-09 23:34:50 +00:00
|
|
|
if (state.playerAge.year < state.playerAgeMax.year) return true
|
|
|
|
if (state.playerAge.year > state.playerAgeMax.year) return false
|
|
|
|
return state.playerAge.month < state.playerAgeMax.month
|
|
|
|
},
|
2022-01-10 00:05:58 +00:00
|
|
|
gameMonth: (state) => {
|
|
|
|
return {
|
|
|
|
1: 'Jan.',
|
|
|
|
2: 'Feb.',
|
|
|
|
3: 'Mar.',
|
|
|
|
4: 'Apr.',
|
|
|
|
5: 'May.',
|
|
|
|
6: 'Jun.',
|
|
|
|
7: 'Jul.',
|
|
|
|
8: 'Aug.',
|
|
|
|
9: 'Sep.',
|
|
|
|
10: 'Oct.',
|
|
|
|
11: 'Nov.',
|
|
|
|
12: 'Dec.',
|
2022-01-10 23:19:34 +00:00
|
|
|
}[(state.gameDate % 12) + 1]
|
|
|
|
},
|
|
|
|
gameYear: (state) => {
|
|
|
|
return Math.floor(state.gameDate / 12)
|
2022-01-10 00:05:58 +00:00
|
|
|
},
|
2022-01-10 00:29:57 +00:00
|
|
|
currencySpent: (state) => {
|
|
|
|
return Decimal.subtract(state.currencyTotal, state.currency)
|
|
|
|
},
|
2022-01-11 02:09:32 +00:00
|
|
|
ageText: (state) => {
|
|
|
|
const year = Math.floor(state.playerAge / 12)
|
|
|
|
const month = state.playerAge % 12
|
|
|
|
|
|
|
|
return `${year}y${month}m`
|
|
|
|
},
|
|
|
|
ageMaxText: (state) => {
|
|
|
|
const year = Math.floor(state.playerAgeMax / 12)
|
|
|
|
const month = state.playerAgeMax % 12
|
|
|
|
|
|
|
|
return `${year}y${month}m`
|
|
|
|
},
|
2022-01-11 05:48:15 +00:00
|
|
|
missionIsCompleted: (state) => (missionName) => {
|
|
|
|
const mission = state.missions.find((m) => m.name === missionName)
|
|
|
|
|
|
|
|
return mission && mission.complete
|
|
|
|
},
|
|
|
|
apprenticeLevels: (state) =>
|
|
|
|
state.processes.reduce(
|
|
|
|
(totalLevels, process) => (totalLevels += process.workerLevel),
|
|
|
|
0
|
|
|
|
),
|
|
|
|
instruments: (state) =>
|
|
|
|
state.processes.reduce(
|
|
|
|
(totalInstruments, process) =>
|
|
|
|
process.created ? totalInstruments + 1 : totalInstruments,
|
|
|
|
0
|
|
|
|
),
|
2022-01-07 01:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const mutations = {
|
2022-01-07 21:10:23 +00:00
|
|
|
addCurrency: (state, value) => {
|
|
|
|
state.currency = Decimal.add(state.currency, value)
|
|
|
|
state.currencyTotal = Decimal.add(state.currencyTotal, value)
|
|
|
|
},
|
|
|
|
spendCurrency: (state, value) => {
|
|
|
|
value = Decimal.mul(value, -1)
|
|
|
|
state.currency = Decimal.add(state.currency, value)
|
2022-01-07 21:19:21 +00:00
|
|
|
},
|
2022-01-10 10:16:25 +00:00
|
|
|
createInstrument: (state, instrument) => {
|
|
|
|
const index = state.processes.findIndex((p) => p.instrument === instrument)
|
|
|
|
Vue.set(state.processes[index], 'created', true)
|
|
|
|
},
|
|
|
|
setProcessCompletion: (state, { index, value }) => {
|
|
|
|
Vue.set(state.processes[index], 'completion', value)
|
2022-01-07 22:28:21 +00:00
|
|
|
},
|
2022-01-08 03:46:33 +00:00
|
|
|
setMissionAvailable: (state, missionIndex) => {
|
|
|
|
Vue.set(state.missions[missionIndex], 'available', true)
|
|
|
|
},
|
|
|
|
setMissionViewed: (state, missionIndex) => {
|
|
|
|
Vue.set(state.missions[missionIndex], 'viewed', true)
|
|
|
|
},
|
2022-01-11 05:48:15 +00:00
|
|
|
completeMission: (state, missionName) => {
|
|
|
|
const index = state.missions.findIndex((m) => m.name === missionName)
|
2022-01-11 02:09:32 +00:00
|
|
|
Vue.set(state.missions[index], 'complete', true)
|
2022-01-08 03:46:33 +00:00
|
|
|
},
|
2022-01-11 05:48:15 +00:00
|
|
|
unlockMission: (state, missionName) => {
|
|
|
|
const index = state.missions.findIndex((m) => m.name === missionName)
|
|
|
|
Vue.set(state.missions[index], 'unlocked', true)
|
|
|
|
},
|
2022-01-10 10:16:25 +00:00
|
|
|
levelUpApprentice: (state, process) => {
|
|
|
|
if (process.nextWorkerCost > state.currency) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const index = state.processes.findIndex((p) => p.worker === process.worker)
|
|
|
|
state.currency = Decimal.subtract(state.currency, process.nextWorkerCost)
|
|
|
|
Vue.set(state.processes[index], 'workerLevel', process.workerLevel + 1)
|
2022-01-09 17:52:17 +00:00
|
|
|
Vue.set(
|
2022-01-10 10:16:25 +00:00
|
|
|
state.processes[index],
|
2022-01-09 17:52:17 +00:00
|
|
|
'nextWorkerCost',
|
2022-01-10 10:16:25 +00:00
|
|
|
Math.floor(process.nextWorkerCost * process.nextWorkerFactor)
|
2022-01-09 17:52:17 +00:00
|
|
|
)
|
|
|
|
},
|
2022-01-09 23:29:13 +00:00
|
|
|
tickGameDate: (state) => {
|
2022-01-10 23:19:34 +00:00
|
|
|
state.gameDate += 1
|
|
|
|
state.playerAge += 1
|
|
|
|
if (!(state.playerAge % 12)) state.wisdomGained++
|
2022-01-09 23:29:13 +00:00
|
|
|
},
|
2022-01-10 23:19:34 +00:00
|
|
|
travelGameDate: (state, month) => {
|
|
|
|
state.gameDate = month
|
2022-01-09 23:29:13 +00:00
|
|
|
},
|
2022-01-07 01:17:26 +00:00
|
|
|
}
|