Compare commits
No commits in common. "f467753242807b4c139c124a778329ca75e9fb83" and "8c8ee30ef866b249b430da37086fa356c7e82f2f" have entirely different histories.
f467753242
...
8c8ee30ef8
21
README.md
21
README.md
|
@ -2,6 +2,27 @@
|
||||||
|
|
||||||
游戏业务代码
|
游戏业务代码
|
||||||
|
|
||||||
|
### 子仓库
|
||||||
|
public子仓库本项目本身并没有使用,只是用来暴露部分公共代码,供其他项目使用。
|
||||||
|
例如:
|
||||||
|
1.客户端同步通信协议
|
||||||
|
2.客户端同步游戏配置
|
||||||
|
|
||||||
|
#### 初始化子仓库
|
||||||
|
```
|
||||||
|
git submodule update --init --recursive
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 更新子仓库
|
||||||
|
```
|
||||||
|
git submodule update --remote
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 更新并提交子仓库代码
|
||||||
|
```
|
||||||
|
update_public.sh
|
||||||
|
```
|
||||||
|
|
||||||
### 脚本
|
### 脚本
|
||||||
#### gen_data.bat
|
#### gen_data.bat
|
||||||
xlsx文件转换为json,dat文件,生成pbdata.proto,生成srvdata包
|
xlsx文件转换为json,dat文件,生成pbdata.proto,生成srvdata包
|
||||||
|
|
|
@ -316,7 +316,6 @@ const (
|
||||||
GainWayVipGift9 = 105 //vip等级礼包
|
GainWayVipGift9 = 105 //vip等级礼包
|
||||||
GainWayRoomCost = 106 //房费消耗
|
GainWayRoomCost = 106 //房费消耗
|
||||||
GainWayRoomGain = 107 //房卡场获得
|
GainWayRoomGain = 107 //房卡场获得
|
||||||
GainWayItemShop = 108 // 交易市场道具交易
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 后台选择 金币变化类型 的充值 类型id号起始
|
// 后台选择 金币变化类型 的充值 类型id号起始
|
||||||
|
|
Binary file not shown.
|
@ -1,9 +1,8 @@
|
||||||
|
|
||||||
$08И@HЂ‡§
|
$08и@HЂ‡§
|
||||||
08d@HЂЪД
|
08ф@HЂЪД
|
||||||
08<@HЂв
|
08¬@HЂв
|
||||||
08(@HЂк0
|
08И@HЂк0
|
||||||
08@H В
|
08–@H В
|
||||||
08@Hа§
|
08d@Hа§
|
||||||
08
|
082@HАљ
|
||||||
@HАљ
|
|
|
@ -5,7 +5,7 @@
|
||||||
"RankType": 1,
|
"RankType": 1,
|
||||||
"Level": 36,
|
"Level": 36,
|
||||||
"Award2Id": 2,
|
"Award2Id": 2,
|
||||||
"Award2Num": 200,
|
"Award2Num": 1000,
|
||||||
"Award3Id": 1,
|
"Award3Id": 1,
|
||||||
"Award3Num": 30000000
|
"Award3Num": 30000000
|
||||||
},
|
},
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
"RankType": 1,
|
"RankType": 1,
|
||||||
"Level": 31,
|
"Level": 31,
|
||||||
"Award2Id": 2,
|
"Award2Id": 2,
|
||||||
"Award2Num": 100,
|
"Award2Num": 500,
|
||||||
"Award3Id": 1,
|
"Award3Id": 1,
|
||||||
"Award3Num": 20000000
|
"Award3Num": 20000000
|
||||||
},
|
},
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
"RankType": 1,
|
"RankType": 1,
|
||||||
"Level": 26,
|
"Level": 26,
|
||||||
"Award2Id": 2,
|
"Award2Id": 2,
|
||||||
"Award2Num": 60,
|
"Award2Num": 300,
|
||||||
"Award3Id": 1,
|
"Award3Id": 1,
|
||||||
"Award3Num": 10000000
|
"Award3Num": 10000000
|
||||||
},
|
},
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
"RankType": 1,
|
"RankType": 1,
|
||||||
"Level": 21,
|
"Level": 21,
|
||||||
"Award2Id": 2,
|
"Award2Id": 2,
|
||||||
"Award2Num": 40,
|
"Award2Num": 200,
|
||||||
"Award3Id": 1,
|
"Award3Id": 1,
|
||||||
"Award3Num": 800000
|
"Award3Num": 800000
|
||||||
},
|
},
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
"RankType": 1,
|
"RankType": 1,
|
||||||
"Level": 16,
|
"Level": 16,
|
||||||
"Award2Id": 2,
|
"Award2Id": 2,
|
||||||
"Award2Num": 30,
|
"Award2Num": 150,
|
||||||
"Award3Id": 1,
|
"Award3Id": 1,
|
||||||
"Award3Num": 500000
|
"Award3Num": 500000
|
||||||
},
|
},
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
"RankType": 1,
|
"RankType": 1,
|
||||||
"Level": 11,
|
"Level": 11,
|
||||||
"Award2Id": 2,
|
"Award2Id": 2,
|
||||||
"Award2Num": 20,
|
"Award2Num": 100,
|
||||||
"Award3Id": 1,
|
"Award3Id": 1,
|
||||||
"Award3Num": 300000
|
"Award3Num": 300000
|
||||||
},
|
},
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
"RankType": 1,
|
"RankType": 1,
|
||||||
"Level": 6,
|
"Level": 6,
|
||||||
"Award2Id": 2,
|
"Award2Id": 2,
|
||||||
"Award2Num": 10,
|
"Award2Num": 50,
|
||||||
"Award3Id": 1,
|
"Award3Id": 1,
|
||||||
"Award3Num": 200000
|
"Award3Num": 200000
|
||||||
}
|
}
|
||||||
|
|
BIN
data/DB_Task.dat
BIN
data/DB_Task.dat
Binary file not shown.
|
@ -101,8 +101,7 @@ func (svc *BagSvc) AddBagItem(args *model.BagInfo, ret *bool) error {
|
||||||
for id, v := range args.BagItem {
|
for id, v := range args.BagItem {
|
||||||
if item, exist := bag.BagItem[id]; !exist {
|
if item, exist := bag.BagItem[id]; !exist {
|
||||||
if v.ItemNum <= 0 {
|
if v.ItemNum <= 0 {
|
||||||
err = errors.New("item num not enough")
|
continue
|
||||||
break
|
|
||||||
}
|
}
|
||||||
bag.BagItem[id] = &model.Item{
|
bag.BagItem[id] = &model.Item{
|
||||||
ItemId: v.ItemId,
|
ItemId: v.ItemId,
|
||||||
|
@ -111,8 +110,7 @@ func (svc *BagSvc) AddBagItem(args *model.BagInfo, ret *bool) error {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if v.ItemNum < 0 && -v.ItemNum > item.ItemNum {
|
if v.ItemNum < 0 && -v.ItemNum > item.ItemNum {
|
||||||
err = errors.New("item num not enough")
|
v.ItemNum = -item.ItemNum
|
||||||
break
|
|
||||||
}
|
}
|
||||||
item.ItemNum += v.ItemNum
|
item.ItemNum += v.ItemNum
|
||||||
}
|
}
|
||||||
|
@ -121,18 +119,10 @@ func (svc *BagSvc) AddBagItem(args *model.BagInfo, ret *bool) error {
|
||||||
vCard = v.ItemNum
|
vCard = v.ItemNum
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
*ret = false
|
|
||||||
logger.Logger.Errorf("AddBagItem error: %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = cbag.Upsert(bson.M{"_id": bag.BagId}, bag)
|
_, err = cbag.Upsert(bson.M{"_id": bag.BagId}, bag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
*ret = false
|
*ret = false
|
||||||
logger.Logger.Info("AddBagItem error ", err)
|
logger.Logger.Info("AddBagItem error ", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// v卡返还
|
// v卡返还
|
||||||
|
|
|
@ -227,7 +227,7 @@ func (svc *PlayerDataSvc) CreatePlayerDataByThird(args *model.CreatePlayer, ret
|
||||||
var dataParams model.PlayerParams
|
var dataParams model.PlayerParams
|
||||||
json.Unmarshal([]byte(a.Params), &dataParams)
|
json.Unmarshal([]byte(a.Params), &dataParams)
|
||||||
pd = model.NewPlayerDataThird(acc, name, args.HeadUrl, id, a.Channel, a.Platform, a.Params,
|
pd = model.NewPlayerDataThird(acc, name, args.HeadUrl, id, a.Channel, a.Platform, a.Params,
|
||||||
a.Tel, a.PackegeTag, dataParams.Ip, a.TagKey, a.AccountType, a.DeviceOs, a.ChannelId)
|
a.Tel, a.PackegeTag, dataParams.Ip, a.TagKey, a.AccountType, a.DeviceOs)
|
||||||
if pd != nil {
|
if pd != nil {
|
||||||
err = cplayerdata.Insert(pd)
|
err = cplayerdata.Insert(pd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -13,6 +13,43 @@ import (
|
||||||
"mongo.games.com/game/srvdata"
|
"mongo.games.com/game/srvdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type CSDestroyRoomPacketFactory struct {
|
||||||
|
}
|
||||||
|
type CSDestroyRoomHandler struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CSDestroyRoomPacketFactory) CreatePacket() interface{} {
|
||||||
|
pack := &gamehall.CSDestroyRoom{}
|
||||||
|
return pack
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CSDestroyRoomHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
|
logger.Logger.Trace("CSDestroyRoomHandler Process recv ", data)
|
||||||
|
p := base.PlayerMgrSington.GetPlayer(sid)
|
||||||
|
if p == nil {
|
||||||
|
logger.Logger.Warn("CSDestroyRoomHandler p == nil")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
scene := p.GetScene()
|
||||||
|
if scene == nil {
|
||||||
|
logger.Logger.Warn("CSDestroyRoomHandler p.GetScene() == nil")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if !scene.HasPlayer(p) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if scene.Creator != p.SnId {
|
||||||
|
logger.Logger.Warn("CSDestroyRoomHandler s.creator != p.AccountId")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// 房卡场开始后不能解散
|
||||||
|
if scene.IsCustom() && scene.NumOfGames > 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
scene.Destroy(true)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type CSLeaveRoomPacketFactory struct {
|
type CSLeaveRoomPacketFactory struct {
|
||||||
}
|
}
|
||||||
type CSLeaveRoomHandler struct {
|
type CSLeaveRoomHandler struct {
|
||||||
|
|
|
@ -35,11 +35,15 @@ func MSDollMachineListHandler(session *netlib.Session, packetId int, data interf
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取空闲娃娃机标识
|
// 获取空闲娃娃机标识
|
||||||
func GetFreeDollMachineId(id int32) int {
|
func GetFreeDollMachineId() int {
|
||||||
if MachineMap[int(id)] != nil && MachineMap[int(id)].MachineStatus == 1 {
|
// 获取互斥锁
|
||||||
return int(id)
|
MachineMapLock.Lock()
|
||||||
} else {
|
defer MachineMapLock.Unlock()
|
||||||
return 0
|
for i, v := range MachineMap {
|
||||||
|
if v.Status == false {
|
||||||
|
v.Status = true
|
||||||
|
return i
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ func HandleWGBuyRecTimeItem(session *netlib.Session, packetId int, data interfac
|
||||||
// return nil
|
// return nil
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func CreateScene(session *netlib.Session, packetId int, data interface{}) error {
|
func CreateSceneHandler(session *netlib.Session, packetId int, data interface{}) error {
|
||||||
logger.Logger.Tracef("receive CreateScene %v", data)
|
logger.Logger.Tracef("receive CreateScene %v", data)
|
||||||
msg, ok := data.(*server.WGCreateScene)
|
msg, ok := data.(*server.WGCreateScene)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -86,53 +86,52 @@ func CreateScene(session *netlib.Session, packetId int, data interface{}) error
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DestroyScene(session *netlib.Session, packetId int, data interface{}) error {
|
|
||||||
logger.Logger.Trace("receive WGDestroyScene:", data)
|
|
||||||
msg, ok := data.(*server.WGDestroyScene)
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if !msg.IsGrace {
|
|
||||||
// 立刻删除,不管游戏是否结束
|
|
||||||
for _, v := range msg.Ids {
|
|
||||||
s := base.SceneMgrSington.GetScene(int(v))
|
|
||||||
if s == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if gameScene, ok := s.ExtraData.(base.GameScene); ok {
|
|
||||||
gameScene.SceneDestroy(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 游戏结束后删除房间
|
|
||||||
for _, v := range msg.Ids {
|
|
||||||
s := base.SceneMgrSington.GetScene(int(v))
|
|
||||||
if s == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if s.IsHundredScene() || s.Gaming {
|
|
||||||
s.SetGraceDestroy()
|
|
||||||
} else {
|
|
||||||
if s.IsMatchScene() {
|
|
||||||
s.SetGraceDestroy()
|
|
||||||
}
|
|
||||||
if gameScene, ok := s.ExtraData.(base.GameScene); ok {
|
|
||||||
gameScene.SceneDestroy(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// 创建房间
|
// 创建房间
|
||||||
netlib.Register(int(server.SSPacketID_PACKET_WG_CREATESCENE), &server.WGCreateScene{}, CreateScene)
|
netlib.Register(int(server.SSPacketID_PACKET_WG_CREATESCENE), &server.WGCreateScene{}, CreateSceneHandler)
|
||||||
// 删除房间
|
|
||||||
netlib.Register(int(server.SSPacketID_PACKET_WG_DESTROYSCENE), &server.WGDestroyScene{}, DestroyScene)
|
//删除场景
|
||||||
|
// 立刻删除,不管游戏是否结束
|
||||||
|
netlib.RegisterFactory(int(server.SSPacketID_PACKET_WG_DESTROYSCENE), netlib.PacketFactoryWrapper(func() interface{} {
|
||||||
|
return &server.WGDestroyScene{}
|
||||||
|
}))
|
||||||
|
netlib.RegisterHandler(int(server.SSPacketID_PACKET_WG_DESTROYSCENE), netlib.HandlerWrapper(func(s *netlib.Session, packetid int, pack interface{}) error {
|
||||||
|
logger.Logger.Trace("receive WGDestroyScene:", pack)
|
||||||
|
msg, ok := pack.(*server.WGDestroyScene)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if !msg.IsGrace {
|
||||||
|
// 立刻删除,不管游戏是否结束
|
||||||
|
for _, v := range msg.Ids {
|
||||||
|
s := base.SceneMgrSington.GetScene(int(v))
|
||||||
|
if s != nil {
|
||||||
|
if gameScene, ok := s.ExtraData.(base.GameScene); ok {
|
||||||
|
gameScene.SceneDestroy(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 游戏结束后删除房间
|
||||||
|
for _, v := range msg.Ids {
|
||||||
|
s := base.SceneMgrSington.GetScene(int(v))
|
||||||
|
if s != nil {
|
||||||
|
if s.IsHundredScene() || s.Gaming {
|
||||||
|
s.SetGraceDestroy(true)
|
||||||
|
} else {
|
||||||
|
if s.IsMatchScene() {
|
||||||
|
s.SetGraceDestroy(true)
|
||||||
|
}
|
||||||
|
if gameScene, ok := s.ExtraData.(base.GameScene); ok {
|
||||||
|
gameScene.SceneDestroy(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}))
|
||||||
|
|
||||||
//玩家进入
|
//玩家进入
|
||||||
netlib.RegisterFactory(int(server.SSPacketID_PACKET_WG_PLAYERENTER), netlib.PacketFactoryWrapper(func() interface{} {
|
netlib.RegisterFactory(int(server.SSPacketID_PACKET_WG_PLAYERENTER), netlib.PacketFactoryWrapper(func() interface{} {
|
||||||
|
|
|
@ -149,7 +149,7 @@ func NewPlayer(sid int64, data []byte, ws, gs *netlib.Session) *Player {
|
||||||
ShopLastLookTime: make(map[int32]int64),
|
ShopLastLookTime: make(map[int32]int64),
|
||||||
IsFoolPlayer: make(map[string]bool),
|
IsFoolPlayer: make(map[string]bool),
|
||||||
},
|
},
|
||||||
GameData: make(map[string]*model.PlayerGameData),
|
GameData: make(map[int32]*model.PlayerGameData),
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.init(data) {
|
if p.init(data) {
|
||||||
|
@ -383,7 +383,7 @@ func (this *Player) MarshalData(gameid int) (d []byte, e error) {
|
||||||
if v.Platform == "" {
|
if v.Platform == "" {
|
||||||
v.Platform = this.Platform
|
v.Platform = this.Platform
|
||||||
}
|
}
|
||||||
if v.Id == "" {
|
if v.Id == 0 {
|
||||||
v.Id = k
|
v.Id = k
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,8 +118,6 @@ func NewScene(args *CreateSceneParam) *Scene {
|
||||||
KeyGameDif: args.GetDBGameFree().GetGameDif(),
|
KeyGameDif: args.GetDBGameFree().GetGameDif(),
|
||||||
}
|
}
|
||||||
s.CycleID, _ = model.AutoIncGameLogId()
|
s.CycleID, _ = model.AutoIncGameLogId()
|
||||||
s.rrVer = ReplayRecorderVer[gameId]
|
|
||||||
s.RecordReplayStart()
|
|
||||||
s.init()
|
s.init()
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
@ -298,8 +296,8 @@ func (this *Scene) SetScenePolicy(sp ScenePolicy) {
|
||||||
func (this *Scene) GetGraceDestroy() bool {
|
func (this *Scene) GetGraceDestroy() bool {
|
||||||
return this.graceDestroy
|
return this.graceDestroy
|
||||||
}
|
}
|
||||||
func (this *Scene) SetGraceDestroy() {
|
func (this *Scene) SetGraceDestroy(graceDestroy bool) {
|
||||||
this.graceDestroy = true
|
this.graceDestroy = graceDestroy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) GetCpControlled() bool {
|
func (this *Scene) GetCpControlled() bool {
|
||||||
|
@ -2556,7 +2554,6 @@ func (this *Scene) TryRelease() {
|
||||||
}
|
}
|
||||||
func (this *Scene) GetMachineServerInfo(MachineId int32, platform string) *webapi.MachineInfo {
|
func (this *Scene) GetMachineServerInfo(MachineId int32, platform string) *webapi.MachineInfo {
|
||||||
config := ConfigMgrInst.GetConfig(platform).MachineConfig
|
config := ConfigMgrInst.GetConfig(platform).MachineConfig
|
||||||
logger.Logger.Tracef("========GetMachineServerInfo=========== platform=%s, MachineId=%d ,config = %v", platform, MachineId, config)
|
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/protocol/machine"
|
"mongo.games.com/game/protocol/machine"
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
@ -31,7 +32,7 @@ func (this *SrvSessMgr) OnRegiste(s *netlib.Session) {
|
||||||
} else if srvInfo.GetType() == 10 {
|
} else if srvInfo.GetType() == 10 {
|
||||||
logger.Logger.Warn("(this *SrvSessMgr) OnRegiste (Machine):", s)
|
logger.Logger.Warn("(this *SrvSessMgr) OnRegiste (Machine):", s)
|
||||||
s.Send(int(machine.DollMachinePacketID_PACKET_SMGameLinkSucceed), &machine.SMGameLinkSucceed{})
|
s.Send(int(machine.DollMachinePacketID_PACKET_SMGameLinkSucceed), &machine.SMGameLinkSucceed{})
|
||||||
logger.Logger.Info("与娃娃机服务器连接成功\n")
|
fmt.Printf("与娃娃机服务器连接成功\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,8 @@ func (this *PolicyClawdoll) OnTick(s *base.Scene) {
|
||||||
sceneEx, ok := s.ExtraData.(*SceneEx)
|
sceneEx, ok := s.ExtraData.(*SceneEx)
|
||||||
if ok {
|
if ok {
|
||||||
if sceneEx.machineId == 0 {
|
if sceneEx.machineId == 0 {
|
||||||
machineId := s.DBGameFree.GetId() % 6080000
|
//machineId := s.DBGameFree.GetId() % 6080000
|
||||||
sceneEx.machineId = action.GetFreeDollMachineId(machineId)
|
sceneEx.machineId = action.GetFreeDollMachineId()
|
||||||
}
|
}
|
||||||
if sceneEx.machineId != 0 {
|
if sceneEx.machineId != 0 {
|
||||||
machineStatus := action.GetDollMachineStatus(sceneEx.machineId)
|
machineStatus := action.GetDollMachineStatus(sceneEx.machineId)
|
||||||
|
|
|
@ -148,9 +148,6 @@ func (this *ScenePolicyTienLen) OnPlayerLeave(s *base.Scene, p *base.Player, rea
|
||||||
}
|
}
|
||||||
sceneEx.OnPlayerLeave(p, reason)
|
sceneEx.OnPlayerLeave(p, reason)
|
||||||
s.FirePlayerEvent(p, base.PlayerEventLeave, []int64{int64(reason)})
|
s.FirePlayerEvent(p, base.PlayerEventLeave, []int64{int64(reason)})
|
||||||
if s.IsCustom() && len(s.Players) == 0 {
|
|
||||||
s.Destroy(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 玩家掉线
|
// 玩家掉线
|
||||||
|
@ -606,6 +603,9 @@ func (this *SceneBaseStateTienLen) OnTick(s *base.Scene) {
|
||||||
s.RandRobotCnt()
|
s.RandRobotCnt()
|
||||||
s.SetTimerRandomRobot(s.GetRobotTime())
|
s.SetTimerRandomRobot(s.GetRobotTime())
|
||||||
}
|
}
|
||||||
|
if s.IsCustom() && len(s.Players) == 0 {
|
||||||
|
s.Destroy(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送玩家操作情况
|
// 发送玩家操作情况
|
||||||
|
@ -2765,10 +2765,7 @@ func (this *SceneBilledStateTienLen) OnLeave(s *base.Scene) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
player_data.Clear()
|
player_data.Clear()
|
||||||
if sceneEx.IsCustom() {
|
if sceneEx.IsMatchScene() {
|
||||||
player_data.UnmarkFlag(base.PlayerState_WaitNext)
|
|
||||||
}
|
|
||||||
if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !player_data.IsOnLine() {
|
if !player_data.IsOnLine() {
|
||||||
|
|
|
@ -106,7 +106,7 @@ func init() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pack.Tag = webapiproto.TagCode_FAILED
|
pack.Tag = webapiproto.TagCode_FAILED
|
||||||
pack.Msg = "数据序列化失败"
|
pack.Msg = "数据序列化失败"
|
||||||
return common.ResponseTag_Ok, pack
|
return common.ResponseTag_ParamError, pack
|
||||||
}
|
}
|
||||||
pack.Tag = webapiproto.TagCode_SUCCESS
|
pack.Tag = webapiproto.TagCode_SUCCESS
|
||||||
|
|
||||||
|
@ -114,11 +114,11 @@ func init() {
|
||||||
if scene == nil || scene.ExtraData == nil {
|
if scene == nil || scene.ExtraData == nil {
|
||||||
pack.Tag = webapiproto.TagCode_NotFound
|
pack.Tag = webapiproto.TagCode_NotFound
|
||||||
pack.Msg = "房间没找到"
|
pack.Msg = "房间没找到"
|
||||||
return common.ResponseTag_Ok, pack
|
return common.ResponseTag_NoFindRoom, pack
|
||||||
}
|
}
|
||||||
|
|
||||||
switch d := scene.ExtraData.(type) {
|
switch d := scene.ExtraData.(type) {
|
||||||
case *tienlen.TienLenSceneData:
|
case tienlen.TienLenSceneData:
|
||||||
for k := range d.BilledList {
|
for k := range d.BilledList {
|
||||||
pack.SnId = append(pack.SnId, k)
|
pack.SnId = append(pack.SnId, k)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
"mongo.games.com/goserver/core/timer"
|
"mongo.games.com/goserver/core/timer"
|
||||||
"strconv"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -170,7 +169,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid
|
||||||
num := int64(1)
|
num := int64(1)
|
||||||
for {
|
for {
|
||||||
// 读取数据
|
// 读取数据
|
||||||
//logger.Logger.Trace("监听抓取结果返回!")
|
logger.Logger.Trace("监听抓取结果返回!")
|
||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
n, err := conn.Read(buf)
|
n, err := conn.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -179,7 +178,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid
|
||||||
}
|
}
|
||||||
// 将读取到的数据按照 221 进行分割
|
// 将读取到的数据按照 221 进行分割
|
||||||
parts := bytes.Split(buf[:n], []byte{221})
|
parts := bytes.Split(buf[:n], []byte{221})
|
||||||
//fmt.Println("获取到的返回值:", parts)
|
fmt.Println("获取到的返回值:", parts)
|
||||||
instruction := []byte{0xAA, 0x05, 0x02, 0x50, 0x09, 0x00}
|
instruction := []byte{0xAA, 0x05, 0x02, 0x50, 0x09, 0x00}
|
||||||
instruction1 := []byte{0xAA, 0x05, 0x02, 0x50, 0x09, 0x01}
|
instruction1 := []byte{0xAA, 0x05, 0x02, 0x50, 0x09, 0x01}
|
||||||
// 遍历分割结果,打印出每个部分
|
// 遍历分割结果,打印出每个部分
|
||||||
|
@ -188,23 +187,6 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid
|
||||||
part = part[:len(part)-1] // 去除最后一个字节,该字节为分隔符
|
part = part[:len(part)-1] // 去除最后一个字节,该字节为分隔符
|
||||||
//fmt.Println("比较返回结果 part = ", part)
|
//fmt.Println("比较返回结果 part = ", part)
|
||||||
if bytes.Contains(part, instruction) && num != 1 {
|
if bytes.Contains(part, instruction) && num != 1 {
|
||||||
//fmt.Printf("Part %d: %s\n", i+1, part)
|
|
||||||
//回应数据
|
|
||||||
_, err = conn.Write([]byte{0xAA, 0x04, 0x01, 0x50, 0x09, 0x5c, 0xdd})
|
|
||||||
if err != nil {
|
|
||||||
//fmt.Println("Failed to read response from server:", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println("没有抓到礼品!!!!!!!!snid = ", snid, "num = ", num)
|
|
||||||
machinedoll.SendToGameServer(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{
|
|
||||||
Snid: snid,
|
|
||||||
Id: id,
|
|
||||||
Result: 0,
|
|
||||||
TypeId: 2,
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if bytes.Contains(part, instruction1) && num != 1 {
|
|
||||||
fmt.Printf("Part %d: %s\n", i+1, part)
|
fmt.Printf("Part %d: %s\n", i+1, part)
|
||||||
//回应数据
|
//回应数据
|
||||||
_, err = conn.Write([]byte{0xAA, 0x04, 0x01, 0x50, 0x09, 0x5c, 0xdd})
|
_, err = conn.Write([]byte{0xAA, 0x04, 0x01, 0x50, 0x09, 0x5c, 0xdd})
|
||||||
|
@ -212,38 +194,53 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid
|
||||||
fmt.Println("Failed to read response from server:", err)
|
fmt.Println("Failed to read response from server:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("抓到礼品了!!!!!!!!snid = ", snid, "num = ", num)
|
session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{
|
||||||
machinedoll.SendToGameServer(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{
|
Snid: snid,
|
||||||
|
Id: id,
|
||||||
|
Result: 0,
|
||||||
|
TypeId: 2,
|
||||||
|
})
|
||||||
|
logger.Logger.Trace("没有抓到礼品!!!!!!!!snid = ", snid, "num = ", num)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if bytes.Contains(part, instruction1) && num != 1 {
|
||||||
|
fmt.Printf("Part %d: %s\n", i+1, part)
|
||||||
|
//回应数据
|
||||||
|
_, err = conn.Write([]byte{0xAA, 0x04, 0x01, 0x50, 0x09, 0x5c, 0xdd})
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Error("Failed to read response from server:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{
|
||||||
Snid: snid,
|
Snid: snid,
|
||||||
Id: id,
|
Id: id,
|
||||||
Result: 1,
|
Result: 1,
|
||||||
TypeId: 2,
|
TypeId: 2,
|
||||||
})
|
})
|
||||||
|
logger.Logger.Trace("抓到礼品了!!!!!!!!snid = ", snid, "num = ", num)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//上分成功
|
//上分成功
|
||||||
coinData := []byte{0xAA, 0x04, 0x02, 0x03, 0x01}
|
coinData := []byte{0xAA, 0x04, 0x02, 0x03, 0x01}
|
||||||
if bytes.Contains(part, coinData) {
|
if bytes.Contains(part, coinData) {
|
||||||
//返回消息
|
//返回消息
|
||||||
machinedoll.SendToGameServer(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{
|
session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{
|
||||||
Snid: snid,
|
Snid: snid,
|
||||||
Id: id,
|
Id: id,
|
||||||
Result: 1,
|
Result: 1,
|
||||||
TypeId: 1,
|
TypeId: 1,
|
||||||
})
|
})
|
||||||
fmt.Println("上分成功!!!!!!!!!!snid = ", snid, "num = ", num)
|
|
||||||
}
|
}
|
||||||
//上分失败
|
//上分失败
|
||||||
coinData = []byte{0xAA, 0x04, 0x02, 0x03, 0x00}
|
coinData = []byte{0xAA, 0x04, 0x02, 0x03, 0x00}
|
||||||
if bytes.Contains(part, coinData) {
|
if bytes.Contains(part, coinData) {
|
||||||
//返回消息
|
//返回消息
|
||||||
machinedoll.SendToGameServer(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{
|
session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{
|
||||||
Snid: snid,
|
Snid: snid,
|
||||||
Id: id,
|
Id: id,
|
||||||
Result: 0,
|
Result: 0,
|
||||||
TypeId: 1,
|
TypeId: 1,
|
||||||
})
|
})
|
||||||
fmt.Println("上分失败!!!!!!!!!!snid = ", snid, "num = ", num)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,7 +253,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid
|
||||||
|
|
||||||
// 与游戏服务器连接成功,向游戏服务器推送所有娃娃机连接
|
// 与游戏服务器连接成功,向游戏服务器推送所有娃娃机连接
|
||||||
func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interface{}) error {
|
func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interface{}) error {
|
||||||
fmt.Println("与游戏服务器连接成功")
|
logger.Logger.Trace("与游戏服务器连接成功")
|
||||||
//开始向游戏服务器发送娃娃机连接信息
|
//开始向游戏服务器发送娃娃机连接信息
|
||||||
msg := &machine.MSDollMachineList{}
|
msg := &machine.MSDollMachineList{}
|
||||||
for i, _ := range machinedoll.MachineMgr.ConnMap {
|
for i, _ := range machinedoll.MachineMgr.ConnMap {
|
||||||
|
@ -265,7 +262,7 @@ func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interf
|
||||||
msg.Data = append(msg.Data, info)
|
msg.Data = append(msg.Data, info)
|
||||||
}
|
}
|
||||||
session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineList), msg)
|
session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineList), msg)
|
||||||
fmt.Println("向游戏服务器发送娃娃机连接信息:%v", msg)
|
logger.Logger.Tracef("向游戏服务器发送娃娃机连接信息:%v", msg)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +290,7 @@ func SMGetTokenHandler(session *netlib.Session, packetId int, data interface{})
|
||||||
var payload string = ""
|
var payload string = ""
|
||||||
|
|
||||||
//生成token
|
//生成token
|
||||||
token, err := token04.GenerateToken04(appId, strconv.Itoa(int(userId)), serverSecret, effectiveTimeInSeconds, payload)
|
token, err := token04.GenerateToken04(appId, string(userId), serverSecret, effectiveTimeInSeconds, payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Logger.Error(err)
|
logger.Logger.Error(err)
|
||||||
return err
|
return err
|
||||||
|
@ -306,7 +303,7 @@ func SMGetTokenHandler(session *netlib.Session, packetId int, data interface{})
|
||||||
info.StreamId = msg.StreamId
|
info.StreamId = msg.StreamId
|
||||||
|
|
||||||
session.Send(int(machine.DollMachinePacketID_PACKET_MSSendToken), info)
|
session.Send(int(machine.DollMachinePacketID_PACKET_MSSendToken), info)
|
||||||
fmt.Println("向游戏服务器发送娃娃机token:%v", info)
|
logger.Logger.Tracef("向游戏服务器发送娃娃机token:%v", info)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,9 @@ func (this *MachineManager) UpdateToGameServer(conn *Conn, status int32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendToGameServer(pid int, msg interface{}) {
|
func SendToGameServer(pid int, msg interface{}) {
|
||||||
GameConn = srvlib.ServerSessionMgrSington.GetSession(1, 7, 777)
|
if GameConn == nil {
|
||||||
|
GameConn = srvlib.ServerSessionMgrSington.GetSession(1, 7, 701)
|
||||||
|
}
|
||||||
if GameConn != nil {
|
if GameConn != nil {
|
||||||
GameConn.Send(pid, msg)
|
GameConn.Send(pid, msg)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"slices"
|
"mongo.games.com/game/protocol/gamehall"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/protocol/gamehall"
|
|
||||||
"mongo.games.com/game/protocol/shop"
|
"mongo.games.com/game/protocol/shop"
|
||||||
"mongo.games.com/game/protocol/webapi"
|
"mongo.games.com/game/protocol/webapi"
|
||||||
)
|
)
|
||||||
|
@ -77,7 +76,7 @@ func (this *ShopInfo) GetItems() []ItemInfo {
|
||||||
if this.ItemId > 0 {
|
if this.ItemId > 0 {
|
||||||
ret = append(ret, ItemInfo{
|
ret = append(ret, ItemInfo{
|
||||||
ItemId: this.ItemId,
|
ItemId: this.ItemId,
|
||||||
ItemNum: this.AmountFinal,
|
ItemNum: this.Amount,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
for _, v := range this.AddItemInfo {
|
for _, v := range this.AddItemInfo {
|
||||||
|
@ -406,19 +405,7 @@ func (cm *ConfigMgr) UpdateRoomConfig(data *webapi.RoomConfig) {
|
||||||
if d == nil {
|
if d == nil {
|
||||||
d = make([]*webapi.RoomConfig, 0)
|
d = make([]*webapi.RoomConfig, 0)
|
||||||
}
|
}
|
||||||
|
d = append(d, data)
|
||||||
has := false
|
|
||||||
for k, v := range d {
|
|
||||||
if v.GetId() == data.GetId() {
|
|
||||||
d[k] = data
|
|
||||||
has = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !has {
|
|
||||||
d = append(d, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
cm.GetConfig(data.GetPlatform()).RoomTypeMap[data.GetRoomType()] = d
|
cm.GetConfig(data.GetPlatform()).RoomTypeMap[data.GetRoomType()] = d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,18 +413,19 @@ func (cm *ConfigMgr) DelRoomConfig(plt string, id int32) {
|
||||||
d := cm.GetConfig(plt).RoomConfig[id]
|
d := cm.GetConfig(plt).RoomConfig[id]
|
||||||
if d != nil {
|
if d != nil {
|
||||||
b := cm.GetConfig(plt).RoomTypeMap[d.GetRoomType()]
|
b := cm.GetConfig(plt).RoomTypeMap[d.GetRoomType()]
|
||||||
for i, v := range b {
|
if b != nil {
|
||||||
if v.GetId() == id {
|
for i, v := range b {
|
||||||
b = append(b[:i], b[i+1:]...)
|
if v.GetId() == id {
|
||||||
cm.GetConfig(plt).RoomTypeMap[d.GetRoomType()] = b
|
b = append(b[:i], b[i+1:]...)
|
||||||
break
|
cm.GetConfig(plt).RoomTypeMap[d.GetRoomType()] = b
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete(cm.GetConfig(plt).RoomConfig, id)
|
delete(cm.GetConfig(plt).RoomConfig, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm *ConfigMgr) GetRoomConfig(plt string, lastChannel string) *gamehall.SCRoomConfig {
|
func (cm *ConfigMgr) GetRoomConfig(plt string) *gamehall.SCRoomConfig {
|
||||||
pack := &gamehall.SCRoomConfig{}
|
pack := &gamehall.SCRoomConfig{}
|
||||||
for _, v := range cm.GetConfig(plt).RoomType {
|
for _, v := range cm.GetConfig(plt).RoomType {
|
||||||
if v.GetOn() != common.On {
|
if v.GetOn() != common.On {
|
||||||
|
@ -448,10 +436,6 @@ func (cm *ConfigMgr) GetRoomConfig(plt string, lastChannel string) *gamehall.SCR
|
||||||
if vv.GetOn() != common.On {
|
if vv.GetOn() != common.On {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if lastChannel != "" && !slices.Contains(vv.GetOnChannelName(), lastChannel) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var cost, reward []*gamehall.ItemInfo
|
var cost, reward []*gamehall.ItemInfo
|
||||||
for _, item := range vv.GetCost() {
|
for _, item := range vv.GetCost() {
|
||||||
cost = append(cost, &gamehall.ItemInfo{
|
cost = append(cost, &gamehall.ItemInfo{
|
||||||
|
|
|
@ -348,7 +348,7 @@ type MatchFreeSignupRec struct {
|
||||||
// 大厅玩家信息发送给游戏服
|
// 大厅玩家信息发送给游戏服
|
||||||
type WGPlayerInfo struct {
|
type WGPlayerInfo struct {
|
||||||
*PlayerData
|
*PlayerData
|
||||||
GameData map[string]*PlayerGameData // 游戏数据,只允许存储玩家对应某个游戏需要持久化的数据
|
GameData map[int32]*PlayerGameData // 游戏数据,只允许存储玩家对应某个游戏需要持久化的数据
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlayerData struct {
|
type PlayerData struct {
|
||||||
|
@ -981,7 +981,7 @@ func NewPlayerData(acc string, name string, id int32, channel, platform string,
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPlayerDataThird(acc string, name, headUrl string, id int32, channel, platform string, params, tel string,
|
func NewPlayerDataThird(acc string, name, headUrl string, id int32, channel, platform string, params, tel string,
|
||||||
packTag, ip string, tagkey, accountType int32, deviceOS, channelId string) *PlayerData {
|
packTag, ip string, tagkey, accountType int32, deviceOS string) *PlayerData {
|
||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
logger.Logger.Trace("New player name is empty.")
|
logger.Logger.Trace("New player name is empty.")
|
||||||
return nil
|
return nil
|
||||||
|
@ -992,7 +992,6 @@ func NewPlayerDataThird(acc string, name, headUrl string, id int32, channel, pla
|
||||||
AccountId: acc,
|
AccountId: acc,
|
||||||
Name: name,
|
Name: name,
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
ChannelId: channelId,
|
|
||||||
Platform: platform,
|
Platform: platform,
|
||||||
SnId: id,
|
SnId: id,
|
||||||
Head: rand.Int31n(common.HeadRange),
|
Head: rand.Int31n(common.HeadRange),
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
type PlayerGameData struct {
|
type PlayerGameData struct {
|
||||||
Platform string `bson:"-"`
|
Platform string `bson:"-"`
|
||||||
SnId int32
|
SnId int32
|
||||||
Id string // 游戏id或场次id
|
Id int32 // 游戏id或场次id
|
||||||
Data interface{} // 数据
|
Data interface{} // 数据
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
if exist "..\public" (
|
if exist ".\public" (
|
||||||
cd ..\public
|
cd .\public
|
||||||
git checkout main
|
git checkout main
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
xcopy ..\game\data .\data /s /e /y
|
xcopy ..\data .\data /s /e /y
|
||||||
xcopy ..\game\protocol .\protocol /s /e /y
|
xcopy ..\protocol .\protocol /s /e /y
|
||||||
xcopy ..\game\xlsx .\xlsx /s /e /y
|
xcopy ..\xlsx .\xlsx /s /e /y
|
||||||
|
|
||||||
git add .
|
git add .
|
||||||
git commit -m "update"
|
git commit -m "update"
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ func CSRoomConfigHandler(s *netlib.Session, packetId int, data interface{}, sid
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
pack := PlatformMgrSingleton.GetRoomConfig(p.Platform, p.LastChannel)
|
pack := PlatformMgrSingleton.GetRoomConfig(p.Platform)
|
||||||
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SCRoomConfig), pack)
|
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SCRoomConfig), pack)
|
||||||
logger.Logger.Tracef("SCRoomConfig: %v", pack)
|
logger.Logger.Tracef("SCRoomConfig: %v", pack)
|
||||||
return nil
|
return nil
|
||||||
|
@ -1202,36 +1202,18 @@ func CSCreatePrivateRoomHandler(s *netlib.Session, packetId int, data interface{
|
||||||
send()
|
send()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !slices.Contains(cfg.GetOnChannelName(), p.LastChannel) {
|
|
||||||
send()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
f := func(param []int32) []int32 {
|
|
||||||
if len(param) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if param[0] == 0 {
|
|
||||||
return param[1:]
|
|
||||||
}
|
|
||||||
if param[0] > 0 && int(param[0]) < len(param) {
|
|
||||||
return []int32{param[param[0]]}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 场次
|
// 场次
|
||||||
if !slices.Contains(f(cfg.GetGameFreeId()), msg.GetGameFreeId()) {
|
if !slices.Contains(cfg.GetGameFreeId(), msg.GetGameFreeId()) {
|
||||||
send()
|
send()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// 局数
|
// 局数
|
||||||
if !slices.Contains(f(cfg.GetRound()), msg.GetRound()) {
|
if !slices.Contains(cfg.GetRound(), msg.GetRound()) {
|
||||||
send()
|
send()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// 玩家数量
|
// 玩家数量
|
||||||
if !slices.Contains(f(cfg.GetPlayerNum()), msg.GetPlayerNum()) {
|
if !slices.Contains(cfg.GetPlayerNum(), msg.GetPlayerNum()) {
|
||||||
send()
|
send()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1938,9 +1938,6 @@ func CSPlayerData(s *netlib.Session, packetid int, data interface{}, sid int64)
|
||||||
if (p.Channel == "" || p.Channel == "0") && p.Channel != msg.AppChannel {
|
if (p.Channel == "" || p.Channel == "0") && p.Channel != msg.AppChannel {
|
||||||
p.Channel = msg.AppChannel
|
p.Channel = msg.AppChannel
|
||||||
}
|
}
|
||||||
if ls.als.acc.ChannelId != "" && p.ChannelId == "" {
|
|
||||||
p.ChannelId = ls.als.acc.ChannelId
|
|
||||||
}
|
|
||||||
|
|
||||||
if ls.clog != nil {
|
if ls.clog != nil {
|
||||||
PlayerSubjectSign.UpdateHeadUrl(p.SnId, ls.clog.HeadUrl)
|
PlayerSubjectSign.UpdateHeadUrl(p.SnId, ls.clog.HeadUrl)
|
||||||
|
|
|
@ -93,10 +93,80 @@ func init() {
|
||||||
etcd.Register(etcd.ETCDKEY_MatchAudience, webapi.MatchAudience{}, handlerEvent)
|
etcd.Register(etcd.ETCDKEY_MatchAudience, webapi.MatchAudience{}, handlerEvent)
|
||||||
// 小精灵配置
|
// 小精灵配置
|
||||||
etcd.Register(etcd.ETCDKEY_Spirit, webapi.SpiritConfig{}, platformConfigEvent)
|
etcd.Register(etcd.ETCDKEY_Spirit, webapi.SpiritConfig{}, platformConfigEvent)
|
||||||
// 竞技馆房间配置
|
|
||||||
etcd.Register(etcd.ETCDKEY_RoomConfig, webapi.RoomConfig{}, handlerEvent)
|
PlatformMgrSingleton.GetConfig("1").RoomType = map[int32]*webapi.RoomType{
|
||||||
// 竞技馆房间类型配置
|
1: {
|
||||||
etcd.Register(etcd.ETCDKEY_RoomType, webapi.RoomType{}, handlerEvent)
|
Platform: "1",
|
||||||
|
Id: 1,
|
||||||
|
Name: "{\"zh\":\"话费赛\",\"kh\":\"话费赛\",\"vi\":\"话费赛\",\"en\":\"话费赛\"}",
|
||||||
|
On: 1,
|
||||||
|
SortId: 1,
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
Platform: "1",
|
||||||
|
Id: 2,
|
||||||
|
Name: "{\"zh\":\"物品赛\",\"kh\":\"物品赛\",\"vi\":\"物品赛\",\"en\":\"物品赛\"}",
|
||||||
|
On: 1,
|
||||||
|
SortId: 2,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
PlatformMgrSingleton.UpdateRoomConfig(&webapi.RoomConfig{
|
||||||
|
Platform: "1",
|
||||||
|
Id: 1,
|
||||||
|
Name: "{\"zh\":\"1元话费赛\",\"kh\":\"1元话费赛\",\"vi\":\"1元话费赛\",\"en\":\"1元话费赛\"}",
|
||||||
|
RoomType: 1,
|
||||||
|
On: 1,
|
||||||
|
SortId: 1,
|
||||||
|
Cost: []*webapi.ItemInfo{
|
||||||
|
{
|
||||||
|
ItemId: 100001,
|
||||||
|
ItemNum: 12,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Reward: []*webapi.ItemInfo{
|
||||||
|
{
|
||||||
|
ItemId: 100001,
|
||||||
|
ItemNum: 12,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
OnChannelName: []string{common.ChannelOfficial, common.ChannelWeb, common.ChannelGooglePlay},
|
||||||
|
GameFreeId: []int32{2150001, 2160001, 2170001, 2180001},
|
||||||
|
Round: []int32{1, 2, 3, 4},
|
||||||
|
PlayerNum: []int32{2, 3, 4},
|
||||||
|
NeedPassword: 3,
|
||||||
|
CostType: 3,
|
||||||
|
Voice: 3,
|
||||||
|
ImageURI: "",
|
||||||
|
})
|
||||||
|
PlatformMgrSingleton.UpdateRoomConfig(&webapi.RoomConfig{
|
||||||
|
Platform: "1",
|
||||||
|
Id: 2,
|
||||||
|
Name: "{\"zh\":\"2元话费赛\",\"kh\":\"2元话费赛\",\"vi\":\"2元话费赛\",\"en\":\"2元话费赛\"}",
|
||||||
|
RoomType: 1,
|
||||||
|
On: 1,
|
||||||
|
SortId: 2,
|
||||||
|
Cost: []*webapi.ItemInfo{
|
||||||
|
{
|
||||||
|
ItemId: 100001,
|
||||||
|
ItemNum: 12,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Reward: []*webapi.ItemInfo{
|
||||||
|
{
|
||||||
|
ItemId: 100001,
|
||||||
|
ItemNum: 12,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
OnChannelName: []string{common.ChannelOfficial, common.ChannelWeb, common.ChannelGooglePlay},
|
||||||
|
GameFreeId: []int32{2150001, 2160001, 2170001, 2180001},
|
||||||
|
Round: []int32{1, 2, 3, 4},
|
||||||
|
PlayerNum: []int32{2, 3, 4},
|
||||||
|
NeedPassword: 3,
|
||||||
|
CostType: 3,
|
||||||
|
Voice: 3,
|
||||||
|
ImageURI: "",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
||||||
|
@ -485,7 +555,7 @@ func handlerEvent(ctx context.Context, completeKey string, isInit bool, event *c
|
||||||
config := data.(*webapi.RoomType)
|
config := data.(*webapi.RoomType)
|
||||||
PlatformMgrSingleton.UpdateRoomType(config)
|
PlatformMgrSingleton.UpdateRoomType(config)
|
||||||
if !isInit {
|
if !isInit {
|
||||||
//PlayerMgrSington.BroadcastMessageToPlatform(config.GetPlatform(), int(0), nil)
|
PlayerMgrSington.BroadcastMessageToPlatform(config.GetPlatform(), int(0), nil)
|
||||||
}
|
}
|
||||||
case clientv3.EventTypeDelete:
|
case clientv3.EventTypeDelete:
|
||||||
if plt == "" || len(param) == 0 {
|
if plt == "" || len(param) == 0 {
|
||||||
|
@ -493,7 +563,7 @@ func handlerEvent(ctx context.Context, completeKey string, isInit bool, event *c
|
||||||
}
|
}
|
||||||
PlatformMgrSingleton.DelRoomType(plt, int32(param[0]))
|
PlatformMgrSingleton.DelRoomType(plt, int32(param[0]))
|
||||||
if !isInit {
|
if !isInit {
|
||||||
//PlayerMgrSington.BroadcastMessageToPlatform(plt, int(0), nil)
|
PlayerMgrSington.BroadcastMessageToPlatform(plt, int(0), nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ type AllPlayerInfo struct {
|
||||||
|
|
||||||
// PlayerInfo 玩家信息
|
// PlayerInfo 玩家信息
|
||||||
type PlayerInfo struct {
|
type PlayerInfo struct {
|
||||||
GameData map[string]*model.PlayerGameData // 游戏数据
|
GameData map[int32]*model.PlayerGameData // 游戏数据
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlayerInfoMgr struct {
|
type PlayerInfoMgr struct {
|
||||||
|
@ -69,7 +69,7 @@ func (p *PlayerInfoMgr) Callback(player any, ret *internal.PlayerLoadReplay) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
info := &PlayerInfo{
|
info := &PlayerInfo{
|
||||||
GameData: make(map[string]*model.PlayerGameData),
|
GameData: make(map[int32]*model.PlayerGameData),
|
||||||
}
|
}
|
||||||
|
|
||||||
// 游戏数据
|
// 游戏数据
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"slices"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/protocol/gamehall"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -78,34 +76,7 @@ func (p *PlayerNotify) GetPlayers(tp common.NotifyType) []int32 {
|
||||||
// SendToClient 发送消息给客户端
|
// SendToClient 发送消息给客户端
|
||||||
// tp 消息类型
|
// tp 消息类型
|
||||||
func (p *PlayerNotify) SendToClient(tp common.NotifyType, packetId int, pack interface{}) {
|
func (p *PlayerNotify) SendToClient(tp common.NotifyType, packetId int, pack interface{}) {
|
||||||
switch tp {
|
ids := p.GetPlayers(tp)
|
||||||
case common.NotifyPrivateRoomList:
|
PlayerMgrSington.BroadcastMessageToTarget(ids, packetId, pack)
|
||||||
d := pack.(*gamehall.SCGetPrivateRoomList)
|
logger.Logger.Tracef("PlayerNotify SendToClient tp:%v ids:%v", tp, ids)
|
||||||
if len(d.GetDatas()) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
scene := SceneMgrSingleton.GetScene(int(d.GetDatas()[0].GetRoomId()))
|
|
||||||
if scene == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
roomConfigId := d.GetDatas()[0].GetRoomConfigId()
|
|
||||||
cfg := PlatformMgrSingleton.GetConfig(scene.limitPlatform.IdStr).RoomConfig[roomConfigId]
|
|
||||||
if cfg == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var ids []int32
|
|
||||||
for _, v := range p.GetPlayers(tp) {
|
|
||||||
player := PlayerMgrSington.GetPlayerBySnId(v)
|
|
||||||
if player == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if slices.Contains(cfg.GetOnChannelName(), player.LastChannel) {
|
|
||||||
ids = append(ids, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerMgrSington.BroadcastMessageToTarget(ids, packetId, pack)
|
|
||||||
logger.Logger.Tracef("PlayerNotify SendToClient tp:%v ids:%v", tp, ids)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,7 @@ func NewScene(args *CreateSceneParam) *Scene {
|
||||||
if s.CustomParam == nil {
|
if s.CustomParam == nil {
|
||||||
s.CustomParam = new(serverproto.CustomParam)
|
s.CustomParam = new(serverproto.CustomParam)
|
||||||
}
|
}
|
||||||
|
s.sp.OnStart(s)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,6 +514,8 @@ func (this *Scene) lastScene(p *Player) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) DelPlayer(p *Player) bool {
|
func (this *Scene) DelPlayer(p *Player) bool {
|
||||||
|
FirePlayerLeaveScene(p, this)
|
||||||
|
this.sp.OnPlayerLeave(this, p)
|
||||||
if p.scene != this {
|
if p.scene != this {
|
||||||
roomId := 0
|
roomId := 0
|
||||||
if p.scene != nil {
|
if p.scene != nil {
|
||||||
|
@ -553,8 +556,6 @@ func (this *Scene) DelPlayer(p *Player) bool {
|
||||||
if !p.IsRob {
|
if !p.IsRob {
|
||||||
this.lastTime = time.Now()
|
this.lastTime = time.Now()
|
||||||
}
|
}
|
||||||
FirePlayerLeaveScene(p, this)
|
|
||||||
this.sp.OnPlayerLeave(this, p)
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,9 +683,9 @@ func (this *Scene) OnClose() {
|
||||||
}
|
}
|
||||||
this.Broadcast(int(hallproto.GameHallPacketID_PACKET_SC_DESTROYROOM), scDestroyRoom, 0)
|
this.Broadcast(int(hallproto.GameHallPacketID_PACKET_SC_DESTROYROOM), scDestroyRoom, 0)
|
||||||
|
|
||||||
this.sp.OnStop(this)
|
|
||||||
this.deleting = true
|
this.deleting = true
|
||||||
this.closed = true
|
this.closed = true
|
||||||
|
this.sp.OnStop(this)
|
||||||
|
|
||||||
for _, p := range this.players {
|
for _, p := range this.players {
|
||||||
this.DelPlayer(p)
|
this.DelPlayer(p)
|
||||||
|
|
|
@ -183,35 +183,34 @@ func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode
|
||||||
((s.gameId == gameId && s.gameMode == gameMode) || gameId == 0) &&
|
((s.gameId == gameId && s.gameMode == gameMode) || gameId == 0) &&
|
||||||
(s.sceneId == sceneId || sceneId == 0) && (s.groupId == int32(groupId) || groupId == 0) &&
|
(s.sceneId == sceneId || sceneId == 0) && (s.groupId == int32(groupId) || groupId == 0) &&
|
||||||
(s.dbGameFree.GetId() == gameFreeId || gameFreeId == 0) &&
|
(s.dbGameFree.GetId() == gameFreeId || gameFreeId == 0) &&
|
||||||
(s.sceneMode == sceneMode || sceneMode == -1) &&
|
(s.sceneMode == sceneMode || sceneMode == -1)) || isNeedFindAll &&
|
||||||
((s.IsCustom() && isCustom) || !isCustom) &&
|
((s.IsCustom() && isCustom) || !isCustom) &&
|
||||||
(s.GetRoomConfigId() == roomConfigId || roomConfigId == 0)) || isNeedFindAll {
|
(s.GetRoomConfigId() == roomConfigId || roomConfigId == 0) {
|
||||||
var platformName string
|
var platformName string
|
||||||
if s.limitPlatform != nil {
|
if s.limitPlatform != nil {
|
||||||
platformName = s.limitPlatform.IdStr
|
platformName = s.limitPlatform.IdStr
|
||||||
}
|
}
|
||||||
|
|
||||||
si := &webapiproto.RoomInfo{
|
si := &webapiproto.RoomInfo{
|
||||||
Platform: platformName,
|
Platform: platformName,
|
||||||
SceneId: int32(s.sceneId),
|
SceneId: int32(s.sceneId),
|
||||||
GameId: int32(s.gameId),
|
GameId: int32(s.gameId),
|
||||||
GameMode: int32(s.gameMode),
|
GameMode: int32(s.gameMode),
|
||||||
SceneMode: int32(s.sceneMode),
|
SceneMode: int32(s.sceneMode),
|
||||||
GroupId: s.groupId,
|
GroupId: s.groupId,
|
||||||
GameFreeId: s.dbGameFree.GetId(),
|
Creator: s.creator,
|
||||||
Creator: s.creator,
|
ReplayCode: s.replayCode,
|
||||||
ReplayCode: s.replayCode,
|
Params: common.CopySliceInt64ToInt32(s.params),
|
||||||
Params: common.CopySliceInt64ToInt32(s.params),
|
PlayerCnt: int32(len(s.players) - s.robotNum),
|
||||||
PlayerCnt: int32(len(s.players) - s.robotNum),
|
RobotCnt: int32(s.robotNum),
|
||||||
RobotCnt: int32(s.robotNum),
|
CreateTime: s.createTime.Unix(),
|
||||||
CreateTime: s.createTime.Unix(),
|
BaseScore: s.dbGameFree.BaseScore,
|
||||||
BaseScore: s.dbGameFree.BaseScore,
|
GameFreeId: s.dbGameFree.GetId(),
|
||||||
RoomConfigId: s.GetRoomConfigId(),
|
MaxRound: s.totalRound,
|
||||||
CurrRound: s.currRound,
|
Password: s.GetPassword(),
|
||||||
MaxRound: s.totalRound,
|
CostType: s.GetCostType(),
|
||||||
Password: s.GetPassword(),
|
Voice: s.GetVoice(),
|
||||||
CostType: s.GetCostType(),
|
CurrRound: s.currRound,
|
||||||
Voice: s.GetVoice(),
|
|
||||||
}
|
}
|
||||||
if s.starting {
|
if s.starting {
|
||||||
si.Start = 1
|
si.Start = 1
|
||||||
|
@ -413,7 +412,6 @@ func (m *SceneMgr) CreateScene(args *CreateSceneParam) *Scene {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
m.scenes[args.RoomId] = s
|
m.scenes[args.RoomId] = s
|
||||||
s.sp.OnStart(s)
|
|
||||||
// 添加到游戏服记录中
|
// 添加到游戏服记录中
|
||||||
args.GS.AddScene(&AddSceneParam{
|
args.GS.AddScene(&AddSceneParam{
|
||||||
S: s,
|
S: s,
|
||||||
|
|
|
@ -44,15 +44,14 @@ const (
|
||||||
|
|
||||||
// page类型
|
// page类型
|
||||||
const (
|
const (
|
||||||
ShopPageCoin = 1 //金币页面
|
ShopPageCoin = 1 //金币页面
|
||||||
ShopPageDiamond = 2 //钻石页面
|
ShopPageDiamond = 2 //钻石页面
|
||||||
ShopPageItem = 3 //道具页面
|
ShopPageItem = 3 //道具页面
|
||||||
ShopPageVip = 4 //VIP页面
|
ShopPageVip = 4 //VIP页面
|
||||||
ShopPagePrivilege = 5 //VIP特权礼包
|
ShopPagePrivilege = 5 //VIP特权礼包
|
||||||
ShopPageGift = 7 //礼包页面
|
ShopPageGift = 7 //礼包页面
|
||||||
ShopPageDiamondBank = 8 //钻石存储罐
|
ShopPageDiamondBank = 8 //钻石存储罐
|
||||||
ShopPagePermit = 9 //赛季通行证
|
ShopPagePermit = 9 //赛季通行证
|
||||||
ShopPageFangKa = 10 //房卡页面
|
|
||||||
|
|
||||||
ShopPagePhoneScore = 61 //手机积分商城
|
ShopPagePhoneScore = 61 //手机积分商城
|
||||||
ShopPagePhoneScoreGoogle = 62
|
ShopPagePhoneScoreGoogle = 62
|
||||||
|
@ -63,15 +62,9 @@ const (
|
||||||
const (
|
const (
|
||||||
ShopTypeCoin = iota + 1 // 金币
|
ShopTypeCoin = iota + 1 // 金币
|
||||||
ShopTypeDiamond // 钻石
|
ShopTypeDiamond // 钻石
|
||||||
SHopTypeItem // 道具
|
ShopTypeItem // 道具
|
||||||
)
|
ShopTypeFangKa // 房卡
|
||||||
|
ShopTypeMax
|
||||||
// 商品参数类型
|
|
||||||
const (
|
|
||||||
ShopParamCoin = iota // 金币
|
|
||||||
ShopParamDiamond // 钻石
|
|
||||||
ShopParamUnKnown // 未定义
|
|
||||||
ShopParamMax // 参数数量
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 兑换商品状态
|
// 兑换商品状态
|
||||||
|
@ -145,7 +138,7 @@ func (this *ShopMgr) GetShopInfoProto(si *model.ShopInfo, p *Player, vipShopId i
|
||||||
}
|
}
|
||||||
added := int32(rand.Intn(int(si.AddArea[1])-int(si.AddArea[0])+1) + int(si.AddArea[0]))
|
added := int32(rand.Intn(int(si.AddArea[1])-int(si.AddArea[0])+1) + int(si.AddArea[0]))
|
||||||
consumptionAmount := int32(rand.Intn(int(si.CostArea[1])-int(si.CostArea[0])+1) + int(si.CostArea[0]))
|
consumptionAmount := int32(rand.Intn(int(si.CostArea[1])-int(si.CostArea[0])+1) + int(si.CostArea[0]))
|
||||||
amount := si.Amount
|
amount := int64(si.Amount)
|
||||||
isBuy := false
|
isBuy := false
|
||||||
if si.Page == ShopPageVip {
|
if si.Page == ShopPageVip {
|
||||||
shopData := p.GetVipShopData(si.Id, vipShopId)
|
shopData := p.GetVipShopData(si.Id, vipShopId)
|
||||||
|
@ -653,7 +646,6 @@ func (this *ShopMgr) GetAmountFinal(p *Player, shopId, vipShopId int32) int64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
addTotal += addNormal
|
|
||||||
}
|
}
|
||||||
return addTotal
|
return addTotal
|
||||||
}
|
}
|
||||||
|
@ -711,7 +703,7 @@ func (this *ShopMgr) GainShop(shopInfo *model.ShopInfo, p *Player, vipShopId, po
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
amount := [ShopParamMax]int32{} // 获得含义:金币,钻石,经验
|
amount := [3]int32{} // 获得含义:金币,钻石,经验
|
||||||
if shopInfo.Page == ShopPageVip {
|
if shopInfo.Page == ShopPageVip {
|
||||||
if p.VipShopData[vipShopId] == nil {
|
if p.VipShopData[vipShopId] == nil {
|
||||||
logger.Logger.Errorf("GainShop 没有找到vip商品 shopId:%v vipShopId:%v snid:%v", shopInfo.Id, vipShopId, p.SnId)
|
logger.Logger.Errorf("GainShop 没有找到vip商品 shopId:%v vipShopId:%v snid:%v", shopInfo.Id, vipShopId, p.SnId)
|
||||||
|
@ -726,7 +718,7 @@ func (this *ShopMgr) GainShop(shopInfo *model.ShopInfo, p *Player, vipShopId, po
|
||||||
|
|
||||||
switch shopInfo.Type {
|
switch shopInfo.Type {
|
||||||
case ShopTypeCoin:
|
case ShopTypeCoin:
|
||||||
amount[ShopParamCoin] = int32(addTotal)
|
amount[0] = int32(addTotal)
|
||||||
p.AddCoin(addTotal, 0, common.GainWay_Shop_Buy, "system", shopName)
|
p.AddCoin(addTotal, 0, common.GainWay_Shop_Buy, "system", shopName)
|
||||||
if shopInfo.Ad > 0 { //观看广告
|
if shopInfo.Ad > 0 { //观看广告
|
||||||
if !p.IsRob {
|
if !p.IsRob {
|
||||||
|
@ -743,7 +735,7 @@ func (this *ShopMgr) GainShop(shopInfo *model.ShopInfo, p *Player, vipShopId, po
|
||||||
|
|
||||||
case ShopTypeDiamond:
|
case ShopTypeDiamond:
|
||||||
//增加钻石
|
//增加钻石
|
||||||
amount[ShopParamDiamond] = int32(addTotal)
|
amount[1] = int32(addTotal)
|
||||||
p.AddDiamond(addTotal, 0, common.GainWay_Shop_Buy, "system", shopName)
|
p.AddDiamond(addTotal, 0, common.GainWay_Shop_Buy, "system", shopName)
|
||||||
if shopInfo.Ad > 0 { //观看广告
|
if shopInfo.Ad > 0 { //观看广告
|
||||||
if !p.IsRob {
|
if !p.IsRob {
|
||||||
|
@ -910,7 +902,7 @@ func (this *ShopMgr) Exchange(p *Player, goodsId int32, username, mobile, commen
|
||||||
if err := proto.Unmarshal(buff, as); err != nil {
|
if err := proto.Unmarshal(buff, as); err != nil {
|
||||||
logger.Logger.Errorf("API_CreateExchange err: %v %v", err, as.Tag)
|
logger.Logger.Errorf("API_CreateExchange err: %v %v", err, as.Tag)
|
||||||
}
|
}
|
||||||
var amount [ShopParamMax]int32
|
var amount [ShopTypeItem]int32
|
||||||
//保存db
|
//保存db
|
||||||
dbShop := this.NewDbShop(p, 0, amount[:], ExchangeConsumeCash, info.Cash*num,
|
dbShop := this.NewDbShop(p, 0, amount[:], ExchangeConsumeCash, info.Cash*num,
|
||||||
common.GainWay_ShopBuy, itemInfo, cdata.Id, cdata.Name, 0, "", []int32{})
|
common.GainWay_ShopBuy, itemInfo, cdata.Id, cdata.Name, 0, "", []int32{})
|
||||||
|
@ -1202,10 +1194,40 @@ func (this *ShopMgr) NewDbShop(p *Player, pageId int32, amount []int32, consume,
|
||||||
func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, remark string) {
|
func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, remark string) {
|
||||||
//三方购买
|
//三方购买
|
||||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||||
var amount [ShopParamMax]int32
|
var amount [ShopTypeItem]int32
|
||||||
var dbShop *model.DbShop
|
var dbShop *model.DbShop
|
||||||
if shopInfo, ok := data.(*model.ShopInfo); ok {
|
if shopInfo, ok := data.(*model.ShopInfo); ok {
|
||||||
|
// 目前现金只能买钻石
|
||||||
|
var addTotal = int64(shopInfo.Amount)
|
||||||
|
added := rand.Int31n(shopInfo.AddArea[1]-shopInfo.AddArea[0]+1) + shopInfo.AddArea[0]
|
||||||
costNum := rand.Int31n(shopInfo.CostArea[1]-shopInfo.CostArea[0]+1) + shopInfo.CostArea[0]
|
costNum := rand.Int31n(shopInfo.CostArea[1]-shopInfo.CostArea[0]+1) + shopInfo.CostArea[0]
|
||||||
|
/* if shopInfo.Page == ShopPageVip {
|
||||||
|
//暂时这样修改 VIP礼包没有现金支付
|
||||||
|
shopData := p.GetVipShopData(shopInfo.Id, 0)
|
||||||
|
if shopData != nil {
|
||||||
|
added = shopData.AddArea
|
||||||
|
costNum = shopData.CostArea
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
vipAdded := int32(0)
|
||||||
|
if shopInfo.Page == ShopPageDiamond {
|
||||||
|
//vip加成
|
||||||
|
vipAdded = VipMgrSington.GetVipDiamondExtra(p.Platform, p.VIP)
|
||||||
|
logger.Logger.Tracef("商城钻石购买,vip加成 vipAdded = %v", vipAdded)
|
||||||
|
}
|
||||||
|
|
||||||
|
if added > 0 || vipAdded > 0 {
|
||||||
|
addTotal = shopInfo.Amount + int64((float64(shopInfo.Amount)*float64(added+vipAdded))/100.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 首充翻倍
|
||||||
|
if shopInfo.FirstSwitch {
|
||||||
|
if !slices.Contains(p.ShopID, int(shopInfo.Id)) {
|
||||||
|
addTotal *= 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
amount[ShopTypeDiamond-1] = int32(addTotal)
|
||||||
var itemInfo []model.ItemInfo
|
var itemInfo []model.ItemInfo
|
||||||
var webItemInfo []*webapi_proto.ItemInfo
|
var webItemInfo []*webapi_proto.ItemInfo
|
||||||
for _, info := range shopInfo.GetItems() {
|
for _, info := range shopInfo.GetItems() {
|
||||||
|
@ -1219,13 +1241,6 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
switch shopInfo.Type {
|
|
||||||
case ShopTypeDiamond:
|
|
||||||
amount[ShopParamDiamond] = int32(shopInfo.AmountFinal)
|
|
||||||
default:
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
dbShop = this.NewDbShop(p, shopInfo.Page, amount[:], ShopConsumeMoney, costNum,
|
dbShop = this.NewDbShop(p, shopInfo.Page, amount[:], ShopConsumeMoney, costNum,
|
||||||
common.GainWay_ShopBuy, itemInfo, shopInfo.Id, shopInfo.Name, 0, remark, []int32{})
|
common.GainWay_ShopBuy, itemInfo, shopInfo.Id, shopInfo.Name, 0, remark, []int32{})
|
||||||
err := model.InsertDbShopLog(dbShop)
|
err := model.InsertDbShopLog(dbShop)
|
||||||
|
@ -1234,7 +1249,7 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, shopInfo.Id, p.Platform, p.PackageID, p.DeviceOS,
|
return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, shopInfo.Id, p.Platform, p.PackageID, p.DeviceOS,
|
||||||
p.DeviceId, shopInfo.Name, amount, costNum, webItemInfo, "", p.Channel, p.ChannelId)
|
p.DeviceId, shopInfo.Name, [ShopTypeItem]int32{0, int32(addTotal), 0}, costNum, webItemInfo, "", p.Channel, p.ChannelId)
|
||||||
|
|
||||||
} else if cdata, ok := data.(*ExchangeShopInfo); ok {
|
} else if cdata, ok := data.(*ExchangeShopInfo); ok {
|
||||||
var info *shop.ExchangeType
|
var info *shop.ExchangeType
|
||||||
|
@ -1259,54 +1274,35 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any,
|
||||||
//兑换 充值订单
|
//兑换 充值订单
|
||||||
logger.Logger.Infof("客户端请求兑换 创建支付订单!AppId = %v,SnId = %v,Id = %v,dbShop.LogId.Hex() = %v,cash = %v", common.GetAppId(), p.SnId, cdata.Id, dbShop.LogId.Hex(), info.Cash*cdata.ExchangeNum)
|
logger.Logger.Infof("客户端请求兑换 创建支付订单!AppId = %v,SnId = %v,Id = %v,dbShop.LogId.Hex() = %v,cash = %v", common.GetAppId(), p.SnId, cdata.Id, dbShop.LogId.Hex(), info.Cash*cdata.ExchangeNum)
|
||||||
return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, cdata.Id, p.Platform, p.PackageID, p.DeviceOS,
|
return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, cdata.Id, p.Platform, p.PackageID, p.DeviceOS,
|
||||||
p.DeviceId, cdata.Name, amount, info.Cash*cdata.ExchangeNum, nil, orderId, p.Channel, p.ChannelId)
|
p.DeviceId, cdata.Name, [ShopTypeItem]int32{0, 0, 0}, info.Cash*cdata.ExchangeNum, nil, orderId, p.Channel, p.ChannelId)
|
||||||
} else if bbd, ok := data.(*webapi_proto.BlindBoxData); ok {
|
} else if bbd, ok := data.(*webapi_proto.BlindBoxData); ok {
|
||||||
if bbd.Type == ShopTypeCoin {
|
if bbd.Type == 1 {
|
||||||
//金币
|
//金币
|
||||||
amount[ShopParamCoin] = bbd.Grade
|
amount[0] = bbd.Grade
|
||||||
} else if bbd.Type == ShopTypeDiamond {
|
} else if bbd.Type == 2 {
|
||||||
//钻石
|
//钻石
|
||||||
amount[ShopParamDiamond] = bbd.Grade
|
amount[1] = bbd.Grade
|
||||||
}
|
}
|
||||||
|
dbShop = this.NewDbShop(p, 0, amount[:], ShopConsumeMoney, int32(bbd.Price2), common.GainWay_ActBlindBox, nil, 0, "", 0, remark, []int32{bbd.Id})
|
||||||
var itemInfo []model.ItemInfo
|
|
||||||
var webItemInfo []*webapi_proto.ItemInfo
|
|
||||||
for _, info := range shopInfo.GetItems() {
|
|
||||||
itemInfo = append(itemInfo, model.ItemInfo{
|
|
||||||
ItemId: info.ItemId,
|
|
||||||
ItemNum: info.ItemNum,
|
|
||||||
})
|
|
||||||
webItemInfo = append(webItemInfo, &webapi_proto.ItemInfo{
|
|
||||||
ItemId: info.ItemId,
|
|
||||||
ItemNum: info.ItemNum,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
dbShop = this.NewDbShop(p, 0, amount[:], ShopConsumeMoney, int32(bbd.Price2), common.GainWay_ActBlindBox, itemInfo, 0, "", 0, remark, []int32{bbd.Id})
|
|
||||||
err := model.InsertDbShopLog(dbShop)
|
err := model.InsertDbShopLog(dbShop)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Logger.Errorf("model.InsertDbShopLog err:", err)
|
logger.Logger.Errorf("model.InsertDbShopLog err:", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS,
|
return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS,
|
||||||
p.DeviceId, bbd.Name, amount, int32(bbd.Price2), webItemInfo, "", p.Channel, p.ChannelId)
|
p.DeviceId, bbd.Name, amount, int32(bbd.Price2), nil, "", p.Channel, p.ChannelId)
|
||||||
} else if wfs, ok := data.(*webapi_proto.WelfareSpree); ok {
|
} else if wfs, ok := data.(*webapi_proto.WelfareSpree); ok {
|
||||||
var items []model.ItemInfo
|
var items []model.ItemInfo
|
||||||
var webItemInfo []*webapi_proto.ItemInfo
|
|
||||||
for _, it := range wfs.Item {
|
for _, it := range wfs.Item {
|
||||||
if it.Type == ShopTypeCoin {
|
if it.Type == 1 {
|
||||||
amount[ShopParamCoin] = it.Grade
|
amount[0] = it.Grade
|
||||||
} else if it.Type == ShopTypeDiamond {
|
} else if it.Type == 2 {
|
||||||
amount[ShopParamDiamond] = it.Grade
|
amount[1] = it.Grade
|
||||||
} else if it.Type == SHopTypeItem {
|
} else if it.Type == 3 {
|
||||||
items = append(items, model.ItemInfo{
|
items = append(items, model.ItemInfo{
|
||||||
ItemId: it.Item_Id,
|
ItemId: it.Item_Id,
|
||||||
ItemNum: int64(it.Grade),
|
ItemNum: int64(it.Grade),
|
||||||
})
|
})
|
||||||
webItemInfo = append(webItemInfo, &webapi_proto.ItemInfo{
|
|
||||||
ItemId: it.GetItem_Id(),
|
|
||||||
ItemNum: int64(it.GetGrade()),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var gainWay int32 = common.GainWay_ActFirstPay
|
var gainWay int32 = common.GainWay_ActFirstPay
|
||||||
|
@ -1320,7 +1316,7 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS,
|
return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS,
|
||||||
p.DeviceId, "FirstRecharge", amount, int32(wfs.Price2), webItemInfo, "", p.Channel, p.ChannelId)
|
p.DeviceId, "FirstRecharge", amount, int32(wfs.Price2), nil, "", p.Channel, p.ChannelId)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}), task.CompleteNotifyWrapper(func(retdata interface{}, t task.Task) {
|
}), task.CompleteNotifyWrapper(func(retdata interface{}, t task.Task) {
|
||||||
|
|
|
@ -3761,21 +3761,15 @@ func init() {
|
||||||
p := PlayerMgrSington.GetPlayerBySnId(msg.GetSnid())
|
p := PlayerMgrSington.GetPlayerBySnId(msg.GetSnid())
|
||||||
if p != nil {
|
if p != nil {
|
||||||
//获取道具Id
|
//获取道具Id
|
||||||
_, _, ok := BagMgrSingleton.AddItemsV2(&model.AddItemParam{
|
BagMgrSingleton.AddItemsV2(&model.AddItemParam{
|
||||||
P: p.PlayerData,
|
P: p.PlayerData,
|
||||||
Change: items,
|
Change: items,
|
||||||
GainWay: msg.GetTypeId(),
|
GainWay: msg.GetTypeId(),
|
||||||
Operator: "system",
|
Operator: "system",
|
||||||
Remark: msg.GetRemark(),
|
Remark: msg.GetRemark(),
|
||||||
})
|
})
|
||||||
if !ok {
|
|
||||||
logger.Logger.Errorf("player delete %v err: %v", msg, err)
|
|
||||||
pack.Tag = webapiproto.TagCode_FAILED
|
|
||||||
pack.Msg = "修改道具失败"
|
|
||||||
return common.ResponseTag_Ok, pack
|
|
||||||
}
|
|
||||||
pack.Tag = webapiproto.TagCode_SUCCESS
|
pack.Tag = webapiproto.TagCode_SUCCESS
|
||||||
pack.Msg = "修改道具成功"
|
pack.Msg = "AddItem success"
|
||||||
return common.ResponseTag_Ok, pack
|
return common.ResponseTag_Ok, pack
|
||||||
} else {
|
} else {
|
||||||
BagMgrSingleton.AddItemsOffline(msg.Platform, msg.Snid, items, msg.GetTypeId(),
|
BagMgrSingleton.AddItemsOffline(msg.Platform, msg.Snid, items, msg.GetTypeId(),
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue