还原本来的道具功能

--task=1000620 --user=李海亮 记牌器调整多道具修改逻辑 https://www.tapd.cn/31044302/s/1010514
This commit is contained in:
kxdd 2024-05-06 13:44:49 +08:00
parent 016ea68379
commit 7756f3ae19
19 changed files with 1679 additions and 1858 deletions

View File

@ -619,7 +619,6 @@ const (
ItemIDCoffee = 100008 // 咖啡 ItemIDCoffee = 100008 // 咖啡
ItemIDBucket = 100009 // 水桶 ItemIDBucket = 100009 // 水桶
ItemIDSlippers = 100010 // 拖鞋 ItemIDSlippers = 100010 // 拖鞋
ItemIDTienlenRecord = 60001 // tienlen记牌器
) )
func ToItemId(id int32) int32 { func ToItemId(id int32) int32 {

View File

@ -147,11 +147,8 @@ func init() {
p.Coin = msg.GetTakeCoin() p.Coin = msg.GetTakeCoin()
p.Pos = int(msg.GetPos()) p.Pos = int(msg.GetPos())
p.MatchParams = msg.GetMatchParams() p.MatchParams = msg.GetMatchParams()
for id, item := range msg.Items { for id, num := range msg.Items {
p.Items[id] = &base.Item{ p.Items[id] = num
ItemNum: item.ItemNum,
ExpireTime: item.ExpireTime,
}
} }
for k, v := range msg.RankScore { for k, v := range msg.RankScore {
p.RankScore[k] = v p.RankScore[k] = v

View File

@ -117,7 +117,7 @@ type Player struct {
BlackLevel int32 //todo 使用WBLevel BlackLevel int32 //todo 使用WBLevel
SingleAdjust *model.PlayerSingleAdjust SingleAdjust *model.PlayerSingleAdjust
IsLocal bool //是否本地player IsLocal bool //是否本地player
Items map[int32]*Item //背包数据 Items map[int32]int64 //背包数据
MatchParams []int32 //比赛参数 排名、段位、假snid、假角色 MatchParams []int32 //比赛参数 排名、段位、假snid、假角色
MatchRobotGrades []MatchRobotGrade MatchRobotGrades []MatchRobotGrade
TestLog []string // 调试日志 TestLog []string // 调试日志
@ -129,12 +129,6 @@ type MatchRobotGrade struct {
Grade int32 Grade int32
} }
type Item struct {
ItemNum int64 // 物品数量
ObtainTime int64 // 获取的时间
ExpireTime int64 // 有效期截止时间
}
func NewPlayer(sid int64, data []byte, ws, gs *netlib.Session) *Player { func NewPlayer(sid int64, data []byte, ws, gs *netlib.Session) *Player {
p := &Player{ p := &Player{
sid: sid, sid: sid,
@ -147,7 +141,7 @@ func NewPlayer(sid int64, data []byte, ws, gs *netlib.Session) *Player {
cparams: make(map[string]string), //平台登陆数据 cparams: make(map[string]string), //平台登陆数据
Iparams: make(map[int]int64), //整形参数 Iparams: make(map[int]int64), //整形参数
sparams: make(map[int]string), //字符参数 sparams: make(map[int]string), //字符参数
Items: make(map[int32]*Item), Items: make(map[int32]int64),
RankScore: make(map[int32]int64), RankScore: make(map[int32]int64),
} }
@ -454,7 +448,7 @@ func (this *Player) AddCoin(num int64, gainWay int32, syncFlag int, oper, remark
return return
} }
this.Coin += num this.Coin += num
this.Items[common.ItemIDCoin].ItemNum = this.Coin this.Items[common.ItemIDCoin] = this.Coin
if this.scene != nil { if this.scene != nil {
if !this.IsRob && !this.scene.Testing { //机器人log排除掉 if !this.IsRob && !this.scene.Testing { //机器人log排除掉
log := model.NewCoinLogEx(&model.CoinLogParam{ log := model.NewCoinLogEx(&model.CoinLogParam{
@ -538,7 +532,7 @@ func (this *Player) AddCoinAsync(num int64, gainWay int32, notifyC, broadcast bo
return return
} }
this.Coin += num this.Coin += num
this.Items[common.ItemIDCoin].ItemNum = this.Coin this.Items[common.ItemIDCoin] = this.Coin
if this.scene != nil { if this.scene != nil {
if !this.IsRob && !this.scene.Testing && writeLog { //机器人log排除掉 if !this.IsRob && !this.scene.Testing && writeLog { //机器人log排除掉
log := model.NewCoinLogEx(&model.CoinLogParam{ log := model.NewCoinLogEx(&model.CoinLogParam{

View File

@ -637,12 +637,9 @@ func (this *Scene) PlayerLeave(p *Player, reason int, isBill bool) {
} }
} }
pack.Items = make(map[int32]*server.ItemParam) pack.Items = make(map[int32]int64)
for id, item := range p.Items { for id, num := range p.Items {
p.Items[id] = &Item{ pack.Items[id] = num
ItemNum: item.ItemNum,
ExpireTime: item.ExpireTime,
}
} }
pack.RankScore = make(map[int32]int64) pack.RankScore = make(map[int32]int64)
for k, v := range p.RankScore { for k, v := range p.RankScore {
@ -2136,7 +2133,7 @@ func (this *Scene) TryBillExGameDrop(p *Player) {
num = rand.Int31n(drop.MaxAmount-drop.MinAmount+1) + drop.MinAmount num = rand.Int31n(drop.MaxAmount-drop.MinAmount+1) + drop.MinAmount
} }
p.Items[drop.ItemId].ItemNum += int64(num) p.Items[drop.ItemId] += int64(num)
realDrop[drop.ItemId] = num realDrop[drop.ItemId] = num
} }
} else { } else {
@ -2184,7 +2181,7 @@ func (this *Scene) DropCollectBox(p *Player) {
pack.Items = make(map[int32]int32) pack.Items = make(map[int32]int32)
itemData := srvdata.PBDB_GameItemMgr.GetData(common.ItemIDCollectBox) itemData := srvdata.PBDB_GameItemMgr.GetData(common.ItemIDCollectBox)
if itemData != nil { if itemData != nil {
p.Items[itemData.Id].ItemNum = p.Items[itemData.Id].ItemNum + 1 p.Items[itemData.Id] = p.Items[itemData.Id] + 1
pack.Items = map[int32]int32{itemData.Id: 1} pack.Items = map[int32]int32{itemData.Id: 1}
remark := fmt.Sprintf("游戏掉落%v", itemData.Id) remark := fmt.Sprintf("游戏掉落%v", itemData.Id)
//logType 0获得 1消耗 //logType 0获得 1消耗

View File

@ -460,8 +460,8 @@ func CreatePlayerData(p *base.Player) *chesstitians.ChesstitiansPlayerData {
} }
if p.Items != nil { if p.Items != nil {
pd.Items = make(map[int32]int32) pd.Items = make(map[int32]int32)
for id, item := range p.Items { for id, num := range p.Items {
pd.Items[id] = int32(item.ItemNum) pd.Items[id] = int32(num)
} }
} }
if len(p.MatchParams) > 0 { if len(p.MatchParams) > 0 {

View File

@ -352,9 +352,9 @@ func (this *CSFishSkillUseReqHandler) Process(s *netlib.Session, packetid int, d
itemId := item[0] itemId := item[0]
itemNum := item[1] itemNum := item[1]
//获取背包道具数量 //获取背包道具数量
playerItem, ok := player.Items[item[0]] num, ok := player.Items[item[0]]
if !ok || playerItem.ItemNum < int64(item[1]) { if !ok || num < int64(item[1]) {
fishlogger.Errorf("道具数量不在 itemId = %v,itemNum = %v背包数量 = %v", item[0], item[1], playerItem.ItemNum) fishlogger.Errorf("道具数量不在 itemId = %v,itemNum = %v背包数量 = %v", item[0], item[1], num)
//判断其他消耗其他物品 //判断其他消耗其他物品
otherItem := skillTemp.OtherConsumer otherItem := skillTemp.OtherConsumer
otherItemId := otherItem[0] otherItemId := otherItem[0]
@ -378,18 +378,18 @@ func (this *CSFishSkillUseReqHandler) Process(s *netlib.Session, packetid int, d
} }
player.Diamond -= int64(otherItemNum) player.Diamond -= int64(otherItemNum)
} else { } else {
if player.Items[otherItemId].ItemNum < int64(otherItemNum) { if player.Items[otherItemId] < int64(otherItemNum) {
fishlogger.Tracef("转换物品是其他物品时,物品数量不足!") fishlogger.Tracef("转换物品是其他物品时,物品数量不足!")
pack.Result = 1 pack.Result = 1
pack.Status = fishing_proto.SCFishSkillUseResp_TOOL_LIMIT pack.Status = fishing_proto.SCFishSkillUseResp_TOOL_LIMIT
player.SendToClient(int(fishing_proto.FIPacketID_FISHING_SC_SKILLUSERESP), pack) player.SendToClient(int(fishing_proto.FIPacketID_FISHING_SC_SKILLUSERESP), pack)
return nil return nil
} }
player.Items[otherItemId].ItemNum = player.Items[otherItemId].ItemNum - int64(otherItemNum) player.Items[otherItemId] = player.Items[otherItemId] - int64(otherItemNum)
} }
fishlogger.Tracef("玩家使用技能当前道具不足 转化物品消耗 skillid = %vsnid = %v,otherItemId = %v,otherItemNum = %v", skillId, player.SnId, otherItemId, otherItemNum) fishlogger.Tracef("玩家使用技能当前道具不足 转化物品消耗 skillid = %vsnid = %v,otherItemId = %v,otherItemNum = %v", skillId, player.SnId, otherItemId, otherItemNum)
} else { } else {
player.Items[itemId].ItemNum = player.Items[itemId].ItemNum - int64(itemNum) player.Items[itemId] = player.Items[itemId] - int64(itemNum)
//记录道具消耗日志 //记录道具消耗日志
fishlogger.Tracef("玩家使用技能消耗道具snod = %v, skill = %v,itemId =%v,itemNum = %v", player.SnId, skillId, itemId, itemNum) fishlogger.Tracef("玩家使用技能消耗道具snod = %v, skill = %v,itemId =%v,itemNum = %v", player.SnId, skillId, itemId, itemNum)
} }

View File

@ -3,7 +3,6 @@ package tienlen
import ( import (
"math" "math"
"math/rand" "math/rand"
"mongo.games.com/game/common"
"mongo.games.com/game/protocol/player" "mongo.games.com/game/protocol/player"
"strconv" "strconv"
"time" "time"
@ -217,14 +216,6 @@ func (this *TienLenPlayerData) LeaveAutoState(s *base.Scene) {
// 能否用记牌器 // 能否用记牌器
func (this *TienLenPlayerData) CanUseRecordItem() bool { func (this *TienLenPlayerData) CanUseRecordItem() bool {
itemData := srvdata.PBDB_GameItemMgr.GetData(common.ItemIDTienlenRecord)
if itemData != nil {
if item, ok := this.Items[common.ItemIDTienlenRecord]; ok {
if item.ItemNum >= 1 && item.ExpireTime >= time.Now().Unix() {
return true
}
}
}
return false return false
} }

View File

@ -374,8 +374,8 @@ func TienLenCreatePlayerData(p *base.Player, rankScore int64) *tienlen.TienLenPl
} }
if p.Items != nil { if p.Items != nil {
pd.Items = make(map[int32]int32) pd.Items = make(map[int32]int32)
for id, item := range p.Items { for id, num := range p.Items {
pd.Items[id] = int32(item.ItemNum) pd.Items[id] = int32(num)
} }
} }
if len(p.MatchParams) > 0 { if len(p.MatchParams) > 0 {

View File

@ -19,7 +19,6 @@ type Item struct {
ItemId int32 // 物品ID ItemId int32 // 物品ID
ItemNum int64 // 物品数量 ItemNum int64 // 物品数量
ObtainTime int64 //获取的时间 ObtainTime int64 //获取的时间
ExpireTime int64 // 截止时间
} }
type GetBagInfoArgs struct { type GetBagInfoArgs struct {
Plt string Plt string

View File

@ -168,7 +168,6 @@ type ItemInfo struct {
// string Location = 14; // 跳转页面 // string Location = 14; // 跳转页面
// string Describe = 15; // 道具描述 // string Describe = 15; // 道具描述
ObtainTime int64 `protobuf:"varint,3,opt,name=ObtainTime,proto3" json:"ObtainTime,omitempty"` //获取的时间 ObtainTime int64 `protobuf:"varint,3,opt,name=ObtainTime,proto3" json:"ObtainTime,omitempty"` //获取的时间
ExpireTime int64 `protobuf:"varint,4,opt,name=ExpireTime,proto3" json:"ExpireTime,omitempty"` //有效期截止时间
} }
func (x *ItemInfo) Reset() { func (x *ItemInfo) Reset() {
@ -224,13 +223,6 @@ func (x *ItemInfo) GetObtainTime() int64 {
return 0 return 0
} }
func (x *ItemInfo) GetExpireTime() int64 {
if x != nil {
return x.ExpireTime
}
return 0
}
//PACKET_ALL_BAG_INFO //PACKET_ALL_BAG_INFO
type CSBagInfo struct { type CSBagInfo struct {
state protoimpl.MessageState state protoimpl.MessageState
@ -913,14 +905,12 @@ var File_bag_proto protoreflect.FileDescriptor
var file_bag_proto_rawDesc = []byte{ var file_bag_proto_rawDesc = []byte{
0x0a, 0x09, 0x62, 0x61, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x62, 0x61, 0x67, 0x0a, 0x09, 0x62, 0x61, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x62, 0x61, 0x67,
0x22, 0x7c, 0x0a, 0x08, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x22, 0x5c, 0x0a, 0x08, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06,
0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74,
0x65, 0x6d, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x49, 0x74, 0x65, 0x6d, 0x4e, 0x75, 0x6d, 0x18, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x49, 0x74, 0x65, 0x6d, 0x4e, 0x75, 0x6d, 0x18,
0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x49, 0x74, 0x65, 0x6d, 0x4e, 0x75, 0x6d, 0x12, 0x1e, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x49, 0x74, 0x65, 0x6d, 0x4e, 0x75, 0x6d, 0x12, 0x1e,
0x0a, 0x0a, 0x4f, 0x62, 0x74, 0x61, 0x69, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x0a, 0x0a, 0x4f, 0x62, 0x74, 0x61, 0x69, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01,
0x28, 0x03, 0x52, 0x0a, 0x4f, 0x62, 0x74, 0x61, 0x69, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1e, 0x28, 0x03, 0x52, 0x0a, 0x4f, 0x62, 0x74, 0x61, 0x69, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x3d,
0x0a, 0x0a, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01,
0x28, 0x03, 0x52, 0x0a, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x3d,
0x0a, 0x09, 0x43, 0x53, 0x42, 0x61, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x20, 0x0a, 0x0b, 0x4e, 0x0a, 0x09, 0x43, 0x53, 0x42, 0x61, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x20, 0x0a, 0x0b, 0x4e,
0x6f, 0x77, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x6f, 0x77, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x52, 0x0b, 0x4e, 0x6f, 0x77, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x52, 0x0b, 0x4e, 0x6f, 0x77, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a,

View File

@ -41,7 +41,6 @@ message ItemInfo{
// string Location = 14; // // string Location = 14; //
// string Describe = 15; // // string Describe = 15; //
int64 ObtainTime = 3; // int64 ObtainTime = 3; //
int64 ExpireTime = 4; //
} }
//PACKET_ALL_BAG_INFO //PACKET_ALL_BAG_INFO

File diff suppressed because it is too large Load Diff

View File

@ -202,12 +202,6 @@ message GWDestroyScene {
message WGGraceDestroyScene { message WGGraceDestroyScene {
repeated int32 Ids = 1; repeated int32 Ids = 1;
} }
message ItemParam {
int64 ItemNum = 1; //
int64 ExpireTime = 2; //
}
message RebateTask { message RebateTask {
bool RebateSwitch = 1; // bool RebateSwitch = 1; //
repeated string RebateGameCfg = 2; // gameid+gamemode repeated string RebateGameCfg = 2; // gameid+gamemode
@ -231,7 +225,7 @@ message WGPlayerEnter {
int32 SnId = 14; int32 SnId = 14;
bytes SingleAdjust = 15;// bytes SingleAdjust = 15;//
int32 Pos = 16; int32 Pos = 16;
map<int32, ItemParam> Items = 17; map<int32, int64> Items = 17;
repeated int32 MatchParams = 18;// repeated int32 MatchParams = 18;//
map<int32, int64> RankScore = 19;// map<int32, int64> RankScore = 19;//
} }
@ -270,7 +264,7 @@ message GWPlayerLeave{
int32 LostTimes = 12; // int32 LostTimes = 12; //
int64 TotalConvertibleFlow = 13; // int64 TotalConvertibleFlow = 13; //
int64 ValidCacheBetTotal = 14; // int64 ValidCacheBetTotal = 14; //
map<int32, ItemParam> Items = 15; map<int32, int64> Items = 15;
int32 MatchId = 16;//id int32 MatchId = 16;//id
int64 CurIsWin = 17;// 0 int64 CurIsWin = 17;// 0
map<int32, int32> MatchRobotGrades = 18;// map<int32, int32> MatchRobotGrades = 18;//

View File

@ -47,16 +47,11 @@ func (this *CSBagInfoHandler) Process(s *netlib.Session, packetid int, data inte
if bagInfo != nil { if bagInfo != nil {
for _, v := range bagInfo.BagItem { for _, v := range bagInfo.BagItem {
item := srvdata.PBDB_GameItemMgr.GetData(v.ItemId) item := srvdata.PBDB_GameItemMgr.GetData(v.ItemId)
if item.Type == common.ItemTypeExpireTime && v.ExpireTime < time.Now().Unix() {
continue
}
if item != nil && v.ItemNum > 0 && (tp <= 0 || item.GetType() == tp) /*&& (nowLocation == -1 || (nowLocation < len(item.ShowLocation) && item.ShowLocation[nowLocation] == 1))*/ { if item != nil && v.ItemNum > 0 && (tp <= 0 || item.GetType() == tp) /*&& (nowLocation == -1 || (nowLocation < len(item.ShowLocation) && item.ShowLocation[nowLocation] == 1))*/ {
pack.Infos = append(pack.Infos, &bag.ItemInfo{ pack.Infos = append(pack.Infos, &bag.ItemInfo{
ItemId: v.ItemId, ItemId: v.ItemId,
ItemNum: v.ItemNum, ItemNum: v.ItemNum,
ObtainTime: v.ObtainTime, ObtainTime: v.ObtainTime,
ExpireTime: v.ExpireTime,
}) })
} }
} }
@ -172,7 +167,6 @@ func (this *CSUpBagInfoHandler) Process(s *netlib.Session, packetid int, data in
ItemId: v.ItemId, ItemId: v.ItemId,
ItemNum: v.ItemNum, ItemNum: v.ItemNum,
ObtainTime: v.ObtainTime, ObtainTime: v.ObtainTime,
ExpireTime: v.ExpireTime,
}) })
} }
} }

View File

@ -155,11 +155,11 @@ func init() {
items := msg.GetItems() items := msg.GetItems()
if items != nil { if items != nil {
for _, dbItem := range dbItemArr { for _, dbItem := range dbItemArr {
if item, exist := items[dbItem.Id]; exist { if itemNum, exist := items[dbItem.Id]; exist {
oldItem := BagMgrSingleton.GetItem(p.SnId, dbItem.Id) oldItem := BagMgrSingleton.GetItem(p.SnId, dbItem.Id)
diffNum := int64(item.ItemNum) diffNum := int64(itemNum)
if oldItem != nil { if oldItem != nil {
diffNum = int64(item.ItemNum) - oldItem.ItemNum diffNum = int64(itemNum) - oldItem.ItemNum
} }
if diffNum != 0 { if diffNum != 0 {
item := &Item{ item := &Item{

View File

@ -50,7 +50,6 @@ type Item struct {
//Describe string // 道具描述 //Describe string // 道具描述
//数据库数据 //数据库数据
ObtainTime int64 //获取的时间 ObtainTime int64 //获取的时间
ExpireTime int64 //截止到期时间
} }
type BagInfo struct { type BagInfo struct {
@ -80,8 +79,6 @@ func (this *BagMgr) GetBagInfo(snid int32) *BagInfo {
if v, exist := this.PlayerBag[snid]; exist { if v, exist := this.PlayerBag[snid]; exist {
return v return v
} }
this.RefreshExpireItem(snid)
return nil return nil
} }
@ -92,8 +89,6 @@ func (this *BagMgr) GetItem(snid, itemId int32) *Item {
return nil return nil
} }
this.RefreshExpireItem(snid)
item := &Item{ item := &Item{
ItemId: itemId, ItemId: itemId,
} }
@ -215,27 +210,12 @@ func (this *BagMgr) AddJybBagInfo(p *Player, addItems []*Item, add int64, gainWa
changeItems = append(changeItems, v.ItemId) changeItems = append(changeItems, v.ItemId)
if itm, exist := newBagInfo.BagItem[v.ItemId]; exist { if itm, exist := newBagInfo.BagItem[v.ItemId]; exist {
if common.ItemTypeExpireTime == item.Type {
itm.ExpireTime += int64(item.Time*3600) * v.ItemNum
itm.ItemNum = 1
} else {
itm.ItemNum += v.ItemNum itm.ItemNum += v.ItemNum
}
} else {
if common.ItemTypeExpireTime == item.Type {
newBagInfo.BagItem[v.ItemId] = &Item{
ItemId: item.Id, // 物品id
ItemNum: 1, // 数量
ObtainTime: time.Now().Unix(),
ExpireTime: time.Now().Unix() + int64(item.Time*3600)*v.ItemNum,
}
} else { } else {
newBagInfo.BagItem[v.ItemId] = &Item{ newBagInfo.BagItem[v.ItemId] = &Item{
ItemId: item.Id, // 物品id ItemId: item.Id, // 物品id
ItemNum: v.ItemNum, // 数量 ItemNum: v.ItemNum, // 数量
ObtainTime: time.Now().Unix(), ObtainTime: time.Now().Unix(),
ExpireTime: 0,
}
} }
} }
if v.ItemId == common.ItemIDWeekScore && v.ItemNum != 0 { if v.ItemId == common.ItemIDWeekScore && v.ItemNum != 0 {
@ -266,10 +246,6 @@ func (this *BagMgr) SaleItem(p *Player, itemId int32, num int64) bool {
// SalePlayerItem 出售道具,减少玩家道具数量 // SalePlayerItem 出售道具,减少玩家道具数量
func (this *BagMgr) SalePlayerItem(p *Player, item *Item, num int64) bool { func (this *BagMgr) SalePlayerItem(p *Player, item *Item, num int64) bool {
if num < 0 {
return false
}
item.ItemNum -= num item.ItemNum -= num
p.dirty = true p.dirty = true
this.SyncBagData(p.SnId, item.ItemId) this.SyncBagData(p.SnId, item.ItemId)
@ -450,7 +426,6 @@ func (this *BagMgr) SyncBagData(snid int32, changeItemIds ...int32) {
//Location: itemInfo.Location, //Location: itemInfo.Location,
//Describe: itemInfo.Describe, //Describe: itemInfo.Describe,
ObtainTime: itemInfo.ObtainTime, ObtainTime: itemInfo.ObtainTime,
ExpireTime: itemInfo.ExpireTime,
}) })
if itemInfo.ItemId == VCard { if itemInfo.ItemId == VCard {
FriendMgrSington.UpdateInfo(p.Platform, p.SnId) FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
@ -460,22 +435,6 @@ func (this *BagMgr) SyncBagData(snid int32, changeItemIds ...int32) {
p.SyncBagData(itemInfos) p.SyncBagData(itemInfos)
} }
// 刷新时效类道具
func (this *BagMgr) RefreshExpireItem(snid int32) {
bagInfo := BagMgrSingleton.GetBagInfo(snid)
if bagInfo != nil {
for k, bi := range bagInfo.BagItem {
itemcfg := srvdata.PBDB_GameItemMgr.GetData(bi.ItemId)
if itemcfg != nil {
// 去掉时限到期的道具
if itemcfg.Type == common.ItemTypeExpireTime && bi.ExpireTime < time.Now().Unix() {
delete(bagInfo.BagItem, k)
}
}
}
}
}
func (this *BagMgr) Update() { func (this *BagMgr) Update() {
} }
@ -512,22 +471,13 @@ func (this *BagMgr) Callback(player any, ret *internal.PlayerLoadReplay) {
BagItem: make(map[int32]*Item), BagItem: make(map[int32]*Item),
} }
for k, bi := range bagInfo.BagItem { for k, bi := range bagInfo.BagItem {
itemcfg := srvdata.PBDB_GameItemMgr.GetData(bi.ItemId) item := srvdata.PBDB_GameItemMgr.GetData(bi.ItemId)
if itemcfg != nil { if item != nil {
if bi.ItemNum > 0 { if bi.ItemNum > 0 {
// 去掉时限到期的道具
if itemcfg.Type == common.ItemTypeExpireTime {
if bi.ExpireTime < time.Now().Unix() {
continue
}
}
newBagInfo.BagItem[k] = &Item{ newBagInfo.BagItem[k] = &Item{
ItemId: bi.ItemId, ItemId: bi.ItemId,
ItemNum: bi.ItemNum, ItemNum: bi.ItemNum,
ObtainTime: bi.ObtainTime, ObtainTime: bi.ObtainTime,
ExpireTime: bi.ExpireTime,
} }
} }
} else { } else {
@ -581,7 +531,7 @@ func (this *BagMgr) Save(platform string, snid int32, isSync, force bool) {
Platform: bagInfo.Platform, Platform: bagInfo.Platform,
} }
for _, v := range bagInfo.BagItem { for _, v := range bagInfo.BagItem {
biMap.BagItem = append(biMap.BagItem, &Item{ItemId: v.ItemId, ItemNum: v.ItemNum, ObtainTime: v.ObtainTime, ExpireTime: v.ExpireTime}) biMap.BagItem = append(biMap.BagItem, &Item{ItemId: v.ItemId, ItemNum: v.ItemNum, ObtainTime: v.ObtainTime})
} }
var err error var err error
@ -592,7 +542,7 @@ func (this *BagMgr) Save(platform string, snid int32, isSync, force bool) {
BagItem: make(map[int32]*model.Item), BagItem: make(map[int32]*model.Item),
} }
for _, v := range biMap.BagItem { for _, v := range biMap.BagItem {
newBagInfo.BagItem[v.ItemId] = &model.Item{ItemId: v.ItemId, ItemNum: v.ItemNum, ObtainTime: v.ObtainTime, ExpireTime: v.ExpireTime} newBagInfo.BagItem[v.ItemId] = &model.Item{ItemId: v.ItemId, ItemNum: v.ItemNum, ObtainTime: v.ObtainTime}
} }
err = model.UpBagItem(newBagInfo) err = model.UpBagItem(newBagInfo)
} }

View File

@ -1326,7 +1326,6 @@ func (this *Player) GetMessageAttachs(ids []string) {
ItemId: msg.Params[i], // 物品id ItemId: msg.Params[i], // 物品id
ItemNum: int64(msg.Params[i+1]), // 数量 ItemNum: int64(msg.Params[i+1]), // 数量
ObtainTime: time.Now().Unix(), ObtainTime: time.Now().Unix(),
ExpireTime: time.Now().Unix() + int64(msg.Params[i+1])*3600,
}) })
} }
if _, code := BagMgrSingleton.AddJybBagInfo(this, items, 0, gainWay, "mail", remark); code != bag.OpResultCode_OPRC_Sucess { // 领取失败 if _, code := BagMgrSingleton.AddJybBagInfo(this, items, 0, gainWay, "mail", remark); code != bag.OpResultCode_OPRC_Sucess { // 领取失败

View File

@ -522,17 +522,12 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
// 道具 // 道具
dbItemArr := srvdata.PBDB_GameItemMgr.Datas.Arr dbItemArr := srvdata.PBDB_GameItemMgr.Datas.Arr
if dbItemArr != nil { if dbItemArr != nil {
msg.Items = make(map[int32]*serverproto.ItemParam) msg.Items = make(map[int32]int64)
for _, dbItem := range dbItemArr { for _, dbItem := range dbItemArr {
msg.Items[dbItem.Id] = &serverproto.ItemParam{ msg.Items[dbItem.Id] = 0
ItemNum: 0,
ExpireTime: 0,
}
itemInfo := BagMgrSingleton.GetItem(p.SnId, dbItem.Id) itemInfo := BagMgrSingleton.GetItem(p.SnId, dbItem.Id)
if itemInfo != nil { if itemInfo != nil {
msg.Items[dbItem.Id].ItemNum = itemInfo.ItemNum msg.Items[dbItem.Id] = itemInfo.ItemNum
msg.Items[dbItem.Id].ExpireTime = itemInfo.ExpireTime
} }
} }
} }

View File

@ -591,7 +591,7 @@ func (this *ShopMgr) PayAway(shopInfo *model.ShopInfo, p *Player, vipShopId, pos
} }
case ShopTypeItem: case ShopTypeItem:
//增加道具 //增加道具
item := &Item{ItemId: shopInfo.ItemId, ItemNum: addTotal, ObtainTime: time.Now().Unix(), ExpireTime: 0} item := &Item{ItemId: shopInfo.ItemId, ItemNum: addTotal, ObtainTime: time.Now().Unix()}
BagMgrSingleton.AddJybBagInfo(p, []*Item{item}, 0, common.GainWay_Shop_Buy, "system", shopName) BagMgrSingleton.AddJybBagInfo(p, []*Item{item}, 0, common.GainWay_Shop_Buy, "system", shopName)
data := srvdata.PBDB_GameItemMgr.GetData(item.ItemId) data := srvdata.PBDB_GameItemMgr.GetData(item.ItemId)
if data != nil { if data != nil {