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