ecs/servers/game/logic/player_lineup_hero.go

72 lines
2.1 KiB
Go
Raw Normal View History

package logic
import "ecs/proto/pb"
type PlayerLineupHero struct {
HeroUid uint64 `bson:"hero_uid"`
Position uint32 `bson:"position"`
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 *PlayerLineupHero) BuildMsgLineupHero(index uint32) *pb.LineupHero {
var msg = &pb.LineupHero{
Index: index,
HeroUid: this.HeroUid,
Position: this.Position,
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) UpdateBattleHeroCapacity(lineupHero *PlayerLineupHero) {
if lineupHero == nil {
return
}
var hero = this.Hero[lineupHero.HeroUid]
if hero == nil {
return
}
var attrs = hero.Attrs()
var capacity = (float64(attrs[pb.AttrType_Attack]) * 2) +
(float64(attrs[pb.AttrType_Hp]) * 0.2) +
(float64(attrs[pb.AttrType_AttrPhysicalDefense]) * 6) +
(float64(attrs[pb.AttrType_AttrMagicDefense]) * 6) +
(float64(attrs[pb.AttrType_AttrDamageRatio]) * 12) +
(float64(attrs[pb.AttrType_AttrDamageRelief]) * 12) +
(float64(attrs[pb.AttrType_AttrCriticalRatio]) * 12) +
(float64(attrs[pb.AttrType_AttrCriticalResistance]) * 12) +
(float64(attrs[pb.AttrType_AttrCriticalDamage]) * 12) +
(float64(attrs[pb.AttrType_AttrCriticalDamageRelief]) * 12) +
(float64(attrs[pb.AttrType_AttrHitRate]) * 12) +
(float64(attrs[pb.AttrType_AttrDodgeRate]) * 12) +
(float64(attrs[pb.AttrType_AttrTreatRatio]) * 12) +
(float64(attrs[pb.AttrType_AttrByTreatedRatio]) * 12) +
(float64(attrs[pb.AttrType_AttrFinalDamageRatio]) * 12)
lineupHero.Capacity = uint64(capacity)
}