test deck loading
This commit is contained in:
parent
fb415ea572
commit
e7c254f4aa
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
@ -57,6 +58,8 @@ func receiveHandler(connection *websocket.Conn, container *UIContainer) {
|
||||
container.Output <- "game left"
|
||||
matchID = uuid.Nil
|
||||
return
|
||||
case tome_lib.SessionRespDeckLoaded:
|
||||
container.Output <- "deck loaded"
|
||||
case tome_lib.SessionRespBroadcastSenTurn:
|
||||
container.Output <- "Sentinal may take their turn"
|
||||
case tome_lib.SessionRespBroadcastScoTrun:
|
||||
@ -83,6 +86,8 @@ func receiveHandler(connection *websocket.Conn, container *UIContainer) {
|
||||
|
||||
case tome_lib.SessionRespError:
|
||||
container.Output <- "generic error"
|
||||
case tome_lib.SessionRespLoadDeckError:
|
||||
container.Output <- "error loading deck"
|
||||
|
||||
default:
|
||||
container.Output <- "Received a server response we don't know how to handle"
|
||||
@ -197,12 +202,16 @@ func GetCommand(uid uuid.UUID, resp chan tome_lib.SessionCommand, container *UIC
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if len(input_s) < 2 {
|
||||
break
|
||||
}
|
||||
cmd = trimFirstRune(input)
|
||||
|
||||
cmd = strings.TrimSpace(cmd)
|
||||
switch t {
|
||||
case 0:
|
||||
//session
|
||||
cmd = strings.TrimSpace(input_s[1])
|
||||
switch tome_lib.SessionCmd(cmd) {
|
||||
case tome_lib.SessionCmdQuery:
|
||||
resp <- tome_lib.SessionCommand{
|
||||
@ -221,7 +230,20 @@ func GetCommand(uid uuid.UUID, resp chan tome_lib.SessionCommand, container *UIC
|
||||
MatchID: matchID,
|
||||
Command: tome_lib.SessionCmdLeave,
|
||||
}
|
||||
case tome_lib.SessionCmdLoadDeck:
|
||||
//dat := ""
|
||||
//if len(input_s) > 2 {
|
||||
dat := "[1,2,3,4,5,6,7,8,9,10,11]"
|
||||
// log.Println(dat)
|
||||
//}
|
||||
resp <- tome_lib.SessionCommand{
|
||||
ID: uid,
|
||||
MatchID: matchID,
|
||||
Command: tome_lib.SessionCmdLoadDeck,
|
||||
Data: dat,
|
||||
}
|
||||
default:
|
||||
container.Output <- fmt.Sprintf("bad command entered: %v", input, cmd)
|
||||
break
|
||||
}
|
||||
case 1:
|
||||
@ -256,4 +278,5 @@ func GetCommand(uid uuid.UUID, resp chan tome_lib.SessionCommand, container *UIC
|
||||
func trimFirstRune(s string) string {
|
||||
_, i := utf8.DecodeRuneInString(s)
|
||||
return s[i:]
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user