Compare commits

...

5 Commits

Author SHA1 Message Date
sk 151a739dab 创建房间参数初始化 2024-09-02 16:26:05 +08:00
sk 00dcc3199f 竞技馆房主付费 2024-09-02 16:13:23 +08:00
sk 26db8f4b21 竞技馆 2024-09-02 14:55:18 +08:00
sk 04a0772415 竞技馆 2024-09-02 14:35:10 +08:00
sk 9f490a7aca 竞技馆 2024-09-02 11:44:12 +08:00
13 changed files with 127 additions and 42 deletions

View File

@ -29,6 +29,7 @@ const (
TIenLenTianhuTimeout = time.Second * 2 // 天胡动画时长 TIenLenTianhuTimeout = time.Second * 2 // 天胡动画时长
TienLenHandNotExceedTimeLimit = time.Second * 3 //玩家没有牌可以接上家的牌,出牌时间上限 TienLenHandNotExceedTimeLimit = time.Second * 3 //玩家没有牌可以接上家的牌,出牌时间上限
TienLenHandAutoStateTimeOut = time.Second * 1 //玩家托管出牌时间上限 TienLenHandAutoStateTimeOut = time.Second * 1 //玩家托管出牌时间上限
TienLenCustomWaiteStatTimeout = time.Millisecond * 1500
) )
// 场景状态 // 场景状态

View File

@ -3,6 +3,8 @@ package base
import ( import (
"reflect" "reflect"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/model" "mongo.games.com/game/model"
"mongo.games.com/game/mq" "mongo.games.com/game/mq"
) )
@ -38,6 +40,7 @@ func (c *LogChannel) WriteLog(log interface{}) {
if cname == "" { if cname == "" {
cname = "_null_" cname = "_null_"
} }
logger.Logger.Tracef("LogChannel ==> %#v", log)
mq.Send(cname, log) mq.Send(cname, log)
} }

View File

@ -2114,6 +2114,7 @@ func (this *TienLenSceneData) SaveCustomLog() {
state = 1 state = 1
} }
log := &model.CustomLog{ log := &model.CustomLog{
Platform: this.Platform,
CycleId: this.CycleID, CycleId: this.CycleID,
RoomConfigId: this.GetCustom().GetRoomConfigId(), RoomConfigId: this.GetCustom().GetRoomConfigId(),
RoomId: this.SceneId, RoomId: this.SceneId,

View File

@ -825,7 +825,7 @@ func (this *SceneWaitStartStateTienLen) OnEnter(s *base.Scene) {
if sceneEx, ok := s.GetExtraData().(*TienLenSceneData); ok { if sceneEx, ok := s.GetExtraData().(*TienLenSceneData); ok {
sceneEx.Clear() sceneEx.Clear()
sceneEx.SetGaming(false) sceneEx.SetGaming(false)
this.BroadcastRoomState(s, this.GetState()) this.BroadcastRoomState(s, this.GetState(), int64(sceneEx.NumOfGames))
logger.Logger.Trace("(this *SceneWaitStartStateTienLen) OnEnter", this.GetState()) logger.Logger.Trace("(this *SceneWaitStartStateTienLen) OnEnter", this.GetState())
} }
} }
@ -914,6 +914,7 @@ func (this *SceneWaitStartStateTienLen) OnTick(s *base.Scene) {
} }
} }
if sceneEx.IsCustom() { if sceneEx.IsCustom() {
if time.Now().Sub(sceneEx.StateStartTime) > rule.TienLenCustomWaiteStatTimeout {
if sceneEx.CanStart() { if sceneEx.CanStart() {
s.ChangeSceneState(rule.TienLenSceneStateHandCard) s.ChangeSceneState(rule.TienLenSceneStateHandCard)
} else { } else {
@ -921,6 +922,7 @@ func (this *SceneWaitStartStateTienLen) OnTick(s *base.Scene) {
} }
} }
} }
}
} }
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -2608,7 +2610,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
if p != nil { if p != nil {
var items []*model.Item var items []*model.Item
for _, v := range packBilled.List[0].Award { for _, v := range packBilled.List[0].Award {
itemData := srvdata.GameItemMgr.Get(p.Platform, p.SnId) itemData := srvdata.GameItemMgr.Get(p.Platform, v.GetId())
if itemData != nil { if itemData != nil {
items = append(items, &model.Item{ items = append(items, &model.Item{
ItemId: v.GetId(), ItemId: v.GetId(),

View File

@ -1,9 +1,5 @@
package model package model
import (
"github.com/globalsign/mgo/bson"
)
var ( var (
DbCustomLogDBName = "log" DbCustomLogDBName = "log"
DbCustomLogCollName = "log_custom" DbCustomLogCollName = "log_custom"
@ -22,7 +18,6 @@ type RoundInfo struct {
} }
type CustomLog struct { type CustomLog struct {
Id bson.ObjectId `bson:"_id"`
Platform string `bson:"-"` Platform string `bson:"-"`
CycleId string // 本轮id多局游戏属于同一轮 CycleId string // 本轮id多局游戏属于同一轮
RoomConfigId int32 // 房间配置id RoomConfigId int32 // 房间配置id

View File

@ -99,6 +99,7 @@ func NewGamePlayerListLogEx(snid int32, gamedetailedlogid string, platform, chan
cl.Time = tNow cl.Time = tNow
cl.MatchId = matchid cl.MatchId = matchid
cl.MatchType = matchType cl.MatchType = matchType
cl.CycleId = cycleId
return cl return cl
} }

View File

@ -1319,6 +1319,10 @@ func CSCreatePrivateRoomHandler(s *netlib.Session, packetId int, data interface{
return nil return nil
} }
if cfg.GetCostType() == 1 {
sp.CostPayment(scene, p)
}
pack = &gamehall.SCCreatePrivateRoom{ pack = &gamehall.SCCreatePrivateRoom{
OpRetCode: gamehall.OpResultCode_Game_OPRC_Sucess_Game, OpRetCode: gamehall.OpResultCode_Game_OPRC_Sucess_Game,
GameFreeId: msg.GetGameFreeId(), GameFreeId: msg.GetGameFreeId(),
@ -1348,6 +1352,8 @@ func CSGetPrivateRoomListHandler(s *netlib.Session, packetId int, data interface
return nil return nil
} }
PlayerNotifySingle.AddTime(p.SnId, common.NotifyPrivateRoomList, time.Second*15)
pack := &gamehall.SCGetPrivateRoomList{} pack := &gamehall.SCGetPrivateRoomList{}
scenes := SceneMgrSingleton.FindRoomList(&FindRoomParam{ scenes := SceneMgrSingleton.FindRoomList(&FindRoomParam{
Platform: p.Platform, Platform: p.Platform,

View File

@ -450,7 +450,7 @@ func (this *BagMgr) AddItem(p *Player, itemId, itemNum int64, add int64, gainWay
return this.AddItems(p, []*Item{{ItemId: int32(itemId), ItemNum: itemNum}}, add, gainWay, operator, remark, gameId, gameFreeId, noLog, params...) return this.AddItems(p, []*Item{{ItemId: int32(itemId), ItemNum: itemNum}}, add, gainWay, operator, remark, gameId, gameFreeId, noLog, params...)
} }
func (this *BagMgr) AddItemsOffline(platform string, snid int32, addItems []*Item, gainWay int32, operator, remark string, func (this *BagMgr) AddItemsOffline(platform string, snid int32, addItems []*model.Item, gainWay int32, operator, remark string,
gameId, gameFreeId int64, noLog bool, callback func(err error)) { gameId, gameFreeId int64, noLog bool, callback func(err error)) {
var findPlayer *model.PlayerBaseInfo var findPlayer *model.PlayerBaseInfo
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {

View File

@ -3,6 +3,8 @@ package main
import ( import (
"time" "time"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/common" "mongo.games.com/game/common"
) )
@ -76,4 +78,5 @@ func (p *PlayerNotify) GetPlayers(tp common.NotifyType) []int32 {
func (p *PlayerNotify) SendToClient(tp common.NotifyType, packetId int, pack interface{}) { func (p *PlayerNotify) SendToClient(tp common.NotifyType, packetId int, pack interface{}) {
ids := p.GetPlayers(tp) ids := p.GetPlayers(tp)
PlayerMgrSington.BroadcastMessageToTarget(ids, packetId, pack) PlayerMgrSington.BroadcastMessageToTarget(ids, packetId, pack)
logger.Logger.Tracef("PlayerNotify SendToClient tp:%v ids:%v", tp, ids)
} }

View File

@ -135,6 +135,12 @@ func NewScene(args *CreateSceneParam) *Scene {
} }
} }
} }
if s.MatchParam == nil {
s.MatchParam = new(serverproto.MatchParam)
}
if s.CustomParam == nil {
s.CustomParam = new(serverproto.CustomParam)
}
s.sp.OnStart(s) s.sp.OnStart(s)
return s return s
} }
@ -422,6 +428,7 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
} }
this.gameSess.AddPlayer(p) this.gameSess.AddPlayer(p)
FirePlayerEnterScene(p, this) FirePlayerEnterScene(p, this)
this.sp.OnPlayerEnter(this, p)
return true return true
} }
@ -507,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 {

View File

@ -85,7 +85,7 @@ func (m *SceneMgr) GenOneMatchSceneId() int {
func (m *SceneMgr) GenPassword() string { func (m *SceneMgr) GenPassword() string {
for i := 0; i < 100; i++ { for i := 0; i < 100; i++ {
s := strconv.Itoa(common.RandInt(10000, 100000)) s := strconv.Itoa(common.RandInt(100000, 1000000))
if _, ok := m.password[s]; !ok { if _, ok := m.password[s]; !ok {
m.password[s] = struct{}{} m.password[s] = struct{}{}
return s return s
@ -155,7 +155,7 @@ func (m *SceneMgr) GetScenesByGameFreeId(gameFreeId int32) []*Scene {
func (m *SceneMgr) GetMatchRoom(sortId int64) []*Scene { func (m *SceneMgr) GetMatchRoom(sortId int64) []*Scene {
var scenes []*Scene var scenes []*Scene
for _, value := range m.scenes { for _, value := range m.scenes {
if value.MatchSortId == sortId { if value.GetMatchSortId() == sortId {
s := m.GetScene(value.sceneId) s := m.GetScene(value.sceneId)
if s != nil { if s != nil {
scenes = append(scenes, value) scenes = append(scenes, value)

View File

@ -2,6 +2,8 @@ package main
import ( import (
"math" "math"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/common" "mongo.games.com/game/common"
"mongo.games.com/game/model" "mongo.games.com/game/model"
hallproto "mongo.games.com/game/protocol/gamehall" hallproto "mongo.games.com/game/protocol/gamehall"
@ -29,6 +31,10 @@ func (spd *ScenePolicyData) OnStart(s *Scene) {
// 场景关闭事件 // 场景关闭事件
func (spd *ScenePolicyData) OnStop(s *Scene) { func (spd *ScenePolicyData) OnStop(s *Scene) {
s.NotifyPrivateRoom(common.ListDel) s.NotifyPrivateRoom(common.ListDel)
// 房主付费,房间没有玩就解散了,返还房主建房费用
if s.IsCustom() && s.GetCostType() == 1 && s.currRound == 0 {
spd.GiveCostPayment(s, s.creator)
}
} }
// 场景心跳事件 // 场景心跳事件
@ -60,10 +66,12 @@ func (spd *ScenePolicyData) OnSceneState(s *Scene, state int) {
case common.SceneStateStart: case common.SceneStateStart:
s.NotifyPrivateRoom(common.ListModify) s.NotifyPrivateRoom(common.ListModify)
if s.IsCustom() { if s.IsCustom() {
if s.GetCostType() == 2 {
for _, v := range s.players { for _, v := range s.players {
spd.CostPayment(s, v) spd.CostPayment(s, v)
} }
} }
}
case common.SceneStateEnd: case common.SceneStateEnd:
s.NotifyPrivateRoom(common.ListModify) s.NotifyPrivateRoom(common.ListModify)
@ -85,13 +93,13 @@ func (spd *ScenePolicyData) CanEnter(s *Scene, p *Player) int {
return 0 return 0
} }
func (spd *ScenePolicyData) costEnough(costType, playerNum int, roomConfig *webapi.RoomConfig, p *Player, f func(items []*model.Item)) bool { func (spd *ScenePolicyData) costEnough(costType, playerNum int, roomConfig *webapi.RoomConfig, snid int32, f func(items []*model.Item)) bool {
isEnough := true isEnough := true
var items []*model.Item var items []*model.Item
if costType == 1 { if costType == 1 {
// 房主 // 房主
for _, v := range roomConfig.GetCost() { for _, v := range roomConfig.GetCost() {
if item := BagMgrSingleton.GetItem(p.SnId, v.GetItemId()); item == nil || item.ItemNum < v.GetItemNum() { if item := BagMgrSingleton.GetItem(snid, v.GetItemId()); item == nil || item.ItemNum < v.GetItemNum() {
isEnough = false isEnough = false
break break
} else { } else {
@ -105,7 +113,7 @@ func (spd *ScenePolicyData) costEnough(costType, playerNum int, roomConfig *weba
// AA // AA
for _, v := range roomConfig.GetCost() { for _, v := range roomConfig.GetCost() {
n := int64(math.Ceil(float64(v.GetItemNum()) / float64(playerNum))) n := int64(math.Ceil(float64(v.GetItemNum()) / float64(playerNum)))
if item := BagMgrSingleton.GetItem(p.SnId, v.GetItemId()); item == nil || item.ItemNum < n { if item := BagMgrSingleton.GetItem(snid, v.GetItemId()); item == nil || item.ItemNum < n {
isEnough = false isEnough = false
break break
} else { } else {
@ -126,7 +134,7 @@ func (spd *ScenePolicyData) CostEnough(costType, playerNum int, roomConfig *weba
if roomConfig == nil { if roomConfig == nil {
return false return false
} }
return spd.costEnough(costType, playerNum, roomConfig, p, func(items []*model.Item) {}) return spd.costEnough(costType, playerNum, roomConfig, p.SnId, func(items []*model.Item) {})
} }
func (spd *ScenePolicyData) CostPayment(s *Scene, p *Player) bool { func (spd *ScenePolicyData) CostPayment(s *Scene, p *Player) bool {
@ -134,7 +142,10 @@ func (spd *ScenePolicyData) CostPayment(s *Scene, p *Player) bool {
if roomConfig == nil { if roomConfig == nil {
return false return false
} }
return spd.costEnough(int(roomConfig.GetCostType()), s.playerNum, roomConfig, p, func(items []*model.Item) { return spd.costEnough(int(roomConfig.GetCostType()), s.playerNum, roomConfig, p.SnId, func(items []*model.Item) {
for _, v := range items {
v.ItemNum = -v.ItemNum
}
BagMgrSingleton.AddItemsV2(&model.AddItemParam{ BagMgrSingleton.AddItemsV2(&model.AddItemParam{
P: p.PlayerData, P: p.PlayerData,
Change: items, Change: items,
@ -148,6 +159,47 @@ func (spd *ScenePolicyData) CostPayment(s *Scene, p *Player) bool {
}) })
} }
// GiveCostPayment 退房费
func (spd *ScenePolicyData) GiveCostPayment(s *Scene, snid int32) bool {
roomConfig := PlatformMgrSingleton.GetConfig(s.limitPlatform.IdStr).RoomConfig[s.GetRoomConfigId()]
if roomConfig == nil {
return false
}
if roomConfig.GetCostType() != 1 { // 只有房主付费才有返还
return false
}
var items []*model.Item
for _, v := range roomConfig.GetCost() {
items = append(items, &model.Item{
ItemId: v.GetItemId(),
ItemNum: v.GetItemNum(),
})
}
p := PlayerMgrSington.GetPlayerBySnId(snid)
if p != nil {
BagMgrSingleton.AddItemsV2(&model.AddItemParam{
P: p.PlayerData,
Change: items,
GainWay: common.GainWayRoomCost,
Operator: "system",
Remark: "竞技场房间费用返还",
GameId: int64(s.gameId),
GameFreeId: int64(s.dbGameFree.GetId()),
NoLog: false,
RoomConfigId: roomConfig.GetId(),
})
} else {
BagMgrSingleton.AddItemsOffline(s.limitPlatform.IdStr, snid, items, common.GainWayRoomCost, "system",
"竞技场费用返还", int64(s.gameId), int64(s.dbGameFree.GetId()), false, func(err error) {
logger.Logger.Errorf("竞技场房间费用返还失败, err: %v", err)
})
}
return false
}
func (spd *ScenePolicyData) GetBetState() int32 { func (spd *ScenePolicyData) GetBetState() int32 {
return spd.BetState return spd.BetState
} }

View File

@ -3375,19 +3375,25 @@ func init() {
} }
addvcoin := msg.NeedNum addvcoin := msg.NeedNum
jPrice := msg.JPrice jPrice := msg.JPrice
var items []*Item var items []*model.Item
//V卡 //V卡
if addvcoin > 0 { if addvcoin > 0 {
items = append(items, &Item{ItemId: common.ItemIDVCard, ItemNum: int64(addvcoin)}) items = append(items, &model.Item{ItemId: common.ItemIDVCard, ItemNum: int64(addvcoin)})
} }
//金券 //金券
if jPrice > 0 { if jPrice > 0 {
items = append(items, &Item{ItemId: common.ItemIDJCard, ItemNum: int64(jPrice)}) items = append(items, &model.Item{ItemId: common.ItemIDJCard, ItemNum: int64(jPrice)})
} }
remark := fmt.Sprintf("兑换撤单 %v-%v", msg.GoodsId, msg.Name) remark := fmt.Sprintf("兑换撤单 %v-%v", msg.GoodsId, msg.Name)
if player != nil { if player != nil {
// 在线 // 在线
if _, code, _ := BagMgrSingleton.AddItems(player, items, 0, common.GainWay_Exchange, "system", remark, 0, 0, false); code != bag.OpResultCode_OPRC_Sucess { // 领取失败 if _, code, _ := BagMgrSingleton.AddItemsV2(&model.AddItemParam{
P: player.PlayerData,
Change: items,
GainWay: common.GainWay_Exchange,
Operator: "system",
Remark: remark,
}); code != bag.OpResultCode_OPRC_Sucess { // 领取失败
logger.Logger.Errorf("UpExchangeStatus AddItems err", code) logger.Logger.Errorf("UpExchangeStatus AddItems err", code)
pack.Msg = "AddItems err" pack.Msg = "AddItems err"
return common.ResponseTag_ParamError, pack return common.ResponseTag_ParamError, pack
@ -3744,9 +3750,9 @@ func init() {
pack.Msg = "参数错误" pack.Msg = "参数错误"
return common.ResponseTag_ParamError, pack return common.ResponseTag_ParamError, pack
} }
var items []*Item var items []*model.Item
for _, info := range msg.ItemInfo { for _, info := range msg.ItemInfo {
items = append(items, &Item{ items = append(items, &model.Item{
ItemId: info.ItemId, // 物品id ItemId: info.ItemId, // 物品id
ItemNum: info.ItemNum, // 数量 ItemNum: info.ItemNum, // 数量
ObtainTime: time.Now().Unix(), ObtainTime: time.Now().Unix(),
@ -3755,7 +3761,13 @@ func init() {
p := PlayerMgrSington.GetPlayerBySnId(msg.GetSnid()) p := PlayerMgrSington.GetPlayerBySnId(msg.GetSnid())
if p != nil { if p != nil {
//获取道具Id //获取道具Id
BagMgrSingleton.AddItems(p, items, 0, msg.GetTypeId(), "system", msg.GetRemark(), 0, 0, false) BagMgrSingleton.AddItemsV2(&model.AddItemParam{
P: p.PlayerData,
Change: items,
GainWay: msg.GetTypeId(),
Operator: "system",
Remark: msg.GetRemark(),
})
pack.Tag = webapiproto.TagCode_SUCCESS pack.Tag = webapiproto.TagCode_SUCCESS
pack.Msg = "AddItem success" pack.Msg = "AddItem success"
return common.ResponseTag_Ok, pack return common.ResponseTag_Ok, pack