add 推币机错误码

This commit is contained in:
sk 2025-01-13 10:42:08 +08:00
parent 45cb4ac678
commit 5e283880ab
3 changed files with 71 additions and 31 deletions

View File

@ -142,8 +142,12 @@ func (OpCodes) EnumDescriptor() ([]byte, []int) {
type OpResultPushCoinCode int32
const (
OpResultPushCoinCode_OPRC_PushCoin_Success OpResultPushCoinCode = 0 //成功
OpResultPushCoinCode_OPRC_PushCoin_Error OpResultPushCoinCode = 1 //失败
OpResultPushCoinCode_OPRC_PushCoin_Success OpResultPushCoinCode = 0 //成功
OpResultPushCoinCode_OPRC_PushCoin_Error OpResultPushCoinCode = 1 //失败
OpResultPushCoinCode_OPRC_PushCoin_BetNotEnough OpResultPushCoinCode = 2 //投币,金币不足
OpResultPushCoinCode_OPRC_PushCoin_ExchangeNotEnough OpResultPushCoinCode = 3 //兑换次数不足
OpResultPushCoinCode_OPRC_PushCoin_ShakeNotEnough OpResultPushCoinCode = 4 //震动次数不足
OpResultPushCoinCode_OPRC_PushCoin_ItemNotEnough OpResultPushCoinCode = 5 //兑换消耗道具不足
)
// Enum value maps for OpResultPushCoinCode.
@ -151,10 +155,18 @@ var (
OpResultPushCoinCode_name = map[int32]string{
0: "OPRC_PushCoin_Success",
1: "OPRC_PushCoin_Error",
2: "OPRC_PushCoin_BetNotEnough",
3: "OPRC_PushCoin_ExchangeNotEnough",
4: "OPRC_PushCoin_ShakeNotEnough",
5: "OPRC_PushCoin_ItemNotEnough",
}
OpResultPushCoinCode_value = map[string]int32{
"OPRC_PushCoin_Success": 0,
"OPRC_PushCoin_Error": 1,
"OPRC_PushCoin_Success": 0,
"OPRC_PushCoin_Error": 1,
"OPRC_PushCoin_BetNotEnough": 2,
"OPRC_PushCoin_ExchangeNotEnough": 3,
"OPRC_PushCoin_ShakeNotEnough": 4,
"OPRC_PushCoin_ItemNotEnough": 5,
}
)
@ -804,14 +816,23 @@ var file_protocol_activity_pushcoin_proto_rawDesc = []byte{
0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x50, 0x5f, 0x53, 0x68, 0x61, 0x6b, 0x65, 0x10, 0x03,
0x12, 0x0e, 0x0a, 0x0a, 0x4f, 0x50, 0x5f, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x10, 0x04,
0x12, 0x0f, 0x0a, 0x0b, 0x4f, 0x50, 0x5f, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x10,
0x05, 0x2a, 0x4a, 0x0a, 0x14, 0x4f, 0x70, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x50, 0x75, 0x73,
0x68, 0x43, 0x6f, 0x69, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x19, 0x0a, 0x15, 0x4f, 0x50, 0x52,
0x43, 0x5f, 0x50, 0x75, 0x73, 0x68, 0x43, 0x6f, 0x69, 0x6e, 0x5f, 0x53, 0x75, 0x63, 0x63, 0x65,
0x73, 0x73, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x50, 0x75, 0x73,
0x68, 0x43, 0x6f, 0x69, 0x6e, 0x5f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x01, 0x42, 0x28, 0x5a,
0x26, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x61,
0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x05, 0x2a, 0xd2, 0x01, 0x0a, 0x14, 0x4f, 0x70, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x50, 0x75,
0x73, 0x68, 0x43, 0x6f, 0x69, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x19, 0x0a, 0x15, 0x4f, 0x50,
0x52, 0x43, 0x5f, 0x50, 0x75, 0x73, 0x68, 0x43, 0x6f, 0x69, 0x6e, 0x5f, 0x53, 0x75, 0x63, 0x63,
0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x50, 0x75,
0x73, 0x68, 0x43, 0x6f, 0x69, 0x6e, 0x5f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x01, 0x12, 0x1e,
0x0a, 0x1a, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x50, 0x75, 0x73, 0x68, 0x43, 0x6f, 0x69, 0x6e, 0x5f,
0x42, 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0x02, 0x12, 0x23,
0x0a, 0x1f, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x50, 0x75, 0x73, 0x68, 0x43, 0x6f, 0x69, 0x6e, 0x5f,
0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4e, 0x6f, 0x74, 0x45, 0x6e, 0x6f, 0x75, 0x67,
0x68, 0x10, 0x03, 0x12, 0x20, 0x0a, 0x1c, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x50, 0x75, 0x73, 0x68,
0x43, 0x6f, 0x69, 0x6e, 0x5f, 0x53, 0x68, 0x61, 0x6b, 0x65, 0x4e, 0x6f, 0x74, 0x45, 0x6e, 0x6f,
0x75, 0x67, 0x68, 0x10, 0x04, 0x12, 0x1f, 0x0a, 0x1b, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x50, 0x75,
0x73, 0x68, 0x43, 0x6f, 0x69, 0x6e, 0x5f, 0x49, 0x74, 0x65, 0x6d, 0x4e, 0x6f, 0x74, 0x45, 0x6e,
0x6f, 0x75, 0x67, 0x68, 0x10, 0x05, 0x42, 0x28, 0x5a, 0x26, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e,
0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -68,6 +68,10 @@ enum OpCodes {
enum OpResultPushCoinCode {
OPRC_PushCoin_Success = 0; //
OPRC_PushCoin_Error = 1; //
OPRC_PushCoin_BetNotEnough = 2; //
OPRC_PushCoin_ExchangeNotEnough = 3; //
OPRC_PushCoin_ShakeNotEnough = 4; //
OPRC_PushCoin_ItemNotEnough = 5; //
}
//PACKET_SCPushCoinPlayerOp

View File

@ -53,16 +53,7 @@ func CSPushCoinInfo(s *netlib.Session, packetid int, data interface{}, sid int64
}
if p.WelfData.PushCoin == nil {
// 初始化
p.WelfData.PushCoin = &model.PushCoinData{
Power: PowerInit,
Exchange: make(map[int32]int32),
Items: map[int32]int64{
common.ItemIDVCard: 1,
common.ItemIDCoin: 50 * 5000,
common.ItemIDPlum: 1,
},
}
InitPlayerPushCoin(p)
}
pack := &activity.SCPushCoinInfo{
@ -164,6 +155,7 @@ func CSPushCoinPlayerOp(s *netlib.Session, packetid int, data interface{}, sid i
}
if p.GetCoin() < item.GetNum() {
pack.OpRetCode = activity.OpResultPushCoinCode_OPRC_PushCoin_BetNotEnough
goto here
}
pack.BetId = int32(msg.GetOpParam())
@ -185,10 +177,12 @@ func CSPushCoinPlayerOp(s *netlib.Session, packetid int, data interface{}, sid i
id = common.ItemIDCoin
}
//if p.WelfData.PushCoin.Items[id] < val {
// logger.Logger.Errorf("获得道具太多: %d, %d", p.WelfData.PushCoin.Items[id], val)
// goto here
//}
if p.WelfData.PushCoin.Items[id] < val {
logger.Logger.Errorf("获得道具太多: %d, %d", p.WelfData.PushCoin.Items[id], val)
// 刷新桌面余额
UpdatePlayerPushCoin(p)
goto here
}
BagMgrSingleton.AddItems(&model.AddItemParam{
Platform: p.Platform,
@ -213,16 +207,13 @@ func CSPushCoinPlayerOp(s *netlib.Session, packetid int, data interface{}, sid i
case activity.OpCodes_OP_Shake:
if p.WelfData.PushCoin.Shake < int32(msg.GetOpParam()) {
pack.OpRetCode = activity.OpResultPushCoinCode_OPRC_PushCoin_ShakeNotEnough
goto here
}
p.WelfData.PushCoin.Shake -= int32(msg.GetOpParam())
case activity.OpCodes_OP_Refresh:
p.WelfData.PushCoin.Refresh++
// 1个v卡50个金币大梅花1个
p.WelfData.PushCoin.Items = map[int32]int64{
common.ItemIDCoin: 50 * 5000,
}
UpdatePlayerPushCoin(p)
case activity.OpCodes_OP_Exchange:
d := srvdata.PBDB_PropExchangeMgr.GetData(int32(msg.GetOpParam()))
@ -231,6 +222,7 @@ func CSPushCoinPlayerOp(s *netlib.Session, packetid int, data interface{}, sid i
}
// 兑换次数
if d.GetTimes() > 0 && p.WelfData.PushCoin.Exchange[d.Id] >= d.GetTimes() {
pack.OpRetCode = activity.OpResultPushCoinCode_OPRC_PushCoin_ExchangeNotEnough
goto here
}
@ -244,6 +236,7 @@ func CSPushCoinPlayerOp(s *netlib.Session, packetid int, data interface{}, sid i
ItemNum: int32(v),
})
if k == common.ItemIDCoin && p.GetCoin() < v {
pack.OpRetCode = activity.OpResultPushCoinCode_OPRC_PushCoin_ItemNotEnough
goto here
}
cost = append(cost, &model.Item{
@ -262,6 +255,7 @@ func CSPushCoinPlayerOp(s *netlib.Session, packetid int, data interface{}, sid i
Remark: "推币机活动兑换消耗",
})
if !ok {
pack.OpRetCode = activity.OpResultPushCoinCode_OPRC_PushCoin_ItemNotEnough
goto here
}
@ -307,6 +301,27 @@ here:
return nil
}
func InitPlayerPushCoin(p *Player) {
// 初始化
p.WelfData.PushCoin = &model.PushCoinData{
Power: PowerInit,
Exchange: make(map[int32]int32),
Items: map[int32]int64{
common.ItemIDVCard: 1,
common.ItemIDCoin: 50 * 5000,
common.ItemIDPlum: 1,
},
}
}
func UpdatePlayerPushCoin(p *Player) {
p.WelfData.PushCoin.Refresh++
// 50个金币
p.WelfData.PushCoin.Items = map[int32]int64{
common.ItemIDCoin: 50 * 5000,
}
}
func AddPower(p *Player, value int64) {
if value < 0 {
return