}
func (ms *MonopolyServer) roll() {
- ms.gameCtx.logGameCtx()
ms.gameCtx.RollDice()
-
- ms.gameCtx.logGameCtx()
ms.gameCtx.ProcessMovement()
ms.gameCtx.logGameCtx()
ms.gameCtxMu.Lock()
ms.gameCtx = InitCtx(ms.randSeed, players)
+ ms.gameCtx.logGameCtx()
ms.gameCtxMu.Unlock()
msg := []byte{MSG_START}
}
func (ctx *Context) ValidateCanRoll(userUUID string) bool {
- if ctx.ValidateIsTurn(userUUID) && ctx.EventPeek() == EventRollDice {
+ if ctx.ValidateIsTurn(userUUID) && (ctx.EventPeek() == EventRollDice || ctx.EventPeek() == EventJail) {
return true
}
return false
}
func (ctx *Context) ValidateCanEndTurn(userUUID string) bool {
- if ctx.ValidateIsTurn(userUUID) || ctx.EventPeek() == EventEndTurn || ctx.GetCurrentTurnPlayer().Money >= 0 {
+ if ctx.ValidateIsTurn(userUUID) && ctx.EventPeek() == EventEndTurn && ctx.GetCurrentTurnPlayer().Money >= 0 {
return true
}
return false
}
-func (ctx *Context) ValidateCanExitJail(userUUD string) bool {
+func (ctx *Context) ValidateCanExitJail(userUUID string) bool {
+ inJail := false
for _, iJV := range ctx.Visitors.InJail {
- if ctx.Players.Alive[iJV.VisitorID.Index()].UserUUID == userUUD {
- return true
+ if ctx.Players.Alive[iJV.VisitorID.Index()].UserUUID == userUUID {
+ inJail = true
}
}
+ if ctx.ValidateIsTurn(userUUID) && inJail && ctx.EventPeek() == EventJail {
+ return true
+ }
return false
}
}
func (ctx *Context) EndTurn() {
+ ctx.EventPop()
nextTurnPlayerID := PlayerID{ID: (ctx.Turn.Current.ID + 1) % int32(len(ctx.Players.Alive))}
ctx.Turn = initTurn(nextTurnPlayerID, !ctx.PlayerCanMove(nextTurnPlayerID))
// TODO: send options list to the next player