Compare commits

...

2 Commits

Author SHA1 Message Date
xinian
87145579e6 refactor: 移除宠物显示提供者接口
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
2026-04-05 07:41:50 +08:00
xinian
7ec6381cf1 111 2026-04-05 07:30:55 +08:00
6 changed files with 34 additions and 17 deletions

View File

@@ -101,7 +101,11 @@ func Initfile() {
})
PetMAP = utils.ToMap[PetInfo, int](getXml[Monsters](path+"226.xml").Monsters, func(m PetInfo) int {
pets := getXml[Monsters](path + "226.xml").Monsters
for i := range pets {
pets[i].YieldingEVValues = parseYieldingEV(pets[i].YieldingEV)
}
PetMAP = utils.ToMap[PetInfo, int](pets, func(m PetInfo) int {
return m.ID
})

View File

@@ -1,6 +1,11 @@
package xmlres
import "github.com/ECUST-XX/xml"
import (
"strconv"
"strings"
"github.com/ECUST-XX/xml"
)
// Move 表示怪物可学习的技能
type PetMoves struct {
@@ -45,6 +50,7 @@ type PetInfo struct {
Recycle int `xml:"Recycle,attr"` // 是否可回收
LearnableMoves LearnableMoves `xml:"LearnableMoves"` // 可学习的技能
NaturalEnemy string `xml:"NaturalEnemy,attr"` //天敌
YieldingEVValues []int64 `xml:"-"` // 预解析后的努力值奖励
}
func (basic *PetInfo) GetBasic() uint32 {
@@ -61,3 +67,16 @@ type Monsters struct {
XMLName xml.Name `xml:"Monsters"`
Monsters []PetInfo `xml:"Monster"`
}
func parseYieldingEV(raw string) []int64 {
values := make([]int64, 6)
parts := strings.Fields(raw)
for i := 0; i < len(parts) && i < len(values); i++ {
value, err := strconv.ParseInt(parts[i], 10, 64)
if err != nil {
continue
}
values[i] = value
}
return values
}

View File

@@ -4,7 +4,6 @@ import (
"blazing/common/data"
"blazing/common/data/xmlres"
"blazing/common/socket/errorcode"
"strings"
"blazing/logic/service/fight"
fightinfo "blazing/logic/service/fight/info"
@@ -279,5 +278,5 @@ func handleNpcFightRewards(p *player.Player, foi model.FightOverInfo, monster *m
if rewards.HasReward() {
p.SendPackCmd(8004, rewards)
}
foi.Winpet.AddEV(gconv.Int64s(strings.Fields(petCfg.YieldingEV)))
foi.Winpet.AddEV(petCfg.YieldingEVValues)
}

View File

@@ -3,10 +3,12 @@ package common
import (
"blazing/common/socket/errorcode"
"blazing/logic/service/fight/info"
space "blazing/logic/service/space/info"
"blazing/modules/player/model"
)
type PlayerI interface {
ApplyPetDisplayInfo(*space.SimpleInfo)
GetPlayerCaptureContext() *info.PlayerCaptureContext
Roll(int, int) (bool, float64, float64)
//SendPack(b []byte) error

View File

@@ -5,6 +5,7 @@ import (
"blazing/common/utils"
"blazing/logic/service/common"
"blazing/logic/service/fight/info"
spaceinfo "blazing/logic/service/space/info"
"blazing/modules/player/model"
)
@@ -100,3 +101,4 @@ func (p *baseplayer) ItemAdd(ItemId, ItemCnt int64) (result bool) {
func (lw *baseplayer) SendLoadPercent(info.LoadPercentOutboundInfo) {
}
func (p *baseplayer) ApplyPetDisplayInfo(out *spaceinfo.SimpleInfo) {}

View File

@@ -10,10 +10,6 @@ import (
"github.com/jinzhu/copier"
)
type petDisplayInfoProvider interface {
ApplyPetDisplayInfo(*info.SimpleInfo)
}
// 向其他人广播,不含自己
// 广播是c 为空就不特判,发给全体成员广播
func (s *Space) Broadcast(c common.PlayerI, cmd uint32, data any) {
@@ -57,9 +53,7 @@ func (s *Space) EnterMap(c common.PlayerI) {
out := info.NewOutInfo()
copier.CopyWithOption(out, c.GetInfo(), copier.Option{DeepCopy: true})
if provider, ok := c.(petDisplayInfoProvider); ok {
provider.ApplyPetDisplayInfo(out)
}
c.ApplyPetDisplayInfo(out)
c.SendPackCmd(2001, out)
s.Broadcast(c, 2001, out)
@@ -68,7 +62,7 @@ func (s *Space) EnterMap(c common.PlayerI) {
curmaps, ok := maphot[s.Super]
if ok {
curmaps.ChangeCount(1)
//atomic.AddInt32(maphot[s.Super], 1)
}
}
@@ -78,11 +72,8 @@ func (s *Space) RefreshUserInfo(c common.PlayerI) {
if !ok {
return
}
if provider, ok := c.(petDisplayInfoProvider); ok {
provider.ApplyPetDisplayInfo(&current)
s.UserInfo.Store(c.GetInfo().UserID, current)
}
c.ApplyPetDisplayInfo(&current)
s.UserInfo.Store(c.GetInfo().UserID, current)
}
func (s *Space) GetInfo(c common.PlayerI) []info.SimpleInfo {