Skip to content

Commit

Permalink
Merge branch 'release/0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
maldestor95 committed Jan 14, 2024
2 parents b9fdd4f + 45727c4 commit 3a27f95
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
2 changes: 1 addition & 1 deletion deploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ git init
git add -A
git commit -m 'deploy'

git remote add origin https://github.com/maldestor95/dorf.git
git remote add origin https://github.com/maldestor95/score.git
git push -f origin master:gh-pages

cd ..
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "score",
"private": true,
"version": "0.1.0",
"version": "0.1.1",
"type": "module",
"homepage": "https://github.com/maldestor95/score",
"description": "Online Scoreboard tool","license":"MIT",
Expand Down
2 changes: 2 additions & 0 deletions src/pages/wizard/definesteps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ const props = withDefaults(defineProps<Props>(), {
const choice = ref("opt1");
const choices = reactive([
{ id: "opt1", opt: props.steps },
{ id: "opt6", opt: [10, 20, 50] },
{ id: "opt2", opt: [-50, -20, -10, 10, 20, 50] },
{ id: "opt3", opt: [-5, -3, -2, -1, 1, 2, 3, 5] },
{ id: "opt4", opt: [-1, 1] },
{ id: "opt5", opt: [10, 20, 30, 40, 80] },
]);
const updateSteps = (id: string) => {
emit("change", choices.filter((c) => c.id == id)[0].opt);
Expand Down
43 changes: 28 additions & 15 deletions src/pages/wizard/store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'

const SETTINGS_LOCAL_STORAGE_KEY = 'score'
interface State {
userList: UserInfo[]
trackBets: boolean
Expand All @@ -14,15 +14,25 @@ export type UserInfo = {
currentRound: number
currentBet: number
}
const DefaultSettings = () => {
return {
userList: [{ name: 'player1', scorePerRound: [], betPerRound: [], currentRound: 0, currentBet: 0 }],
trackBets: false,
scoreSteps: [1, 5, 10],
betSteps: [1, 2, 5, 10],
}
}
const updateLocalStorage = (state: State) => {
localStorage.setItem(SETTINGS_LOCAL_STORAGE_KEY, JSON.stringify(state))
}
const getSettings = () => {
const settings = localStorage.getItem(SETTINGS_LOCAL_STORAGE_KEY)

return settings ? JSON.parse(settings) : DefaultSettings()
}
export const useScoreStore = defineStore('scores', {
state: (): State => {
return {
userList: [{ name: 'player1', scorePerRound: [], betPerRound: [], currentRound: 0, currentBet: 0 }],
trackBets: false,
scoreSteps: [1, 5, 10],
betSteps: [1, 2, 5, 10],
}
},
state: (): State => { return getSettings() }
,
getters: {
getUsers: (state) => { return state.userList },
getRoundNumber: (state) => {
Expand Down Expand Up @@ -52,17 +62,19 @@ export const useScoreStore = defineStore('scores', {
},
updateUserName(userId: number, username: string) {
this.userList[userId - 1].name = username

},
newRound() {
if (this.trackBets)
this.userList.forEach(user => {
user.betPerRound.push(user.currentBet)
user.currentBet = 0
})
// if (this.trackBets)
this.userList.forEach(user => {
user.betPerRound.push(user.currentBet)
user.currentBet = 0
})
this.userList.forEach(user => {
user.scorePerRound.push(user.currentRound)
user.currentRound = 0
})
updateLocalStorage(this.$state)
},
editRoundOfPlayer(userId: number, scoreForTheRound: number, roundId?: number) {
if (roundId) {
Expand All @@ -83,6 +95,7 @@ export const useScoreStore = defineStore('scores', {
user.scorePerRound = []
user.betPerRound = []
})
updateLocalStorage(this.$state)
},
getScore(userId: number) {
return this.totalScore[userId]
Expand All @@ -93,7 +106,7 @@ export const useScoreStore = defineStore('scores', {
editCurrentBet(userId: number, newValue: number) {
this.userList[userId].currentBet = newValue
}
//TODO changes to save to local Storage

}
})

Expand Down

0 comments on commit 3a27f95

Please sign in to comment.