From fed71065f79401d2f0a5157039646740a217b4b6 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Thu, 9 Jan 2025 17:33:20 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E8=BF=9B=E6=88=BF=E4=BD=99=E9=A2=9D?= =?UTF-8?q?=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worldsrv/action_game.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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)