ecs/servers/game/logic/player_battle_hero.go

48 lines
1.3 KiB
Go
Raw Normal View History

package logic
import "ecs/proto/pb"
type PlayerBattleHero struct {
//Position uint32 `bson:"position"`
HeroUid uint64 `bson:"hero_uid"`
Equip [4]uint64 `bson:"equip"`
Treasure [2]uint64 `bson:"treasure"`
Artifact [1]uint64 `bson:"artifact"`
Mounts [1]uint64 `bson:"mounts"`
General [1]uint64 `bson:"general"`
Ornament [1]uint64 `bson:"ornament"`
Sack [10]uint64 `bson:"sack"`
FateChart [6]uint64 `bson:"fate_chart"`
Tetris [36]uint64 `bson:"tetris"`
Capacity uint64 `bson:"-"`
}
func (this *PlayerBattleHero) BuildMsgBattleHero(position int) *pb.BattleHero {
var msg = &pb.BattleHero{
Position: uint32(position),
HeroUid: this.HeroUid,
Capacity: this.Capacity,
}
if this.HeroUid != 0 {
msg.Equip = this.Equip[:]
msg.Treasure = this.Treasure[:]
msg.Artifact = this.Artifact[:]
msg.Mounts = this.Mounts[:]
msg.General = this.General[:]
msg.Ornament = this.Ornament[:]
msg.Sack = this.Sack[:]
msg.FateChart = this.FateChart[:]
msg.Tetris = this.Tetris[:]
}
return msg
}
func (this *Player) BuildMsgBattleHeroListAck() *pb.BattleHeroListAck {
var list []*pb.BattleHero
for i, battleHero := range this.BattleHeroes {
list = append(list, battleHero.BuildMsgBattleHero(i))
}
return &pb.BattleHeroListAck{HeroList: list}
}