feat: initial commit
This commit is contained in:
@ -19,6 +19,7 @@ type QuizPageVModel struct {
|
||||
Player *store.Player
|
||||
CurrentTurn *store.QuizTurn
|
||||
PlayDelay time.Duration
|
||||
IsOffDay bool
|
||||
}
|
||||
|
||||
func NewSelectEntryForm() *form.Form {
|
||||
@ -46,10 +47,28 @@ templ QuizPage(vmodel QuizPageVModel) {
|
||||
common.WithTitle(fmt.Sprintf("Tour #%d", vmodel.CurrentTurn.ID)),
|
||||
)) {
|
||||
<h2 class="title is-size-3">Tour #{ strconv.FormatUint(uint64(vmodel.CurrentTurn.ID), 10) }</h2>
|
||||
if vmodel.Player.PlayedAt.After(vmodel.CurrentTurn.StartedAt) {
|
||||
<div class="content has-text-centered is-size-5">
|
||||
<p><strong>Vous avez déjà joué ce tour ci !</strong></p>
|
||||
<p>Le prochain tour commencera dans { vmodel.CurrentTurn.EndedAt.Sub(time.Now().UTC()).Round(time.Second).String() }.</p>
|
||||
if vmodel.IsOffDay {
|
||||
<div class="message is-warning">
|
||||
<div class="message-header">
|
||||
<p>Jeu désactivé aujourd'hui</p>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
<div class="content">
|
||||
<p>Désolé, le jeu est désactivé pour la journée. Revenez prochainement pour le prochain tour !</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
} else if vmodel.Player.PlayedAt.After(vmodel.CurrentTurn.StartedAt) {
|
||||
<div class="content has-text-centered is-size-5"></div>
|
||||
<div class="message is-info">
|
||||
<div class="message-header">
|
||||
<p>En attente du prochain tour</p>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
<div class="content">
|
||||
<p>Il commencera dans { vmodel.CurrentTurn.EndedAt.Local().Sub(time.Now().Local()).Round(time.Second).String() }.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
} else if vmodel.Player.SelectedEntry == nil || vmodel.Player.SelectedTurn == nil || *vmodel.Player.SelectedTurn != vmodel.CurrentTurn.ID {
|
||||
@QuizQuestionSelector(vmodel)
|
||||
@ -89,7 +108,7 @@ templ QuizQuestionSelector(vmodel QuizPageVModel) {
|
||||
<div class="level-item">
|
||||
<div class="content">
|
||||
<p class="is-size-4 is-family-secondary has-text-right" style="width:300px">
|
||||
<span></span> <span class="has-text-weight-bold">{ difficultyLevel(entry.Level) }</span>
|
||||
<span></span> <span class="has-text-weight-bold">{ store.DifficultyLevel(entry.Level) }</span>
|
||||
<br/>
|
||||
<span>+{ strconv.FormatInt(int64((entry.Level+1)*2), 10) } points</span>
|
||||
</p>
|
||||
@ -158,19 +177,6 @@ templ QuizQuestion(vmodel QuizPageVModel) {
|
||||
</script>
|
||||
}
|
||||
|
||||
func difficultyLevel(level uint) string {
|
||||
switch level {
|
||||
case 0:
|
||||
return "Débutant"
|
||||
case 1:
|
||||
return "Confirmé"
|
||||
case 2:
|
||||
return "Expert"
|
||||
default:
|
||||
return fmt.Sprintf("Hors catégorie (%d)", level)
|
||||
}
|
||||
}
|
||||
|
||||
func markdownToHTML(ctx context.Context, text string) string {
|
||||
var buff bytes.Buffer
|
||||
if err := goldmark.Convert([]byte(text), &buff); err != nil {
|
||||
|
Reference in New Issue
Block a user