highscore-server/src/types.v

43 lines
644 B
V

module main
pub const default_score_key = '_default'
struct Score {
player string
score ?int
scores ?map[string]int
valkey string
}
struct ScoreRes {
id int
player string
score int
time i64
}
struct Status {
status int
message string
}
fn (score ScoreTable) convert_to_res() &ScoreRes {
return &ScoreRes{
id: score.id
player: score.player
score: score.score
time: score.time
}
}
// More efficient than array.map(it.convert_to_res())?
fn (scores []ScoreTable) convert_to_res() []ScoreRes {
mut score_res := []ScoreRes{}
for _, score in scores {
score_res << score.convert_to_res()
}
return score_res
}