192 lines
3.5 KiB
Go
192 lines
3.5 KiB
Go
package clawdoll
|
|
|
|
import (
|
|
"mongo.games.com/game/common"
|
|
rule "mongo.games.com/game/gamerule/clawdoll"
|
|
"mongo.games.com/game/gamesrv/base"
|
|
"mongo.games.com/game/model"
|
|
"mongo.games.com/game/srvdata"
|
|
"mongo.games.com/goserver/core/logger"
|
|
)
|
|
|
|
type PlayerEx struct {
|
|
*base.Player //玩家信息
|
|
|
|
clawDollState int32 // 抓娃娃状态
|
|
dollCardsCnt int32 // 娃娃卡数量
|
|
|
|
winDollCardType int32 // 本局赢取娃娃的类型
|
|
gainCoin int64 // 本局赢的金币
|
|
taxCoin int64 // 本局税收
|
|
odds int32
|
|
}
|
|
|
|
func (this *PlayerEx) Clear(baseScore int32) {
|
|
this.UnmarkFlag(base.PlayerState_WaitNext)
|
|
this.UnmarkFlag(base.PlayerState_GameBreak)
|
|
this.MarkFlag(base.PlayerState_Ready)
|
|
|
|
this.gainCoin = 0
|
|
this.taxCoin = 0
|
|
this.odds = 0
|
|
}
|
|
|
|
func (this *PlayerEx) CanOp(sceneEx *SceneEx) bool {
|
|
if !this.IsGameing() {
|
|
logger.Logger.Trace("(this *PlayerEx) CanOp return false ", this.SnId)
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
// 能否投币
|
|
func (this *PlayerEx) CanPayCoin() bool {
|
|
|
|
itemID := int32(rule.ClawDoorItemID)
|
|
itemCount := this.GetItemCount(itemID)
|
|
if itemCount < 1 {
|
|
return true
|
|
}
|
|
|
|
itemData := srvdata.GameItemMgr.Get(this.Platform, itemID)
|
|
if itemData == nil {
|
|
return false
|
|
}
|
|
|
|
num, ok := this.Items[itemID]
|
|
if !ok || num < 1 {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// 投币消耗
|
|
func (this *PlayerEx) CostPlayCoin(count int32) bool {
|
|
|
|
if !this.CanPayCoin() {
|
|
return false
|
|
}
|
|
|
|
var items []*model.Item
|
|
|
|
itemData := srvdata.GameItemMgr.Get(this.Platform, rule.ClawDoorItemID)
|
|
if itemData != nil {
|
|
items = append(items, &model.Item{
|
|
ItemId: rule.ClawDoorItemID,
|
|
ItemNum: -1,
|
|
})
|
|
}
|
|
|
|
s := this.GetScene()
|
|
if s == nil {
|
|
logger.Logger.Warn("CostPlayCoin 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.GainWayClawdoorCostItem,
|
|
Operator: "system",
|
|
Remark: "娃娃机上分扣除道具",
|
|
GameId: int64(sceneEx.GameId),
|
|
GameFreeId: int64(sceneEx.GetGameFreeId()),
|
|
})
|
|
|
|
return true
|
|
}
|
|
|
|
// 能否移动
|
|
func (this *PlayerEx) CanMove() bool {
|
|
|
|
s := this.GetScene()
|
|
if sceneEx, ok := s.ExtraData.(*SceneEx); ok {
|
|
if !sceneEx.Gaming {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// 能否下抓
|
|
func (this *PlayerEx) CanGrab() bool {
|
|
|
|
s := this.GetScene()
|
|
if sceneEx, ok := s.ExtraData.(*SceneEx); ok {
|
|
if !sceneEx.Gaming {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// 游戏新一局 设置数据
|
|
func (this *PlayerEx) ReStartGame() {
|
|
this.ReDataStartGame()
|
|
|
|
this.UnmarkFlag(base.PlayerState_WaitNext)
|
|
this.UnmarkFlag(base.PlayerState_GameBreak)
|
|
this.MarkFlag(base.PlayerState_Ready)
|
|
|
|
this.gainCoin = 0
|
|
this.taxCoin = 0
|
|
this.odds = 0
|
|
}
|
|
|
|
// 初始化
|
|
func (this *PlayerEx) InitData(baseScore int32) {
|
|
|
|
}
|
|
|
|
// 重置数据
|
|
func (this *PlayerEx) ResetData() {
|
|
|
|
}
|
|
|
|
// 游戏新一局 设置数据
|
|
func (this *PlayerEx) ReDataStartGame() {
|
|
|
|
}
|
|
|
|
func (this *PlayerEx) CanPlayerOpInState(sceneState int) bool {
|
|
|
|
return false
|
|
}
|
|
|
|
// 能否退出游戏
|
|
func (this *PlayerEx) CanLeaveScene(sceneState int) bool {
|
|
|
|
return true
|
|
}
|
|
|
|
// 获取状态
|
|
func (this *PlayerEx) GetClawState() int32 {
|
|
return this.clawDollState
|
|
}
|
|
|
|
// 设置状态
|
|
func (this *PlayerEx) SetClawState(state int32) {
|
|
this.clawDollState = state
|
|
}
|
|
|
|
func (this *PlayerEx) GetItemCount(itemID int32) int64 {
|
|
itemData := srvdata.GameItemMgr.Get(this.Platform, itemID)
|
|
if itemData != nil {
|
|
v, ok := this.Items[itemID]
|
|
if ok {
|
|
return v
|
|
} else {
|
|
return 0
|
|
}
|
|
}
|
|
return 0
|
|
}
|