Skip to content

Commit

Permalink
refactor(pages): preparing for multi-game mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mJehanno committed Mar 14, 2024
1 parent 165a646 commit ec9cc81
Show file tree
Hide file tree
Showing 42 changed files with 1,978 additions and 468 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ The game is supposed to be able to update itself on launch.

More features are to come :

- [ ] live score display
- [ ] new difficulty mode (easier than the existing one)
- [X] live score display
- [X] new difficulty mode (easier than the existing one)
- [ ] might add some other mod later
15 changes: 8 additions & 7 deletions backend/score/score.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ func (s ScoreDB) Convert(dest *Score) {
}

type Score struct {
ID int64 `db:"id" json:"id,omitempty"`
Username string `db:"username" json:"username"`
Score int `db:"score" json:"score"`
Difficulty DifficultyLevel `db:"difficulty" json:"difficulty"`
Date time.Time `db:"created_at" goqu:"skipinsert" json:"created_at,omitempty"`
ID int64 `json:"id,omitempty"`
Username string `json:"username"`
Score int `json:"score"`
Difficulty DifficultyLevel `json:"difficulty"`
Game GameEnum `json:"game"`
Date time.Time `json:"created_at,omitempty"`
}

type ScoreParams struct {
Expand All @@ -78,7 +79,7 @@ func NewScoreService(p ScoreParams) *ScoreService {
}
}

func (s *ScoreService) GetScore(difficulty DifficultyLevel) []Score {
func (s *ScoreService) GetScore(game GameEnum, difficulty DifficultyLevel) []Score {
var (
resDB []*ScoreDB
res []Score
Expand All @@ -90,7 +91,7 @@ func (s *ScoreService) GetScore(difficulty DifficultyLevel) []Score {
goqu.C("difficulty"),
goqu.C("created_at"),
).From("rank").Order(goqu.C("score").Desc(), goqu.C("created_at").Desc()).
Where(goqu.C("difficulty").Eq(difficulty)).Limit(10)
Where(goqu.And(goqu.C("difficulty").Eq(difficulty), goqu.C("game").Eq(game))).Limit(10)

err := query.ScanStructsContext(context.Background(), &resDB)
if err != nil {
Expand Down
16 changes: 12 additions & 4 deletions frontend/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ declare module 'vue' {
Button: typeof import('primevue/button')['default']
Column: typeof import('primevue/column')['default']
DataTable: typeof import('primevue/datatable')['default']
DifficultyMenu: typeof import('./src/components/menus/DifficultyMenu.vue')['default']
DockMenu: typeof import('./src/components/menus/DockMenu.vue')['default']
Game: typeof import('./src/components/Game.vue')['default']
Home: typeof import('./src/components/Home.vue')['default']
GameBoard: typeof import('./src/components/game-components/GameBoard.vue')['default']
GameMenu: typeof import('./src/components/menus/GameMenu.vue')['default']
GameOverDialog: typeof import('./src/components/game-components/GameOverDialog.vue')['default']
InputText: typeof import('primevue/inputtext')['default']
Prompter: typeof import('./src/components/Prompter.vue')['default']
LifeBar: typeof import('./src/components/game-components/LifeBar.vue')['default']
Prompter: typeof import('./src/components/game-components/Prompter.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
ScoreBoard: typeof import('./src/components/ScoreBoard.vue')['default']
Streak: typeof import('./src/components/Streak.vue')['default']
Timer: typeof import('./src/components/Timer.vue')['default']
Streak: typeof import('./src/components/game-components/Streak.vue')['default']
Timer: typeof import('./src/components/game-components/Timer.vue')['default']
Title: typeof import('./src/components/Title.vue')['default']
Update: typeof import('./src/components/Update.vue')['default']
VersionDisplayer: typeof import('./src/components/VersionDisplayer.vue')['default']
}
}
Loading

0 comments on commit ec9cc81

Please sign in to comment.