feat: Issue #50, run game clock in months
This commit is contained in:
parent
a7ac60c0fa
commit
e19621e124
2 changed files with 22 additions and 56 deletions
|
|
@ -150,22 +150,10 @@ export const state = () => ({
|
|||
complete: false,
|
||||
},
|
||||
],
|
||||
gameDate: {
|
||||
month: 12,
|
||||
year: 1990,
|
||||
},
|
||||
playerAge: {
|
||||
month: 0,
|
||||
year: 34,
|
||||
},
|
||||
playerAgeMax: {
|
||||
month: 0,
|
||||
year: 80,
|
||||
},
|
||||
playerLivedTotal: {
|
||||
month: 0,
|
||||
year: 0,
|
||||
},
|
||||
gameDate: 1991 * 12,
|
||||
playerAge: 34 * 12,
|
||||
playerAgeMax: 80 * 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,
|
||||
|
|
@ -197,7 +185,10 @@ export const getters = {
|
|||
10: 'Oct.',
|
||||
11: 'Nov.',
|
||||
12: 'Dec.',
|
||||
}[state.gameDate.month]
|
||||
}[(state.gameDate % 12) + 1]
|
||||
},
|
||||
gameYear: (state) => {
|
||||
return Math.floor(state.gameDate / 12)
|
||||
},
|
||||
currencySpent: (state) => {
|
||||
return Decimal.subtract(state.currencyTotal, state.currency)
|
||||
|
|
@ -243,29 +234,11 @@ export const mutations = {
|
|||
)
|
||||
},
|
||||
tickGameDate: (state) => {
|
||||
let gameYear = state.gameDate.year
|
||||
let gameMonth = state.gameDate.month + 1
|
||||
// Intentional: Months are 1 through 12, ages are 0 through 11.
|
||||
if (gameMonth > 12) {
|
||||
gameMonth = 1
|
||||
gameYear = gameYear + 1
|
||||
}
|
||||
let ageYear = state.playerAge.year
|
||||
let ageMonth = state.playerAge.month + 1
|
||||
let wisdomGained = 0
|
||||
if (ageMonth >= 12) {
|
||||
ageMonth = 0
|
||||
ageYear = ageYear + 1
|
||||
wisdomGained += 1
|
||||
}
|
||||
Vue.set(state.gameDate, 'year', gameYear)
|
||||
Vue.set(state.gameDate, 'month', gameMonth)
|
||||
Vue.set(state.playerAge, 'year', ageYear)
|
||||
Vue.set(state.playerAge, 'month', ageMonth)
|
||||
state.wisdomGained = state.wisdomGained + wisdomGained
|
||||
state.gameDate += 1
|
||||
state.playerAge += 1
|
||||
if (!(state.playerAge % 12)) state.wisdomGained++
|
||||
},
|
||||
travelGameDate: (state, { month, year }) => {
|
||||
Vue.set(state.gameDate, 'month', month)
|
||||
Vue.set(state.gameDate, 'year', year)
|
||||
travelGameDate: (state, month) => {
|
||||
state.gameDate = month
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue