金币道具优化

This commit is contained in:
sk 2024-09-19 11:37:25 +08:00
parent 47f98ad5f8
commit ba27fa4b3a
5 changed files with 116 additions and 135 deletions

View File

@ -87,7 +87,7 @@ func SaveToDelBackupBagItem(args *BagInfo) error {
} }
type AddItemParam struct { type AddItemParam struct {
P *PlayerData P *PlayerData // 玩家信息,玩家离线时不传
Change []*Item // 道具变化数量 Change []*Item // 道具变化数量
Cost []*Item // 获得道具时消耗的道具数量 Cost []*Item // 获得道具时消耗的道具数量
Add int64 // 加成数量 Add int64 // 加成数量

View File

@ -1722,6 +1722,7 @@ func (this *CSPlayerVIPInfoHandler) Process(s *netlib.Session, packetid int, dat
logger.Logger.Warn("CSPlayerVIPInfoHandler p == nil") logger.Logger.Warn("CSPlayerVIPInfoHandler p == nil")
return nil return nil
} }
p.GetVIPLevel()
p.SCVIPInfo() p.SCVIPInfo()
} }
return nil return nil

View File

@ -394,12 +394,12 @@ func (this *BagMgr) AddItems(param *model.AddItemParam) (*BagInfo, bag.OpResultC
} }
case common.ItemTypeFishPower: case common.ItemTypeFishPower:
//增加炮台 //增加炮台
p.ItemUnPlayerPowerListEx(v.ItemId) //p.ItemUnPlayerPowerListEx(v.ItemId)
case common.ItemTypeMoneyPond: case common.ItemTypeMoneyPond:
//增加个人金币池 //增加个人金币池
if v.ItemId == common.ItemIDMoneyPond { //if v.ItemId == common.ItemIDMoneyPond {
p.MoneyPond += v.ItemNum // p.MoneyPond += v.ItemNum
} //}
case common.ItemTypeVipExp: case common.ItemTypeVipExp:
//增加玩家VIP经验 //增加玩家VIP经验
if v.ItemId == common.ItemIDVipExp { if v.ItemId == common.ItemIDVipExp {

View File

@ -310,13 +310,7 @@ func (this *Player) OnLogined() {
this.SetOnline() this.SetOnline()
//测试用 //测试用
if !this.IsRob { if this.IsRob {
old := this.VIP
this.VIP = this.GetVIPLevel()
if old != this.VIP {
this.dirty = true
}
} else {
this.VIP = rand.Int31n(6) + 1 this.VIP = rand.Int31n(6) + 1
//机器人随机vip和头像 //机器人随机vip和头像
this.RobRandVip() this.RobRandVip()
@ -1720,14 +1714,6 @@ func (this *Player) AddDiamond(num, add int64, gainWay int32, oper, remark strin
return return
} }
logger.Logger.Tracef("snid(%v) AddDiamond(%v)", this.SnId, num) logger.Logger.Tracef("snid(%v) AddDiamond(%v)", this.SnId, num)
//async := false
//if num > 0 && this.scene != nil && !this.scene.IsTestScene() && this.scene.sceneMode != common.SceneMode_Thr { //游戏场中加币,需要同步到gamesrv上
// if StartAsyncAddCoinTransact(this, num, gainWay, oper, remark, true, 0, true) {
// async = true
// }
//}
if num != 0 /*&& !async*/ {
this.dirty = true this.dirty = true
if num > 0 { if num > 0 {
this.Diamond += num this.Diamond += num
@ -1770,7 +1756,6 @@ func (this *Player) AddDiamond(num, add int64, gainWay int32, oper, remark strin
LogChannelSingleton.WriteLog(log) LogChannelSingleton.WriteLog(log)
} }
} }
}
} }
// AddCoin 添加钻石 // AddCoin 添加钻石
@ -2265,23 +2250,14 @@ func (this *Player) BackDiffData() {
this.diffData.SafeBoxCoin = this.SafeBoxCoin this.diffData.SafeBoxCoin = this.SafeBoxCoin
} }
func (this *Player) UpdateVip() {
if this.IsRob {
return
}
this.VIP = this.GetVIPLevel()
//clubManager.UpdateVip(this)
}
func (this *Player) AddMoneyPayTotal(amount int64) { func (this *Player) AddMoneyPayTotal(amount int64) {
if amount > 0 { if amount > 0 {
this.MoneyPayTotal += amount this.MoneyPayTotal += amount
this.SendDiffData() //更新vip this.GetVIPLevel()
} }
} }
func (this *Player) SendDiffData() { func (this *Player) SendDiffData() {
this.UpdateVip()
var dirty bool var dirty bool
pack := &playerproto.SCPlayerDataUpdate{} pack := &playerproto.SCPlayerDataUpdate{}
pack.UpdateField = 0 pack.UpdateField = 0
@ -2767,7 +2743,6 @@ func (this *Player) GetPromoterKey() (string, error) {
//} //}
func (this *Player) SendPlayerInfo() { func (this *Player) SendPlayerInfo() {
this.UpdateVip()
scPlayerData := &playerproto.SCPlayerData{ scPlayerData := &playerproto.SCPlayerData{
OpRetCode: playerproto.OpResultCode_OPRC_Sucess, OpRetCode: playerproto.OpResultCode_OPRC_Sucess,
Data: &playerproto.PlayerData{ Data: &playerproto.PlayerData{
@ -2878,6 +2853,8 @@ func (this *Player) SendPlayerInfo() {
this.SendGameConfig(int32(this.scene.gameId), this.Platform, this.Channel) this.SendGameConfig(int32(this.scene.gameId), this.Platform, this.Channel)
} }
//this.SendJackpotInfo() //this.SendJackpotInfo()
// 更新vip
this.GetVIPLevel()
// 后台道具配置 // 后台道具配置
this.SCItems() this.SCItems()
// 引导配置 // 引导配置
@ -3606,8 +3583,6 @@ func (this *Player) SCVIPInfo() {
pack.TolVipExp, pack.Money = this.GetCurrentVIPExp(vips) pack.TolVipExp, pack.Money = this.GetCurrentVIPExp(vips)
pack.Vip = this.VIP pack.Vip = this.VIP
pack.OpRetCode = playerproto.OpResultCode_OPRC_Sucess pack.OpRetCode = playerproto.OpResultCode_OPRC_Sucess
//WelfareMgrSington.MonitorWelfData(this)
//pack.VipId = append(pack.VipId, this.WelfData.VIPGift...)
} }
this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_VIPINFO), pack) this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_VIPINFO), pack)
logger.Logger.Tracef("send vipinfo to client:%v", pack) logger.Logger.Tracef("send vipinfo to client:%v", pack)
@ -3732,6 +3707,8 @@ func (this *Player) VIPDraw(id, vip int32) {
send() send()
} }
// GetCurrentVIPExp 更新vip等级
// 返回当前经验和升级需要经验
func (this *Player) GetCurrentVIPExp(vipcfg ...*webapiproto.VIPcfgDataList) (exp int64, money int64) { func (this *Player) GetCurrentVIPExp(vipcfg ...*webapiproto.VIPcfgDataList) (exp int64, money int64) {
var vips *webapiproto.VIPcfgDataList var vips *webapiproto.VIPcfgDataList
if len(vipcfg) == 0 { if len(vipcfg) == 0 {
@ -3767,6 +3744,7 @@ func (this *Player) GetCurrentVIPExp(vipcfg ...*webapiproto.VIPcfgDataList) (exp
return // 默认 return // 默认
} }
// GetVIPLevel 更新vip等级返回vip等级
func (this *Player) GetVIPLevel() int32 { func (this *Player) GetVIPLevel() int32 {
if this.IsRob { if this.IsRob {
return 0 return 0
@ -3786,6 +3764,7 @@ func (this *Player) GetVIPLevel() int32 {
} }
var b bool var b bool
if vip != this.VIP { if vip != this.VIP {
this.dirty = true
b = true b = true
//玩家VIP升级 //玩家VIP升级
this.SCVIPInfo() this.SCVIPInfo()
@ -4344,7 +4323,7 @@ func (this *Player) addLotteryCount(count int32) {
} }
// 增加手机积分 // AddPhoneScore 增加手机积分
func (this *Player) AddPhoneScore(num, add int64, gainWay int32, oper, remark string) { func (this *Player) AddPhoneScore(num, add int64, gainWay int32, oper, remark string) {
if num == 0 { if num == 0 {
return return
@ -4353,7 +4332,7 @@ func (this *Player) AddPhoneScore(num, add int64, gainWay int32, oper, remark st
return return
} }
logger.Logger.Tracef("snid(%v) AddPhoneScore(%v)", this.SnId, num) logger.Logger.Tracef("snid(%v) AddPhoneScore(%v)", this.SnId, num)
if num != 0 /*&& !async*/ {
this.dirty = true this.dirty = true
if num > 0 { if num > 0 {
this.PhoneScore += num this.PhoneScore += num
@ -4366,9 +4345,7 @@ func (this *Player) AddPhoneScore(num, add int64, gainWay int32, oper, remark st
this.PhoneScore += num this.PhoneScore += num
} }
} }
this.SendDiffData() this.SendDiffData()
}
} }
// 抽奖任务 // 抽奖任务
@ -4644,15 +4621,12 @@ func (this *Player) GetWeekCardPrivilege(typeId int32) bool {
// 增加记牌器道具时限 // 增加记牌器道具时限
func (this *Player) AddItemRecExpireTime(itemId int32, num, add int64, gainWay int32, oper, remark string) { func (this *Player) AddItemRecExpireTime(itemId int32, num, add int64, gainWay int32, oper, remark string) {
if num == 0 { if num <= 0 {
return return
} }
logger.Logger.Tracef("snid(%v) AddItemRecExpireTime, itemId:(%v), num:(%v)", this.SnId, itemId, num) logger.Logger.Tracef("snid(%v) AddItemRecExpireTime, itemId:(%v), num:(%v)", this.SnId, itemId, num)
if num != 0 /*&& !async*/ {
this.dirty = true this.dirty = true
if num > 0 {
itemData := srvdata.GameItemMgr.Get(this.Platform, itemId) itemData := srvdata.GameItemMgr.Get(this.Platform, itemId)
if itemData == nil { if itemData == nil {
return return
@ -4674,14 +4648,8 @@ func (this *Player) AddItemRecExpireTime(itemId int32, num, add int64, gainWay i
ExpireTime: this.ItemRecExpireTime, ExpireTime: this.ItemRecExpireTime,
Diamond: this.Diamond, Diamond: this.Diamond,
} }
proto.SetDefaults(msg)
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_BUYRECTIMEITEM), msg) this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_BUYRECTIMEITEM), msg)
} }
}
this.SendDiffData()
}
} }
func (this *Player) GetIsPermit() bool { func (this *Player) GetIsPermit() bool {

View File

@ -921,18 +921,30 @@ func (this *ShopMgr) Exchange(p *Player, goodsId int32, username, mobile, commen
}) })
} }
if info.DPrice > 0 { if info.DPrice > 0 {
item := model.ItemInfo{ n := int64(info.DPrice * num)
ItemId: common.ItemDollCard, item := BagMgrSingleton.GetItem(p.SnId, common.ItemIDJCard)
ItemNum: int64(info.JPrice * num), if item != nil && item.ItemNum >= n {
} BagMgrSingleton.AddItems(&model.AddItemParam{
_, _, isF := BagMgrSingleton.AddItem(p, int64(item.ItemId), -item.ItemNum, 0, common.GainWayItemChangeDoll, P: p.PlayerData,
"sys", fmt.Sprintf("兑换娃娃扣除%v", item.ItemId), 0, 0, false) Change: []*model.Item{
if !isF { // 扣掉金券 {
ItemId: item.ItemId,
ItemNum: -n,
},
},
GainWay: common.GainWayItemChangeDoll,
Operator: "system",
Remark: fmt.Sprintf("兑换娃娃扣除%v", item.ItemId),
})
} else {
pack.RetCode = shop.OpResultCode_OPRC_DCoinNotEnough pack.RetCode = shop.OpResultCode_OPRC_DCoinNotEnough
p.SendToClient(int(shop.SPacketID_PACKET_SC_SHOP_EXCHANGE), pack) p.SendToClient(int(shop.SPacketID_PACKET_SC_SHOP_EXCHANGE), pack)
return false return false
} }
itemInfo = append(itemInfo, item) itemInfo = append(itemInfo, &model.Item{
ItemId: common.ItemDollCard,
ItemNum: n,
})
} }
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
pack := &webapi_proto.ASCreateExchangeOrder{ pack := &webapi_proto.ASCreateExchangeOrder{