1
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
昔念
2026-04-15 00:07:36 +08:00
parent de755f8fd0
commit 6f51a2e349
11 changed files with 242 additions and 125 deletions

View File

@@ -72,7 +72,7 @@ func startMapBossFight(
ai *player.AI_player,
fn func(model.FightOverInfo),
) (*fight.FightC, errorcode.ErrorCode) {
ourPets := p.GetPetInfo(100)
ourPets := p.GetPetInfo(p.CurrentMapPetLevelLimit())
oppPets := ai.GetPetInfo(0)
if mapNode != nil && mapNode.IsGroupBoss != 0 {
if len(ourPets) > 0 && len(oppPets) > 0 {
@@ -98,8 +98,8 @@ func (Controller) OnPlayerFightNpcMonster(req *FightNpcMonsterInboundInfo, p *pl
if err = p.CanFight(); err != 0 {
return nil, err
}
if req.Number > 9 {
return nil, errorcode.ErrorCodes.ErrSystemError
if int(req.Number) >= len(p.Data) {
return nil, errorcode.ErrorCodes.ErrPokemonNotHere
}
refPet := p.Data[req.Number]
@@ -114,7 +114,7 @@ func (Controller) OnPlayerFightNpcMonster(req *FightNpcMonsterInboundInfo, p *pl
p.Fightinfo.Status = fightinfo.BattleMode.FIGHT_WITH_NPC
p.Fightinfo.Mode = fightinfo.BattleMode.MULTI_MODE
_, err = fight.NewFight(p, ai, p.GetPetInfo(100), ai.GetPetInfo(0), func(foi model.FightOverInfo) {
_, err = fight.NewFight(p, ai, p.GetPetInfo(p.CurrentMapPetLevelLimit()), ai.GetPetInfo(0), func(foi model.FightOverInfo) {
handleNpcFightRewards(p, foi, monster)
})
if err != 0 {
@@ -236,7 +236,7 @@ func shouldGrantBossWinBonus(fightC *fight.FightC, playerID uint32, bossConfig c
func buildNpcMonsterInfo(refPet player.OgrePetInfo, mapID uint32) (*model.PetInfo, *model.PlayerInfo, errorcode.ErrorCode) {
if refPet.ID == 0 {
return nil, nil, errorcode.ErrorCodes.ErrPokemonNotExists
return nil, nil, errorcode.ErrorCodes.ErrPokemonNotHere
}
monster := model.GenPetInfo(

View File

@@ -17,11 +17,16 @@ const (
// c: 当前玩家对象
// 返回: 分配结果和错误码
func (h Controller) PetEVDiy(data *PetEV, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
_, currentPet, found := c.FindPet(data.CacthTime)
slot, found := c.FindPetBagSlot(data.CacthTime)
if !found {
return nil, errorcode.ErrorCodes.Err10401
}
currentPet := slot.PetInfoPtr()
if currentPet == nil {
return nil, errorcode.ErrorCodes.Err10401
}
var targetTotal uint32
var currentTotal uint32
for i, evValue := range data.EVs {

View File

@@ -0,0 +1,45 @@
package controller
import (
"testing"
"blazing/logic/service/player"
playermodel "blazing/modules/player/model"
)
func TestPetEVDiy_AppliesToBackupPet(t *testing.T) {
p := player.NewPlayer(nil)
p.Info = &playermodel.PlayerInfo{
EVPool: 20,
PetList: []playermodel.PetInfo{
{CatchTime: 1},
},
BackupPetList: []playermodel.PetInfo{
{
CatchTime: 2,
Level: 100,
Ev: [6]uint32{0, 4, 0, 0, 0, 0},
},
},
}
data := &PetEV{
CacthTime: 2,
EVs: [6]uint32{0, 8, 4, 0, 0, 0},
}
_, err := (Controller{}).PetEVDiy(data, p)
if err != 0 {
t.Fatalf("PetEVDiy returned error: %v", err)
}
got := p.Info.BackupPetList[0].Ev
want := [6]uint32{0, 8, 4, 0, 0, 0}
if got != want {
t.Fatalf("backup pet EV mismatch, got %v want %v", got, want)
}
if gotPool, wantPool := p.Info.EVPool, int64(12); gotPool != wantPool {
t.Fatalf("EVPool mismatch, got %d want %d", gotPool, wantPool)
}
}

View File

@@ -4,18 +4,20 @@ import (
"blazing/common/socket/errorcode"
"blazing/logic/service/common"
"blazing/logic/service/pet"
"blazing/logic/service/player"
playersvc "blazing/logic/service/player"
"blazing/modules/player/model"
)
// GetPetInfo 获取精灵信息
func (h Controller) GetPetInfo(
data *GetPetInfoInboundInfo,
player *player.Player) (result *model.PetInfo,
player *playersvc.Player) (result *model.PetInfo,
err errorcode.ErrorCode) {
levelLimit := player.CurrentMapPetLevelLimit()
if slot, found := player.FindPetBagSlot(data.CatchTime); found {
if petInfo := slot.PetInfoPtr(); petInfo != nil {
result = petInfo
petCopy := playersvc.ApplyPetLevelLimit(*petInfo, levelLimit)
result = &petCopy
return result, 0
}
}
@@ -25,16 +27,18 @@ func (h Controller) GetPetInfo(
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
}
result = &ret.Data
petData := ret.Data
petData = playersvc.ApplyPetLevelLimit(petData, levelLimit)
result = &petData
return result, 0
}
// GetUserBagPetInfo 获取主背包和并列备用精灵列表
func (h Controller) GetUserBagPetInfo(
data *GetUserBagPetInfoInboundEmpty,
player *player.Player) (result *pet.GetUserBagPetInfoOutboundInfo,
player *playersvc.Player) (result *pet.GetUserBagPetInfoOutboundInfo,
err errorcode.ErrorCode) {
return player.GetUserBagPetInfo(), 0
return player.GetUserBagPetInfo(player.CurrentMapPetLevelLimit()), 0
}
// GetPetListInboundEmpty 定义请求或响应数据结构。
@@ -45,7 +49,7 @@ type GetPetListInboundEmpty struct {
// GetPetList 获取当前主背包列表
func (h Controller) GetPetList(
data *GetPetListInboundEmpty,
player *player.Player) (result *pet.GetPetListOutboundInfo,
player *playersvc.Player) (result *pet.GetPetListOutboundInfo,
err errorcode.ErrorCode) {
return buildPetListOutboundInfo(player.Info.PetList), 0
}
@@ -58,7 +62,7 @@ type GetPetListFreeInboundEmpty struct {
// GetPetReleaseList 获取仓库可放生列表
func (h Controller) GetPetReleaseList(
data *GetPetListFreeInboundEmpty,
player *player.Player) (result *pet.GetPetListOutboundInfo,
player *playersvc.Player) (result *pet.GetPetListOutboundInfo,
err errorcode.ErrorCode) {
return buildPetListOutboundInfo(player.WarehousePetList()), 0
@@ -67,7 +71,7 @@ func (h Controller) GetPetReleaseList(
// PlayerShowPet 精灵展示
func (h Controller) PlayerShowPet(
data *PetShowInboundInfo,
player *player.Player) (result *pet.PetShowOutboundInfo, err errorcode.ErrorCode) {
player *playersvc.Player) (result *pet.PetShowOutboundInfo, err errorcode.ErrorCode) {
result = &pet.PetShowOutboundInfo{
UserID: data.Head.UserID,
CatchTime: data.CatchTime,