竞技馆房主付费
This commit is contained in:
parent
26db8f4b21
commit
00dcc3199f
|
@ -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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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(),
|
||||||
|
|
|
@ -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{} {
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue