You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
package crash |
|
|
|
import ( |
|
"server/game" |
|
"server/pb" |
|
|
|
"github.com/liangdas/mqant/gate" |
|
"github.com/liangdas/mqant/log" |
|
timewheel "github.com/liangdas/mqant/module/modules/timer" |
|
) |
|
|
|
func OnCashout(session gate.Session, req *pb.GameCommonReq) (string, error) { |
|
p := game.FindPlayer(session) |
|
if p == nil { |
|
log.Error("player %v not found", session.GetUserID()) |
|
return "", nil |
|
} |
|
log.Debug("player %v OnCashout %+v", p.UID, *req) |
|
p.T.PutQueue("nf", func() { |
|
if p.Status != pb.PlayerStatus_PlayerStatusPlaying || p.T.Status != pb.GameStatus_GameStatusSpecial { |
|
return |
|
} |
|
p.SubPlayer.(*Player).CashOut() |
|
}) |
|
return "", nil |
|
} |
|
|
|
func OnAutoCashout(session gate.Session, req *pb.CrashMsgAutoCashoutReq) (string, error) { |
|
p := game.FindPlayer(session) |
|
if p == nil { |
|
log.Error("player %v not found", session.GetUserID()) |
|
return "", nil |
|
} |
|
log.Debug("player %v OnAutoCashout %+v", p.UID, *req) |
|
if req.ODD <= 100 { |
|
req.ODD = 0 |
|
} |
|
p.T.PutQueue("nf", func() { |
|
player := p.SubPlayer.(*Player) |
|
player.SetAutoCashoutOdd = req.ODD |
|
// 飞行过程中不允许改变自动下车倍数 |
|
// if req.ODD > 100 && p.T.Status == pb.GameStatus_GameStatusSpecial { |
|
// return |
|
// } |
|
if req.ODD == 0 && p.T.Status == pb.GameStatus_GameStatusSpecial { |
|
player.AutoCashoutOdd = req.ODD |
|
timewheel.GetTimeWheel().RemoveTimer(player.AutoCashoutTimer) |
|
} |
|
player.Send(int(pb.CrashProtocol_CrashAutoCashoutResp), &pb.GameCommonResp{}) |
|
}) |
|
return "", nil |
|
}
|
|
|