From 7b2a22dde5974220b72833bf7b04a7994189e450 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 17 Oct 2025 13:50:29 +0000 Subject: [PATCH 01/10] =?UTF-8?q?```fix(socket):=20=E4=BC=98=E5=8C=96TCP?= =?UTF-8?q?=E6=96=AD=E5=8C=85=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97=E5=92=8C?= =?UTF-8?q?=E5=94=A4=E9=86=92=E6=9C=BA=E5=88=B6```?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/socket/ServerEvent.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/socket/ServerEvent.go b/common/socket/ServerEvent.go index 6413b04e..f68e8bec 100644 --- a/common/socket/ServerEvent.go +++ b/common/socket/ServerEvent.go @@ -155,14 +155,17 @@ func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) { conn.Context().(*player.ClientData).IsCrossDomain = true data, err := s.codec.Decode(conn) if err != nil { - if err != codec.ErrIncompletePacket { - action = gnet.Close - return - } else { + + if err == codec.ErrIncompletePacket&&conn.InboundBuffered()>0 { + t, _ := conn.Peek(conn.InboundBuffered()) + cool.Loger.Debug(context.Background(), "断包", err.Error(), conn.InboundBuffered(), t) if err := conn.Wake(nil); err != nil { // wake up the connection manually to avoid missing the leftover data logging.Errorf("failed to wake up the connection, %v", err) return gnet.Close } + } else { + action = gnet.Close + return } } From 609058056031fc6515efe50814ef5d66e8a22e98 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 17 Oct 2025 19:23:38 +0000 Subject: [PATCH 02/10] =?UTF-8?q?```fix(pet):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AE=A0=E7=89=A9=E6=B7=BB=E5=8A=A0=E6=97=B6=E6=8D=95=E6=8D=89?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=86=B2=E7=AA=81=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=94=AF=E4=B8=80=E9=94=AE=E7=BA=A6=E6=9D=9F?= =?UTF-8?q?=E5=92=8C=E8=87=AA=E5=A2=9E=E9=87=8D=E8=AF=95=E9=80=BB=E8=BE=91?= =?UTF-8?q?```?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/blazing/model/pet.go | 4 ++-- modules/blazing/service/pet.go | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/modules/blazing/model/pet.go b/modules/blazing/model/pet.go index 4a127fb7..6a5b5217 100644 --- a/modules/blazing/model/pet.go +++ b/modules/blazing/model/pet.go @@ -11,8 +11,8 @@ const TableNamePet = "pet" type Pet struct { *cool.Model PlayerID uint32 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"` - InBag int `gorm:"not null;comment:'是否在背包中'" json:"in_bag"` //"0为放入仓库,1为放入背包 - CatchTime uint32 `gorm:"not null;comment:'捕捉时间'" json:"catch_time"` + InBag int `gorm:"not null;comment:'是否在背包中'" json:"in_bag"` //"0为放入仓库,1为放入背包 + CatchTime uint32 `gorm:"not null;unique;comment:'捕捉时间'" json:"catch_time"` //唯一键 // Owner uint32 `struc:"skip"` //仅作为存储 // FreedTime uint32 `struc:"skip"` //放生时间 //是否可交易,这里应该定义在精灵ID里 diff --git a/modules/blazing/service/pet.go b/modules/blazing/service/pet.go index 950a5562..150ad023 100644 --- a/modules/blazing/service/pet.go +++ b/modules/blazing/service/pet.go @@ -34,14 +34,21 @@ func (s *UserService) PetInfo_One(cachetime uint32) model.PetEX { } func (s *UserService) PetAdd(y model.PetInfo) { - m1 := cool.DBM(s.pet.Model).Where("player_id", s.userid) - var player model.PetEX - player.PlayerID = s.userid - player.Data = y - player.CatchTime = y.CatchTime - player.InBag = 0 + for { + m1 := cool.DBM(s.pet.Model).Where("player_id", s.userid) + var player model.PetEX + player.PlayerID = s.userid + player.Data = y + player.CatchTime = y.CatchTime + player.InBag = 0 - m1.Insert(player) + _, err := m1.Insert(player) + if err == nil { + break + + } + y.CatchTime += 1//自增保持时间排序 + } } From 7f18af25078cd20d3780538974c491831bf23a3a Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 17 Oct 2025 19:24:13 +0000 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/blazing/service/pet.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/blazing/service/pet.go b/modules/blazing/service/pet.go index 150ad023..b3086454 100644 --- a/modules/blazing/service/pet.go +++ b/modules/blazing/service/pet.go @@ -43,11 +43,11 @@ func (s *UserService) PetAdd(y model.PetInfo) { player.InBag = 0 _, err := m1.Insert(player) - if err == nil { - break - + if err != nil { + y.CatchTime += 1 //自增保持时间排序 + continue } - y.CatchTime += 1//自增保持时间排序 + break } } From 696e6225e523d649ab77324de6992ca06f6d8c21 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 17 Oct 2025 19:40:27 +0000 Subject: [PATCH 04/10] =?UTF-8?q?```refactor(pet):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=AE=A0=E7=89=A9=E6=9C=8D=E5=8A=A1=E7=BB=93=E6=9E=84=EF=BC=8C?= =?UTF-8?q?=E5=B0=86PetService=E7=8B=AC=E7=AB=8B=E5=B0=81=E8=A3=85?= =?UTF-8?q?=E5=B9=B6=E7=BB=A7=E6=89=BFcool.Service```?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/cool/service.go | 3 ++- modules/blazing/service/pet.go | 8 ++++++-- modules/blazing/service/user.go | 12 ++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/common/cool/service.go b/common/cool/service.go index ef998c45..4a2a9f40 100644 --- a/common/cool/service.go +++ b/common/cool/service.go @@ -22,6 +22,7 @@ type IService interface { GetModel() IModel // 获取model } type Service struct { + Models *gdb.Model Model IModel ListQueryOp *QueryOp PageQueryOp *QueryOp @@ -420,8 +421,8 @@ func (s *Service) ModifyAfter(ctx context.Context, method string, param g.MapStr func (s *Service) GetModel() IModel { return s.Model } -// GetModel 获取model +// GetModel 获取model // NewService 新建一个service func NewService(model IModel) *Service { diff --git a/modules/blazing/service/pet.go b/modules/blazing/service/pet.go index b3086454..e66a9b5f 100644 --- a/modules/blazing/service/pet.go +++ b/modules/blazing/service/pet.go @@ -52,8 +52,12 @@ func (s *UserService) PetAdd(y model.PetInfo) { } -func NewPetService() *MonsterService { - return &MonsterService{ +type PetService struct { + *cool.Service +} + +func NewPetService() *PetService { + return &PetService{ &cool.Service{ Model: model.NewPet(), PageQueryOp: &cool.QueryOp{ diff --git a/modules/blazing/service/user.go b/modules/blazing/service/user.go index de9c7297..5ba44711 100644 --- a/modules/blazing/service/user.go +++ b/modules/blazing/service/user.go @@ -10,11 +10,11 @@ import ( type UserService struct { userid uint32 //感觉可以给每个server重新继承? - talk *cool.Service //挖矿 - task *cool.Service //任务 - info *cool.Service //信息 - pet *cool.Service //精灵 - item *cool.Service //物品 + talk *cool.Service //挖矿 + task *cool.Service //任务 + info *cool.Service //信息 + pet *PetService //精灵 + item *cool.Service //物品 } func NewUserService(id uint32) *UserService { @@ -29,7 +29,7 @@ func NewUserService(id uint32) *UserService { "player_id": "角色名称不能重复", }, }, - pet: &cool.Service{Model: model.NewPet()}, + pet: NewPetService(), item: &cool.Service{Model: model.NewPlayerBag(), UniqueKey: map[string]string{ "player_id": "角色名称不能重复", From 7f0cde461df1738cb7f580a3eb9203e73f8d5b06 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 17 Oct 2025 19:41:02 +0000 Subject: [PATCH 05/10] =?UTF-8?q?```refactor(cool):=20=E7=A7=BB=E9=99=A4Se?= =?UTF-8?q?rvice=E4=B8=AD=E5=86=97=E4=BD=99=E7=9A=84Models=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=8C=E4=BB=85=E4=BF=9D=E7=95=99Model=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3```?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/cool/service.go | 1 - 1 file changed, 1 deletion(-) diff --git a/common/cool/service.go b/common/cool/service.go index 4a2a9f40..8033cbef 100644 --- a/common/cool/service.go +++ b/common/cool/service.go @@ -22,7 +22,6 @@ type IService interface { GetModel() IModel // 获取model } type Service struct { - Models *gdb.Model Model IModel ListQueryOp *QueryOp PageQueryOp *QueryOp From eb3d5f05a1b7a60f19cd951f3f0a367cdfce5734 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 17 Oct 2025 20:33:02 +0000 Subject: [PATCH 06/10] =?UTF-8?q?```feat(chat):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E6=A8=A1=E5=9D=97=E5=9F=BA=E7=A1=80=E7=BB=93?= =?UTF-8?q?=E6=9E=84=EF=BC=8C=E5=AE=9A=E4=B9=89ChatInboundInfo=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=BB=93=E6=9E=84=E4=BD=93```?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/chat.go | 0 logic/service/chat/chat.go | 11 +++++++++++ 2 files changed, 11 insertions(+) create mode 100644 logic/controller/chat.go create mode 100644 logic/service/chat/chat.go diff --git a/logic/controller/chat.go b/logic/controller/chat.go new file mode 100644 index 00000000..e69de29b diff --git a/logic/service/chat/chat.go b/logic/service/chat/chat.go new file mode 100644 index 00000000..ee4fd9bc --- /dev/null +++ b/logic/service/chat/chat.go @@ -0,0 +1,11 @@ +package chat + +import "blazing/logic/service/player" + +type ChatInboundInfo struct { + + + Head player.TomeeHeader `cmd:"2102" struc:"[0]pad"` + Reserve uint32 `json:"reserve" fieldDescription:"填充 默认值为0" uint:"true"` // @UInt long reserve,无符号长整数 + Message string `json:"message" fieldDescription:"消息内容, 结束符为utf-8的数字0"` // 消息内容,包含utf-8空字符('\x00')作为结束符 +} From 6e7dc9ebca17f7e8702d69845ded93cf4d76ec51 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 17 Oct 2025 21:04:19 +0000 Subject: [PATCH 07/10] =?UTF-8?q?```refactor(service):=20=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E6=95=B0=E6=8D=AE=E5=BA=93=E6=A8=A1=E5=9E=8B=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E6=96=B9=E5=BC=8F=EF=BC=8C=E4=BD=BF=E7=94=A8s.Model?= =?UTF-8?q?=E6=9B=BF=E4=BB=A3cool.DBM```?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/chat.go | 1 + modules/blazing/service/info.go | 6 +++--- modules/blazing/service/item.go | 3 +-- modules/blazing/service/task.go | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/logic/controller/chat.go b/logic/controller/chat.go index e69de29b..484b5256 100644 --- a/logic/controller/chat.go +++ b/logic/controller/chat.go @@ -0,0 +1 @@ +package controller \ No newline at end of file diff --git a/modules/blazing/service/info.go b/modules/blazing/service/info.go index 10d67ff2..b819801b 100644 --- a/modules/blazing/service/info.go +++ b/modules/blazing/service/info.go @@ -13,7 +13,7 @@ import ( // 是否注册,如果注册过,那么就会产生用户player信息 func (s *UserService) IsReg() bool { - m := cool.DBM(s.info.Model).Where("player_id", s.userid) + m := s.Model(s.info.Model) record, err := m.One() if err != nil { @@ -52,7 +52,7 @@ func (s *UserService) Reg(nick string, color uint32) { func (s *UserService) Person(userid uint32) *model.PlayerInfo { - m := cool.DBM(s.info.Model).Where("player_id", userid) + m := s.Model(s.info.Model) var tt model.PlayerEX err := m.Scan(&tt) if err != nil { @@ -64,7 +64,7 @@ func (s *UserService) Person(userid uint32) *model.PlayerInfo { } func (s *UserService) Save(data *model.PlayerInfo) { - m := cool.DBM(s.info.Model).Where("player_id", data.UserID) + m := s.Model(s.info.Model) var tt model.PlayerEX m.Scan(&tt) tt.Data = data diff --git a/modules/blazing/service/item.go b/modules/blazing/service/item.go index eb9d0b90..e948ce43 100644 --- a/modules/blazing/service/item.go +++ b/modules/blazing/service/item.go @@ -1,7 +1,6 @@ package service import ( - "blazing/cool" "blazing/modules/blazing/model" ) @@ -9,7 +8,7 @@ func (s *UserService) Item(t func(map[uint32]model.SingleItemInfo) bool) { //todo待测试 var player model.ItemEX - m1 := cool.DBM(s.item.Model).Where("player_id", s.userid) + m1 := s.Model(s.item.Model) err := m1.Scan(&player) if err != nil { diff --git a/modules/blazing/service/task.go b/modules/blazing/service/task.go index 42e3379a..6db5ae80 100644 --- a/modules/blazing/service/task.go +++ b/modules/blazing/service/task.go @@ -11,6 +11,7 @@ func Exec[T cool.UserModel, F any](userid uint32, s *cool.Service, processFunc f //todo待测试 var player T + m1 := cool.DBM(s.Model).Where("player_id", userid) m1.Scan(&player) // 方法2:使用反射获取 From 31c7687036376cf744264f53d4580d2ce0bd8f8a Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 17 Oct 2025 21:38:24 +0000 Subject: [PATCH 08/10] =?UTF-8?q?```refactor(pet):=20=E6=8F=90=E5=8F=96?= =?UTF-8?q?=E5=AE=A0=E7=89=A9=E5=9F=BA=E7=A1=80=E5=B1=9E=E6=80=A7=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E9=80=BB=E8=BE=91=E5=88=B0GetBasic=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E7=BB=8F=E9=AA=8C=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=B5=81=E7=A8=8B```?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/data/xmlres/pet.go | 9 +++++++++ logic/service/player/pet.go | 27 +++++++++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/common/data/xmlres/pet.go b/common/data/xmlres/pet.go index 188d9705..5b9e282e 100644 --- a/common/data/xmlres/pet.go +++ b/common/data/xmlres/pet.go @@ -45,6 +45,15 @@ type PetInfo struct { LearnableMoves LearnableMoves `xml:"LearnableMoves"` // 可学习的技能 } + +func (basic *PetInfo) GetBasic() uint32 { +return basic.Atk + + basic.Def + + basic.SpAtk + + basic.SpDef + + basic.Spd + + uint32(basic.HP) +} // Monsters 表示所有怪物的集合 type Monsters struct { XMLName xml.Name `xml:"Monsters"` diff --git a/logic/service/player/pet.go b/logic/service/player/pet.go index 53e609c1..16760a75 100644 --- a/logic/service/player/pet.go +++ b/logic/service/player/pet.go @@ -37,24 +37,19 @@ func calculateExperience(level uint32, baseValue uint32) uint32 { func (p *Player) AddPetExp(petinfo *model.PetInfo, addExp uint32, bro bool) { originalLevel := petinfo.Level + basic := xmlres.PetMAP[int(petinfo.ID)] for { - basic := xmlres.PetMAP[int(petinfo.ID)] - ba := basic.Atk + - basic.Def + - basic.SpAtk + - basic.SpDef + - basic.Spd + - uint32(basic.HP) - needExp := calculateExperience(petinfo.Level, ba) + + needExp := calculateExperience(petinfo.Level, basic.GetBasic()) needExp -= petinfo.Exp if addExp >= needExp { + basic := xmlres.PetMAP[int(petinfo.ID)] addExp -= needExp p.Info.ExpPool -= needExp //减去已使用的经验 petinfo.Level++ - + petinfo.Exp = 0 if originalLevel < 100 && petinfo.Level == 100 { //升到100了 - petinfo.Cure() - petinfo.NextLvExp = calculateExperience(petinfo.Level, ba) + break //停止升级 } @@ -69,13 +64,17 @@ func (p *Player) AddPetExp(petinfo *model.PetInfo, addExp uint32, bro bool) { } else { p.Info.ExpPool -= addExp //减去已使用的经验 - petinfo.Exp = addExp //零头添到这里 - petinfo.NextLvExp = calculateExperience(petinfo.Level, ba) + petinfo.Exp += addExp //零头添到这里 + break } } - + petinfo.NextLvExp = calculateExperience(petinfo.Level, basic.GetBasic()) + //治疗 + if petinfo.Level != originalLevel { + petinfo.Cure() + } //petinfo.Exp = addExp petinfo.LvExp = petinfo.NextLvExp - petinfo.Exp From 3597f226670844fc90fd4feb1cd1ff23cce53768 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 17 Oct 2025 21:40:51 +0000 Subject: [PATCH 09/10] =?UTF-8?q?```refactor(pet):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=AE=A0=E7=89=A9=E7=BB=8F=E9=AA=8C=E8=AE=A1=E7=AE=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E4=BD=BF=E7=94=A8NextLvExp=E6=9B=BF=E4=BB=A3?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E8=AE=A1=E7=AE=97```?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/player/pet.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/logic/service/player/pet.go b/logic/service/player/pet.go index 16760a75..49035b39 100644 --- a/logic/service/player/pet.go +++ b/logic/service/player/pet.go @@ -40,12 +40,11 @@ func (p *Player) AddPetExp(petinfo *model.PetInfo, addExp uint32, bro bool) { basic := xmlres.PetMAP[int(petinfo.ID)] for { - needExp := calculateExperience(petinfo.Level, basic.GetBasic()) - needExp -= petinfo.Exp - if addExp >= needExp { + if addExp >= petinfo.NextLvExp { + petinfo.NextLvExp = calculateExperience(petinfo.Level, basic.GetBasic()) basic := xmlres.PetMAP[int(petinfo.ID)] - addExp -= needExp - p.Info.ExpPool -= needExp //减去已使用的经验 + addExp -= petinfo.NextLvExp + p.Info.ExpPool -= petinfo.NextLvExp //减去已使用的经验 petinfo.Level++ petinfo.Exp = 0 if originalLevel < 100 && petinfo.Level == 100 { //升到100了 @@ -70,7 +69,7 @@ func (p *Player) AddPetExp(petinfo *model.PetInfo, addExp uint32, bro bool) { } } - petinfo.NextLvExp = calculateExperience(petinfo.Level, basic.GetBasic()) + //治疗 if petinfo.Level != originalLevel { petinfo.Cure() From be32e4dba71597889d2984355745d30e4094d3a5 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 17 Oct 2025 23:09:26 +0000 Subject: [PATCH 10/10] =?UTF-8?q?```refactor(pet):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=AE=A0=E7=89=A9=E7=BB=8F=E9=AA=8C=E6=B7=BB=E5=8A=A0=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=AE=80=E5=8C=96=E5=8D=87=E7=BA=A7=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E5=B9=B6=E4=BF=AE=E5=A4=8D=E7=BB=8F=E9=AA=8C=E6=B1=A0?= =?UTF-8?q?=E8=AE=A1=E7=AE=97```?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/player/pet.go | 53 +++++++++++++------------------------ 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/logic/service/player/pet.go b/logic/service/player/pet.go index 49035b39..857b314d 100644 --- a/logic/service/player/pet.go +++ b/logic/service/player/pet.go @@ -37,50 +37,35 @@ func calculateExperience(level uint32, baseValue uint32) uint32 { func (p *Player) AddPetExp(petinfo *model.PetInfo, addExp uint32, bro bool) { originalLevel := petinfo.Level - basic := xmlres.PetMAP[int(petinfo.ID)] - for { - if addExp >= petinfo.NextLvExp { - petinfo.NextLvExp = calculateExperience(petinfo.Level, basic.GetBasic()) - basic := xmlres.PetMAP[int(petinfo.ID)] - addExp -= petinfo.NextLvExp - p.Info.ExpPool -= petinfo.NextLvExp //减去已使用的经验 - petinfo.Level++ + petinfo.Exp += addExp + p.Info.ExpPool -= addExp //减去已使用的经验 + for petinfo.Exp >= petinfo.NextLvExp { + + petinfo.Level++ + if originalLevel < 100 && petinfo.Level == 100 { //升到100了 + p.Info.ExpPool += (petinfo.Exp) //减去已使用的经验 petinfo.Exp = 0 - if originalLevel < 100 && petinfo.Level == 100 { //升到100了 + break //停止升级 + } + basic := xmlres.PetMAP[int(petinfo.ID)] + // 检查是否可以进化 + if basic.EvolvesTo != 0 && // 有明确的进化 + int(petinfo.Level) >= basic.EvolvingLv && // 有明确的进化等级 + basic.IsLarge == 0 { // 非最终形态 - break //停止升级 - } + petinfo.ID = uint32(basic.EvolvesTo) - // 检查是否可以进化 - if basic.EvolvesTo != 0 && // 有明确的进化 - int(petinfo.Level) >= basic.EvolvingLv && // 有明确的进化等级 - basic.IsLarge == 0 { // 非最终形态 - - petinfo.ID = uint32(basic.EvolvesTo) - - } - - } else { - p.Info.ExpPool -= addExp //减去已使用的经验 - petinfo.Exp += addExp //零头添到这里 - - break } + petinfo.Exp -= petinfo.NextLvExp + petinfo.LvExp = petinfo.NextLvExp + petinfo.NextLvExp = calculateExperience(petinfo.Level, basic.GetBasic()) } - //治疗 - if petinfo.Level != originalLevel { - petinfo.Cure() - } - //petinfo.Exp = addExp - - petinfo.LvExp = petinfo.NextLvExp - petinfo.Exp - // 处理进化逻辑 - // 重新计算面板 if originalLevel != petinfo.Level { + petinfo.Cure() petinfo.CalculatePetPane() } if bro {