single game fix
This commit is contained in:
parent
09bf741997
commit
f3020b7cb0
6 changed files with 195 additions and 128 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import components.{click_cell, click_cell_pair}
|
||||
import components.{click_cell_pair}
|
||||
import gleam/bit_array
|
||||
import gleam/crypto
|
||||
import gleam/dynamic/decode
|
||||
|
|
@ -146,7 +146,7 @@ fn view(model: Model) -> Element(Msg) {
|
|||
html.div([class("terminal-status")], [
|
||||
html.span([class("status-blink")], [html.text("●")]),
|
||||
html.text(" SYSTEM READY"),
|
||||
html.span([class("ml-8")], [
|
||||
html.div([class("ml-8")], [
|
||||
case model.state {
|
||||
Initial -> html.text("STATUS: Please select player")
|
||||
ReceiveName(_) -> html.text("STATUS: Please enter your name")
|
||||
|
|
@ -163,19 +163,18 @@ fn view(model: Model) -> Element(Msg) {
|
|||
html.text("[ACTIVE TRANSMISSIONS]"),
|
||||
]),
|
||||
]),
|
||||
|
||||
html.div([class("participants-grid")], [
|
||||
case model.state {
|
||||
Initial ->
|
||||
case model.players {
|
||||
[] -> input_new_player()
|
||||
_ -> view_players(model.players)
|
||||
[] -> shared.input_new_player(ReceiveName)
|
||||
_ -> shared.view_players(model.players, PickedPlayer)
|
||||
}
|
||||
PickQuestion -> view_questions(model.answers)
|
||||
ReceiveName(_) -> input_new_player()
|
||||
ReceiveName(_) -> shared.input_new_player(ReceiveName)
|
||||
AcceptPlayer(Some(player)) -> {
|
||||
let #(_, player_name) = player
|
||||
shared.confirm_cell(
|
||||
shared.confirm_cells(
|
||||
Some("Join as this player: " <> player_name <> "?"),
|
||||
player,
|
||||
AcceptPlayer,
|
||||
|
|
@ -189,26 +188,6 @@ fn view(model: Model) -> Element(Msg) {
|
|||
])
|
||||
}
|
||||
|
||||
fn view_players(players: List(#(String, String))) {
|
||||
html.div([], [
|
||||
html.div(
|
||||
[],
|
||||
list.append(
|
||||
list.index_map(players, fn(item, index) {
|
||||
click_cell_pair(Some(int.to_string(index)), Some(item), PickedPlayer)
|
||||
}),
|
||||
[click_cell_pair(Some("ENTER NEW PLAYER"), None, PickedPlayer)],
|
||||
),
|
||||
),
|
||||
])
|
||||
}
|
||||
|
||||
fn input_new_player() {
|
||||
html.div([class("participant-box")], [
|
||||
input_cell("Enter player name:", ReceiveName),
|
||||
])
|
||||
}
|
||||
|
||||
fn input_new_answer(question: #(String, String)) {
|
||||
let #(question_id, question_text) = question
|
||||
html.div([class("participant-box")], [
|
||||
|
|
@ -220,17 +199,25 @@ fn input_new_answer(question: #(String, String)) {
|
|||
}
|
||||
|
||||
fn view_questions(answers: List(#(String, #(String, String)))) {
|
||||
html.div(
|
||||
[class("singles-grid")],
|
||||
list.map(answers, fn(content) {
|
||||
let #(number, #(question, answer)) = content
|
||||
click_cell_pair(
|
||||
Some(number <> " " <> answer),
|
||||
Some(#(number, question)),
|
||||
PickedQuestion,
|
||||
)
|
||||
}),
|
||||
)
|
||||
html.div([], [
|
||||
html.div(
|
||||
[class("singles-grid")],
|
||||
list.map(answers, fn(content) {
|
||||
let #(number, #(question, answer)) = content
|
||||
click_cell_pair(
|
||||
Some(number <> " " <> answer),
|
||||
Some(#(number, question)),
|
||||
True,
|
||||
PickedQuestion,
|
||||
)
|
||||
}),
|
||||
),
|
||||
html.div([], [
|
||||
html.text(
|
||||
"[Your answers are saved automatically, when you are done answering, simply close the window]",
|
||||
),
|
||||
]),
|
||||
])
|
||||
}
|
||||
|
||||
fn content_cell(answer: #(Int, #(String, String))) -> Element(Msg) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue