|
|
|
@ -209,12 +209,12 @@ func (g *Game) exportJSON(player int) (string, error) {
@@ -209,12 +209,12 @@ func (g *Game) exportJSON(player int) (string, error) {
|
|
|
|
|
if player > 0 { |
|
|
|
|
gamestate["player"] = strconv.Itoa(player) |
|
|
|
|
|
|
|
|
|
jsonvalue, err := json.Marshal(g.getClient(player).getWaiting()) |
|
|
|
|
jsonvalue, err := json.Marshal(g.getClient(player).getStatus()) |
|
|
|
|
if err != nil { |
|
|
|
|
return "", err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gamestate["waiting"] = string(jsonvalue) |
|
|
|
|
gamestate["status"] = string(jsonvalue) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
throwPileSum := cribbage.Sum(g.ThrowPile.Cards()) |
|
|
|
@ -334,7 +334,7 @@ func (g *Game) scoreHands() (int, int, int) {
@@ -334,7 +334,7 @@ func (g *Game) scoreHands() (int, int, int) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
g.getClient(msgplayer).gameready = false |
|
|
|
|
g.getClient(msgplayer).setWaiting("You scored " + yourscore + " - Your opponent scored " + theirscore) |
|
|
|
|
g.getClient(msgplayer).setStatus("You scored " + yourscore + " - Your opponent scored " + theirscore) |
|
|
|
|
|
|
|
|
|
log.Println(msgplayer, "You scored "+yourscore+" - Your opponent scored "+theirscore) |
|
|
|
|
} |
|
|
|
@ -416,7 +416,7 @@ func (g *Game) Throw(player int, cardidentifier string) bool {
@@ -416,7 +416,7 @@ func (g *Game) Throw(player int, cardidentifier string) bool {
|
|
|
|
|
if opponentHand.Len() > 0 && !g.getClient(g.getOpponent(player)).gamego { |
|
|
|
|
log.Println("Setting Go - Player", g.getOpponent(player)) |
|
|
|
|
g.getClient(g.getOpponent(player)).gamego = true |
|
|
|
|
g.getClient(g.getOpponent(player)).setWaiting("Go") |
|
|
|
|
g.getClient(g.getOpponent(player)).setStatus("Go") |
|
|
|
|
g.getClient(g.getOpponent(player)).gameready = false |
|
|
|
|
|
|
|
|
|
g.NextTurn() |
|
|
|
@ -457,15 +457,15 @@ func (g *Game) ResetGo() {
@@ -457,15 +457,15 @@ func (g *Game) ResetGo() {
|
|
|
|
|
func (g *Game) ResetReady() { |
|
|
|
|
if g.Phase > 0 { |
|
|
|
|
g.Player1.gameready = true |
|
|
|
|
g.Player1.setWaiting("") |
|
|
|
|
g.Player1.setStatus("") |
|
|
|
|
g.Player2.gameready = true |
|
|
|
|
g.Player2.setWaiting("") |
|
|
|
|
g.Player2.setStatus("") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (g *Game) Ready(player int) { |
|
|
|
|
g.getClient(player).gameready = true |
|
|
|
|
g.getClient(player).setWaiting("Waiting on opponent...") |
|
|
|
|
g.getClient(player).setStatus("Waiting on opponent...") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (g *Game) AllReady() bool { |
|
|
|
@ -756,7 +756,7 @@ func (g *Game) pegTurn(player int) {
@@ -756,7 +756,7 @@ func (g *Game) pegTurn(player int) {
|
|
|
|
|
|
|
|
|
|
g.PegPhase = PegPhaseSolo |
|
|
|
|
g.getClient(g.getOpponent(player)).gameready = false |
|
|
|
|
g.getClient(g.getOpponent(player)).setWaiting("Go - Pegging finished") |
|
|
|
|
g.getClient(g.getOpponent(player)).setStatus("Go - Pegging finished") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
g.NextTurn() |
|
|
|
@ -772,14 +772,14 @@ func (g *Game) pegTurn(player int) {
@@ -772,14 +772,14 @@ func (g *Game) pegTurn(player int) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
g.getClient(g.Turn).gameready = false |
|
|
|
|
g.getClient(g.Turn).setWaiting("You pegged " + strconv.Itoa(finalpeg) + " point") |
|
|
|
|
g.getClient(g.Turn).setStatus("You pegged " + strconv.Itoa(finalpeg) + " point") |
|
|
|
|
if finalpeg != 1 { |
|
|
|
|
g.getClient(g.Turn).gamewaiting += "s" |
|
|
|
|
g.getClient(g.Turn).gamestatus += "s" |
|
|
|
|
} |
|
|
|
|
g.getClient(g.getOpponent(g.Turn)).gameready = false |
|
|
|
|
g.getClient(g.getOpponent(g.Turn)).setWaiting("Your opponent pegged " + strconv.Itoa(finalpeg) + " point") |
|
|
|
|
g.getClient(g.getOpponent(g.Turn)).setStatus("Your opponent pegged " + strconv.Itoa(finalpeg) + " point") |
|
|
|
|
if finalpeg != 1 { |
|
|
|
|
g.getClient(g.getOpponent(g.Turn)).gamewaiting += "s" |
|
|
|
|
g.getClient(g.getOpponent(g.Turn)).gamestatus += "s" |
|
|
|
|
} |
|
|
|
|
g.NextTurn() |
|
|
|
|
} else if g.PegPhase == PegPhaseFinal { |
|
|
|
@ -839,8 +839,8 @@ func (g *Game) processGameCommand(command GameCommand) {
@@ -839,8 +839,8 @@ func (g *Game) processGameCommand(command GameCommand) {
|
|
|
|
|
|
|
|
|
|
g.Ready(command.Player) |
|
|
|
|
if g.AllReady() { |
|
|
|
|
g.Player1.setWaiting("") |
|
|
|
|
g.Player2.setWaiting("") |
|
|
|
|
g.Player1.setStatus("") |
|
|
|
|
g.Player2.setStatus("") |
|
|
|
|
|
|
|
|
|
g.logDebug("ALL READY") |
|
|
|
|
if g.Phase == PhasePeg { |
|
|
|
|