diff --git a/src/server.odin b/src/server.odin index 53dd50b..42d701e 100644 --- a/src/server.odin +++ b/src/server.odin @@ -58,6 +58,29 @@ send_payload :: proc(sock: net.TCP_Socket, pl: Payload) -> net.Network_Error { return nil } +poke_player :: proc(player: int) -> bool { + unimplemented() +} + +Play_Action :: distinct Card +Discard_Action :: distinct Card +Hint_Action :: distinct Card + +Action :: union { + Play_Action, + Discard_Action, + Hint_Action, +} + +receive_action :: proc(player: int) -> (action: Action, is_valid: bool) { + unimplemented() +} + +perform_action :: proc(game: ^Game, action: Action) { + unimplemented() +} + + run_server :: proc(listen_addr: net.Endpoint, num_players: int, num_hints: int, num_lives: int) { listener, list_err := net.listen_tcp(listen_addr) if list_err != nil do panic(fmt.tprintln("failed to listen:", net.to_string(listen_addr))) @@ -84,15 +107,22 @@ run_server :: proc(listen_addr: net.Endpoint, num_players: int, num_hints: int, fmt.printfln("player %d's turn!", current_player) - for p in g.players { - fmt.println() - for c in p.hand { - fmt.println(c.value, c.color) - } + // for p in g.players { + // fmt.println() + // for c in p.hand { + // fmt.println(c.value, c.color) + // } + // } + + action: Action + POKE: for { + poke_ok := poke_player(current_player) + if !poke_ok do panic(fmt.tprintln("failed to poke player", current_player)) + action, is_valid := receive_action(current_player) + if is_valid do break POKE + fmt.println("invalid action received. try again.") } - - // body - + perform_action(&g, action) current_player = (current_player + 1) % num_players free_all(context.temp_allocator) break GAME_LOOP diff --git a/src/test.nu b/src/test.nu index fb05c3a..894afc9 100755 --- a/src/test.nu +++ b/src/test.nu @@ -2,8 +2,8 @@ (interleave { odin run . -- h localhost:42069 2 | lines | each { "HOST | " ++ $in } } - { sleep 300ms - odin run . -- c localhost:42069 | lines | each { "PLAYER 1 | " ++ $in } } - { sleep 300ms - odin run . -- c localhost:42069 | lines | each { "PLAYER 2 | " ++ $in } }) + { sleep 500ms + odin run . -- c localhost:42069 | lines | each { "PLAYER 0 | " ++ $in } } + { sleep 500ms + odin run . -- c localhost:42069 | lines | each { "PLAYER 1 | " ++ $in } }) | each { print $in } | ignore