娃娃机道具消耗与获得

This commit is contained in:
kxdd 2024-09-13 18:18:01 +08:00
parent a5265e5410
commit e7e08755a4
7 changed files with 1413 additions and 1347 deletions

View File

@ -314,7 +314,8 @@ const (
GainWayRoomCost = 106 //房费消耗
GainWayRoomGain = 107 //房卡场获得
GainWayItemShop = 108 // 交易市场道具交易
GainWayClawdoorCostItem = 109 // 娃娃机上分扣道具
GainWayClawdollCostItem = 109 // 娃娃机上分扣道具
GainWayClawdollCatch = 110 // 娃娃机抓取到娃娃获取卡
)
// 后台选择 金币变化类型 的充值 类型id号起始
@ -565,6 +566,7 @@ const (
ItemIDVCard = 30001 // v卡
ItemIDJCard = 30002 // 金券
ItemDiamondScore = 100012 //钻石积分
ItemIDClawdoll = 40003 // 娃娃卡
)
func ToItemId(id int32) int32 {

View File

@ -75,5 +75,7 @@ const (
)
const (
ClawDoorItemID = 40003
ClawDollItemID = 40003
ClawDollGiveItemID = 74004
ClawDollCostItemCount = 2
)

View File

@ -73,12 +73,19 @@ func MSDollMachineoCoinResultHandler(session *netlib.Session, packetId int, data
return nil
}
playerEx, ok := p.ExtraData.(*PlayerEx)
if !ok {
return nil
}
switch msg.TypeId {
case 1:
logger.Logger.Tracef("ClawDoll OnPlayerOp payCoin response, SnId= %v", p.SnId)
if msg.Result == 1 {
logger.Logger.Tracef("上分成功snid = %v", msg.Snid)
playerEx.CostPlayCoin(2)
sceneEx.playingSnid = p.SnId
//发送向前移动指令
@ -99,6 +106,9 @@ func MSDollMachineoCoinResultHandler(session *netlib.Session, packetId int, data
case 2:
if msg.Result == 1 {
// 获得娃娃卡
playerEx.CatchCardClawdoll(1)
logger.Logger.Tracef("下抓成功snid = %v", msg.Snid)
} else {
logger.Logger.Tracef("下抓失败snid = %v", msg.Snid)

View File

@ -42,10 +42,10 @@ func (this *PlayerEx) CanOp(sceneEx *SceneEx) bool {
// 能否投币
func (this *PlayerEx) CanPayCoin() bool {
itemID := int32(rule.ClawDoorItemID)
itemID := int32(rule.ClawDollItemID)
itemCount := this.GetItemCount(itemID)
if itemCount < 1 {
return true
if itemCount < rule.ClawDollCostItemCount {
return false
}
itemData := srvdata.GameItemMgr.Get(this.Platform, itemID)
@ -70,11 +70,11 @@ func (this *PlayerEx) CostPlayCoin(count int32) bool {
var items []*model.Item
itemData := srvdata.GameItemMgr.Get(this.Platform, rule.ClawDoorItemID)
itemData := srvdata.GameItemMgr.Get(this.Platform, rule.ClawDollItemID)
if itemData != nil {
items = append(items, &model.Item{
ItemId: rule.ClawDoorItemID,
ItemNum: -1,
ItemId: rule.ClawDollItemID,
ItemNum: int64(count),
})
}
@ -92,7 +92,7 @@ func (this *PlayerEx) CostPlayCoin(count int32) bool {
this.AddItems(&model.AddItemParam{
P: this.PlayerData,
Change: items,
GainWay: common.GainWayClawdoorCostItem,
GainWay: common.GainWayClawdollCostItem,
Operator: "system",
Remark: "娃娃机上分扣除道具",
GameId: int64(sceneEx.GameId),
@ -102,6 +102,42 @@ func (this *PlayerEx) CostPlayCoin(count int32) bool {
return true
}
// 抓取到娃娃获得娃娃
func (this *PlayerEx) CatchCardClawdoll(count int32) bool {
var items []*model.Item
itemData := srvdata.GameItemMgr.Get(this.Platform, rule.ClawDollGiveItemID)
if itemData != nil {
items = append(items, &model.Item{
ItemId: rule.ClawDollGiveItemID,
ItemNum: int64(count),
})
}
s := this.GetScene()
if s == nil {
logger.Logger.Warn("CatchCardClawdoll p.scene == nil")
return false
}
sceneEx, ok := s.ExtraData.(*SceneEx)
if !ok {
return false
}
this.AddItems(&model.AddItemParam{
P: this.PlayerData,
Change: items,
GainWay: common.GainWayClawdollCatch,
Operator: "system",
Remark: "娃娃机抓取到娃娃获得娃娃卡",
GameId: int64(sceneEx.GameId),
GameFreeId: int64(sceneEx.GetGameFreeId()),
})
return true
}
// 能否移动
func (this *PlayerEx) CanMove() bool {

File diff suppressed because it is too large Load Diff

View File

@ -344,6 +344,7 @@ message PlayerData {
int32 UseSkinId = 50; // id
string ChannelID = 51; // ID
int32 GuideStep = 52; // ; 0-1
int64 ClawdollCard = 53; //
}
//

View File

@ -3000,6 +3000,11 @@ func (this *Player) SendPlayerInfo() {
if item := BagMgrSingleton.GetItem(this.SnId, common.ItemIDVCard); item != nil {
scPlayerData.Data.VCoin = item.ItemNum //V卡
}
if item := BagMgrSingleton.GetItem(this.SnId, common.ItemIDClawdoll); item != nil {
scPlayerData.Data.ClawdollCard = item.ItemNum //娃娃卡
}
// 排位积分
scPlayerData.Data.RankScore = RankMgrSingleton.GetPlayerRankScore(this.SnId)