Esempio n. 1
0
func OnJoin(m game.JsonString, c net.Conn) {
	fmt.Println("OnJoin")
	uid := m.GetUid()
	rep := game.JoinRep{common.RET_FL, uid, 0, 0, "join"}

	r, ok := m.GetRound(Casino)
	if ok == false {
		game.SendMsg(c, rep)
		fmt.Println("OnJoin did not found round")
		return
	}

	pos := m.GetPos()
	rep.Pos, rep.Ret = pos, r.Join(game.Player{game.User{c, uid}, pos, ""})
	if rep.Ret == common.RET_OK {
		bal, _ := db.GetBalance([]uint32{uid})
		rep.Coin = bal[uid]
		r.Broadcast(rep)
	} else {
		game.SendMsg(c, rep)
	}
	fmt.Println("OnJoin rep:", rep)
}