This commit is contained in:
aozhiwei 2024-10-12 15:16:42 +08:00
parent bc43c9e28f
commit 7c260b04cb
2 changed files with 20 additions and 20 deletions

View File

@ -10,6 +10,13 @@ import (
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
) )
type BattleItem struct {
ItemId int32 `json:"item_id"`
ItemNum int32 `json:"item_num"`
ItemType int32 `json:"item_type"`
ItemSubType int32 `json:"item_sub_type"`
}
type UserInfo struct { type UserInfo struct {
//Activated string `json:"activated"` //Activated string `json:"activated"`
//RenameCount string `json:"rename_count"` //RenameCount string `json:"rename_count"`

View File

@ -24,13 +24,6 @@ type hero struct {
skinId int32 skinId int32
} }
type battleItem struct {
itemId int32
itemNum int32
itemType int32
itemSubType int32
}
type player struct { type player struct {
cs.MsgHandlerImpl cs.MsgHandlerImpl
socket f5.WspCliConn socket f5.WspCliConn
@ -54,7 +47,7 @@ type player struct {
vipLv int32 vipLv int32
vipExp int64 vipExp int64
hasVipLucky int32 hasVipLucky int32
battleItems []*battleItem battleItems []*common.BattleItem
} }
func (this *player) SendMsg(rspMsg proto.Message) { func (this *player) SendMsg(rspMsg proto.Message) {
@ -249,8 +242,8 @@ func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) {
q5.NewSlice(&member_pb.BattleItems, 0, 0) q5.NewSlice(&member_pb.BattleItems, 0, 0)
for _, p := range(this.battleItems) { for _, p := range(this.battleItems) {
item_pb := new(cs.MFBattleItem) item_pb := new(cs.MFBattleItem)
item_pb.ItemId = proto.Int32(p.itemId) item_pb.ItemId = proto.Int32(p.ItemId)
item_pb.ItemNum = proto.Int32(p.itemNum) item_pb.ItemNum = proto.Int32(p.ItemNum)
q5.AppendSlice(&member_pb.BattleItems, item_pb) q5.AppendSlice(&member_pb.BattleItems, item_pb)
} }
} }
@ -608,21 +601,21 @@ func (this *player) CMChooseBattleItem(hdr *f5.MsgHdr, msg *cs.CMChooseBattleIte
if itemNum > 0 { if itemNum > 0 {
found := false found := false
for _, p := range(this.battleItems) { for _, p := range(this.battleItems) {
if p.itemType == itemType && p.itemSubType == itemSubType { if p.ItemType == itemType && p.ItemSubType == itemSubType {
p.itemId = itemId p.ItemId = itemId
p.itemNum = itemNum p.ItemNum = itemNum
p.itemType = itemType p.ItemType = itemType
p.itemSubType = itemSubType p.ItemSubType = itemSubType
found = true found = true
break break
} }
} }
if !found { if !found {
p := new(battleItem) p := new(common.BattleItem)
p.itemId = itemId p.ItemId = itemId
p.itemNum = itemNum p.ItemNum = itemNum
p.itemType = itemType p.ItemType = itemType
p.itemSubType = itemSubType p.ItemSubType = itemSubType
q5.AppendSlice(&this.battleItems, p) q5.AppendSlice(&this.battleItems, p)
} }
} }