diff --git a/logic/controller/fight_boss.go b/logic/controller/fight_boss.go index 95aebf1cc..8a1a88d27 100644 --- a/logic/controller/fight_boss.go +++ b/logic/controller/fight_boss.go @@ -134,7 +134,7 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *pla ai := player.NewAI_player(monsterInfo) ai.CanCapture = canCapture ai.Prop[0] = 2 - fight.NewFight(p, ai, func(foi *info.FightOverInfo) { + fight.NewFight(p, ai, func(foi info.FightOverInfo) { if taskID != 0 { if foi.Reason == 0 && foi.WinnerId == p.Info.UserID { p.CompletedTask(taskID, 100) @@ -188,7 +188,7 @@ func (h Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundI p.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC //打野怪 p.Fightinfo.Mode = info.BattleMode.MULTI_MODE //多人模式 - fight.NewFight(p, ai, func(foi *info.FightOverInfo) { + fight.NewFight(p, ai, func(foi info.FightOverInfo) { p.Done.Exec(model.MilestoneMode.Moster, []uint32{p.Info.MapID, monsterInfo.PetList[0].ID, uint32(foi.Reason)}, nil) if foi.Reason == 0 && foi.WinnerId == p.Info.UserID { diff --git a/logic/controller/fight_leitai.go b/logic/controller/fight_leitai.go index 9b986231e..e94deafa1 100644 --- a/logic/controller/fight_leitai.go +++ b/logic/controller/fight_leitai.go @@ -64,7 +64,7 @@ func (h Controller) ArenaFightOwner(data *fight.ARENA_FIGHT_OWENR, c *player.Pla c.Fightinfo.Mode = info.BattleMode.SINGLE_MODE c.Fightinfo.Status = info.BattleMode.FIGHT_ARENA - _, err = fight.NewFight(c, c.GetSpace().Owner.ARENA_Player, func(foi *info.FightOverInfo) { //我方邀请擂主挑战,我方先手 + _, err = fight.NewFight(c, c.GetSpace().Owner.ARENA_Player, func(foi info.FightOverInfo) { //我方邀请擂主挑战,我方先手 if foi.Reason != 0 && foi.WinnerId == c.GetInfo().UserID { //异常退出 diff --git a/logic/controller/fight_pvp_king.go b/logic/controller/fight_pvp_king.go index 696bcfe1f..359f3d8c5 100644 --- a/logic/controller/fight_pvp_king.go +++ b/logic/controller/fight_pvp_king.go @@ -17,7 +17,7 @@ func (h Controller) PetMelee(data *fight.StartPetWarInboundInfo, c *player.Playe c.Fightinfo.Status = info.BattleMode.PET_MELEE err = c.JoinFight(func(p common.PlayerI) bool { - _, err = fight.NewFight(p, c, func(foi *info.FightOverInfo) { + _, err = fight.NewFight(p, c, func(foi info.FightOverInfo) { if foi.Reason == 0 { //我放获胜 if foi.WinnerId == c.GetInfo().UserID { @@ -45,7 +45,7 @@ func (h Controller) PetKing(data *fight.PetKingJoinInboundInfo, c *player.Player c.Fightinfo.Mode = info.BattleMode.MULTI_MODE } err = c.JoinFight(func(p common.PlayerI) bool { - _, err = fight.NewFight(p, c, func(foi *info.FightOverInfo) { + _, err = fight.NewFight(p, c, func(foi info.FightOverInfo) { if foi.Reason == 0 { //我放获胜 if foi.WinnerId == c.GetInfo().UserID { c.Info.MonKingWin += 1 diff --git a/logic/controller/fight_pvp_withplayer.go b/logic/controller/fight_pvp_withplayer.go index 7ec15a17d..305f9942b 100644 --- a/logic/controller/fight_pvp_withplayer.go +++ b/logic/controller/fight_pvp_withplayer.go @@ -53,7 +53,7 @@ func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInbou return } - _, err = fight.NewFight(v, c, func(foi *info.FightOverInfo) { + _, err = fight.NewFight(v, c, func(foi info.FightOverInfo) { }) diff --git a/logic/controller/fight_tawor.go b/logic/controller/fight_tawor.go index 623858e7a..7ec11bcfc 100644 --- a/logic/controller/fight_tawor.go +++ b/logic/controller/fight_tawor.go @@ -184,7 +184,7 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player) } ai := player.NewAI_player(monsterInfo) - _, err = fight.NewFight(c, ai, func(foi *fightinfo.FightOverInfo) { + _, err = fight.NewFight(c, ai, func(foi fightinfo.FightOverInfo) { if foi.Reason == 0 && foi.WinnerId == c.Info.UserID { //我放获胜 switch data.Head.CMD { case 2429: //试炼之塔 diff --git a/logic/controller/pet_collect.go b/logic/controller/pet_collect.go index 402cbb877..5d650bb5a 100644 --- a/logic/controller/pet_collect.go +++ b/logic/controller/pet_collect.go @@ -12,6 +12,12 @@ func (h Controller) IsCollect( ID: data.Type, IsCom: 0, } + // r := c.Service.Barge.Get() + + // for _, v := range r { + + // } + return result, 0 } diff --git a/logic/controller/pet_info.go b/logic/controller/pet_info.go index 664e8588a..82406a8d1 100644 --- a/logic/controller/pet_info.go +++ b/logic/controller/pet_info.go @@ -223,6 +223,19 @@ func (h Controller) SetPetExp(data *pet.PetSetExpInboundInfo, player *player.Pla // GetPetBargeList 精灵图鉴 func (h Controller) GetPetBargeList(data *pet.PetBargeListInboundInfo, player *player.Player) (result *pet.PetBargeListOutboundInfo, err errorcode.ErrorCode) { + ret := &pet.PetBargeListOutboundInfo{ + PetBargeList: make([]pet.PetBargeListInfo, 0), + } + r := player.Service.Barge.Get(data.StartPetId, data.EndPetId) + for _, v := range r { + + ret.PetBargeList = append(ret.PetBargeList, pet.PetBargeListInfo{ + PetId: v.PetId, + IsCatched: v.CatchedCount, + IsKilled: v.KilledCount, + }) + } + return &pet.PetBargeListOutboundInfo{ PetBargeList: make([]pet.PetBargeListInfo, 0), }, 0 diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index 22fbafbeb..367868e0e 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -363,6 +363,9 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction) fighter.Player.SendPackCmd(2505, &attackValueResult) fighter.CanChange = 0 }) + if f.closefight { + return + } //println("回合结束") if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC { if f.Opp.CurrentPet.Info.Hp <= 0 { diff --git a/logic/service/fight/input.go b/logic/service/fight/input.go index f09bc4613..ea889818a 100644 --- a/logic/service/fight/input.go +++ b/logic/service/fight/input.go @@ -51,7 +51,7 @@ type FightC struct { waittime int info.FightOverInfo //战斗结束的插装 - callback func(*info.FightOverInfo) + callback func(info.FightOverInfo) } func (f *FightC) Ownerid() uint32 { @@ -266,7 +266,7 @@ func initfightready(in *input.Input) (info.FightUserInfo, []info.ReadyFightPetIn } // 创建新战斗,邀请方和被邀请方,或者玩家和野怪方 -func NewFight(p1, p2 common.PlayerI, fn func(*info.FightOverInfo)) (*FightC, errorcode.ErrorCode) { +func NewFight(p1, p2 common.PlayerI, fn func(info.FightOverInfo)) (*FightC, errorcode.ErrorCode) { fmt.Println("NewFight", p1.GetInfo().UserID) f := &FightC{} diff --git a/logic/service/fight/loop.go b/logic/service/fight/loop.go index 01fb88b8f..af7e082a0 100644 --- a/logic/service/fight/loop.go +++ b/logic/service/fight/loop.go @@ -43,7 +43,6 @@ func (f *FightC) battleLoop() { f.resolveRound(actions[ourID], actions[oppID]) } - f.Broadcast(func(ff *input.Input) { //todo 将血量和技能pp传回enterturn @@ -74,25 +73,24 @@ func (f *FightC) battleLoop() { } }) + if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC { + if f.Reason == info.BattleOverReason.Cacthok { + f.WinnerId = f.ownerID + f.Our.Player.(*player.Player).Service.Pet.PetAdd(&f.Opp.Player.GetInfo().PetList[0]) - if f.Reason == info.BattleOverReason.Cacthok { - f.WinnerId = f.ownerID - f.Our.Player.(*player.Player).Service.Pet.PetAdd(&f.Opp.Player.GetInfo().PetList[0]) + f.Our.Player.SendPackCmd(2409, &info.CatchMonsterOutboundInfo{ + CatchTime: uint32(f.Opp.Player.GetInfo().PetList[0].CatchTime), + PetId: uint32(f.Opp.CurrentPet.ID), + }) + defer f.Our.Player.(*player.Player).Service.Barge.Update(f.Opp.Player.GetInfo().PetList[0].ID, false) + //f.Reason = 0 //清空 + } + if f.Reason == 0 { + defer f.Our.Player.(*player.Player).Service.Barge.Update(f.Opp.Player.GetInfo().PetList[0].ID, true) - f.Our.Player.SendPackCmd(2409, &info.CatchMonsterOutboundInfo{ - CatchTime: uint32(f.Opp.Player.GetInfo().PetList[0].CatchTime), - PetId: uint32(f.Opp.CurrentPet.ID), - }) - //f.Reason = 0 //清空 + } } - //f.Reason = info.BattleOverReason.PlayerCaptureSuccess - //f.WinnerId = 0 //捕捉成功不算胜利 - if f.callback != nil { - - f.callback(&f.FightOverInfo) //先执行回调,再执行返回信息,在回调内修改战斗判断 - - } //大乱斗,给个延迟 //<-time.After(1000) f.Broadcast(func(ff *input.Input) { @@ -104,6 +102,13 @@ func (f *FightC) battleLoop() { //待退出玩家战斗状态 }) + //f.Reason = info.BattleOverReason.PlayerCaptureSuccess + //f.WinnerId = 0 //捕捉成功不算胜利 + if f.callback != nil { + + f.callback(f.FightOverInfo) //先执行回调,再执行返回信息,在回调内修改战斗判断 + + } // close(f.actionChan) fmt.Println(f.ownerID, "战斗循环结束") close(f.over) @@ -279,7 +284,7 @@ func (f *FightC) handleActiveSwitchAction(switchAction *action.ActiveSwitchActio // handleUseItemAction 处理使用道具动作 func (f *FightC) handleUseItemAction(itemAction *action.UseItemAction, otherAction action.BattleActionI) { f.handleItemAction(itemAction) - + input := f.GetInputByAction(itemAction, false) if input.CurrentPet.Info.Hp <= 0 { input.CurrentPet.Info.Hp = 1 diff --git a/modules/blazing/model/pet_Barge.go b/modules/blazing/model/Barge.go similarity index 64% rename from modules/blazing/model/pet_Barge.go rename to modules/blazing/model/Barge.go index 9612ed45c..38af8b934 100644 --- a/modules/blazing/model/pet_Barge.go +++ b/modules/blazing/model/Barge.go @@ -3,7 +3,6 @@ package model import ( "blazing/cool" "errors" - "fmt" ) // 表名常量定义:精灵捕捉击杀数量记录表 @@ -13,20 +12,12 @@ const ( // PetBargeListInfo 精灵捕捉击杀数量核心模型(简化版,直接记录数量,摒弃状态判断) type PetBargeListInfo struct { - *cool.Model `json:"-" gorm:"embedded"` // 嵌入通用Model(ID/创建时间/更新时间,不参与json序列化) - - PetId uint32 `gorm:"not null;default:0;comment:'精灵ID,关联config_pet_boss表主键'" json:"pet_id" description:"精灵ID"` - EnCntCnt uint32 `gorm:"not null;default:0;comment:'预留未知字段,暂未使用'" json:"en_cnt_cnt" description:"未知"` - CatchedCount uint32 `gorm:"not null;default:0;comment:'精灵捕捉总数量'" json:"catched_count" description:"捕捉数量"` // 替换原IsCatched,记录捕捉总数 - KilledCount uint32 `gorm:"not null;default:0;comment:'精灵击杀总数量'" json:"killed_count" description:"击杀数量"` // 替换原IsKilled,记录击杀总数 -} - -// PetBargeListInfoEX 精灵捕捉击杀数量扩展模型(用于前端/业务层展示) -type PetBargeListInfoEX struct { - PetBargeListInfo // 嵌入核心数量模型 - PetName string `json:"pet_name" description:"精灵名称"` // 前端展示用,关联精灵配置表查询 - CatchedCountDesc string `json:"catched_count_desc" description:"捕捉数量描述"` // 如"已捕捉3次" - KilledCountDesc string `json:"killed_count_desc" description:"击杀数量描述"` // 如"已击杀5次" + *cool.Model `json:"-" gorm:"embedded"` // 嵌入通用Model(ID/创建时间/更新时间,不参与json序列化) + PlayerID uint64 `gorm:"not null;index:idx_milestone_by_player_id;comment:'所属玩家ID'" json:"player_id"` + PetId uint32 `gorm:"not null;default:0;comment:'精灵ID,关联config_pet_boss表主键'" json:"pet_id" description:"精灵ID"` + EnCntCnt uint32 `gorm:"not null;default:0;comment:'预留未知字段,暂未使用'" json:"en_cnt_cnt" description:"未知"` + CatchedCount uint32 `gorm:"not null;default:0;comment:'精灵捕捉总数量'" json:"catched_count" description:"捕捉数量"` // 替换原IsCatched,记录捕捉总数 + KilledCount uint32 `gorm:"not null;default:0;comment:'精灵击杀总数量'" json:"killed_count" description:"击杀数量"` // 替换原IsKilled,记录击杀总数 } // -------------------------- 核心配套方法 -------------------------- @@ -98,12 +89,6 @@ func (p *PetBargeListInfo) SetKilledCount(count uint32) error { return nil } -// GetCountDesc 填充扩展模型的数量描述字段(前端展示用) -func (p *PetBargeListInfoEX) GetCountDesc() { - p.CatchedCountDesc = fmt.Sprintf("已捕捉%d次", p.CatchedCount) - p.KilledCountDesc = fmt.Sprintf("已击杀%d次", p.KilledCount) -} - // -------------------------- 表结构自动同步 -------------------------- func init() { // 程序启动时自动创建/同步精灵捕捉击杀数量表 diff --git a/modules/blazing/service/Barge.go b/modules/blazing/service/Barge.go new file mode 100644 index 000000000..6afc495d1 --- /dev/null +++ b/modules/blazing/service/Barge.go @@ -0,0 +1,71 @@ +package service + +import ( + "blazing/cool" + "blazing/modules/blazing/model" + + "github.com/gogf/gf/v2/frame/g" +) + +type BargeService struct { + BaseService +} + +func NewBargeService(id uint32) *BargeService { + return &BargeService{ + + BaseService: BaseService{userid: id, + + Service: &cool.Service{Model: model.NewPetBargeListInfo()}, + }, + } + +} + +func (s *BargeService) Update(petid uint32, isskill bool) { + if t, _ := s.GModel(s.Model).Where("pet_id", petid).Count(); t != 0 { + if isskill { + s.GModel(s.Model).Where("pet_id", petid).Increment("killed_count", 1) + } else { + s.GModel(s.Model).Where("pet_id", petid).Increment("catched_count", 1) + } + + } else { + + r := g.Map{ + "player_id": s.userid, + "pet_id": petid, + } + + if isskill { + r["killed_count"] = 1 + } else { + r["catched_count"] = 1 + } + s.GModel(s.Model).Data(r).Insert() + } + +} +func (s *BargeService) Get(start, end uint32) []model.PetBargeListInfo { + var Barges []model.PetBargeListInfo + s.GModel(s.Model).WhereBetween("pet_id", start, end).Scan(&Barges) + return Barges + +} + +// // BargeCheck 获取玩家当前的Barge数据 +// // todo 待实现xml解析判断是否溢出 +// func (s *BargeService) Exec(t func(map[uint32]uint32) bool) { + +// m1 := s.GModel(s.Model) + +// var Barges model.Barge +// m1.Scan(&Barges) + +// ok := t(Barges) +// if ok { +// Barges.PlayerID = uint64(s.userid) +// m1.Save(Barges) +// } + +// } diff --git a/modules/blazing/service/user.go b/modules/blazing/service/user.go index e4de30ee0..6b7271de6 100644 --- a/modules/blazing/service/user.go +++ b/modules/blazing/service/user.go @@ -11,25 +11,27 @@ type BaseService struct { *cool.Service } type UserService struct { - Talk *TalkService //挖矿 - Task *TaskService //任务 - Info *InfoService //信息 - Pet *PetService //精灵 - Item *ItemService //物品 - Done *DoneService //完成 - Room *RoomService + Talk *TalkService //挖矿 + Task *TaskService //任务 + Info *InfoService //信息 + Pet *PetService //精灵 + Item *ItemService //物品 + Done *DoneService //完成 + Room *RoomService + Barge *BargeService } func NewUserService(id uint32) *UserService { return &UserService{ - Task: NewTaskService(id), - Info: NewInfoService(id), - Pet: NewPetService(id), - Item: NewItemService(id), - Talk: NewTalkService(id), - Done: NewDoneService(id), - Room: NewRoomService(id), + Task: NewTaskService(id), + Info: NewInfoService(id), + Pet: NewPetService(id), + Item: NewItemService(id), + Talk: NewTalkService(id), + Done: NewDoneService(id), + Room: NewRoomService(id), + Barge: NewBargeService(id), } }