diff --git a/worldsrv/action_game.go b/worldsrv/action_game.go index 1e0cd61..2e66760 100644 --- a/worldsrv/action_game.go +++ b/worldsrv/action_game.go @@ -112,6 +112,20 @@ func (this *CSEnterRoomHandler) Process(s *netlib.Session, packetid int, data in logger.Logger.Trace("CSEnterRoomHandler cost error") goto failed } + + if scene.CustomParam.CostType == 1 { // AA + var afterCoin = p.GetCoin() + for _, v := range scene.CustomParam.GetItems() { + if v.GetId() == common.ItemIDCoin { + afterCoin -= v.GetNum() + } + } + if afterCoin <= 0 || (scene.dbGameFree.GetLimitCoin() > 0 && afterCoin < scene.dbGameFree.GetLimitCoin()) { + code = gamehall.OpResultCode_Game_OPRC_CoinNotEnough_Game + logger.Logger.Trace("CSEnterRoomHandler cost after coin too little error") + goto failed + } + } } dbGameFree = scene.dbGameFree @@ -1327,12 +1341,16 @@ func CSCreatePrivateRoomHandler(s *netlib.Session, packetId int, data interface{ } var item []*server.Item + var afterCoin = p.GetCoin() costItem := sp.NeedRoomCardCost(int(costType), int(msg.GetPlayerNum()), cfg) for _, v := range costItem { item = append(item, &server.Item{ Id: v.ItemID, Num: v.Count, }) + if v.ItemID == common.ItemIDCoin { + afterCoin -= v.Count + } } // 创建房间 @@ -1369,6 +1387,12 @@ func CSCreatePrivateRoomHandler(s *netlib.Session, packetId int, data interface{ return nil } + if afterCoin <= 0 || (scene.dbGameFree.GetLimitCoin() > 0 && afterCoin < scene.dbGameFree.GetLimitCoin()) { + code = gamehall.OpResultCode_Game_OPRC_CoinNotEnough_Game + send() + return nil + } + csp.AddScene(scene) sp.CostPayment(scene, p.SnId)