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