This commit is contained in:
1
2025-09-23 15:08:12 +00:00
8 changed files with 57 additions and 32 deletions

View File

@@ -109,11 +109,16 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player.
*/
func (h Controller) Get_Task_Buf(data *task.GetTaskBufInboundInfo, c *player.Player) (result *task.GetTaskBufOutboundInfo, err errorcode.ErrorCode) {
result = &task.GetTaskBufOutboundInfo{}
<<<<<<< HEAD
c.Service.Task(data.TaskId, func(te *model.TaskEX)bool {
result.TaskId = te.TaskID
result.TaskList = te.Data
return false
})
=======
result.TaskId = data.TaskId
result.TaskList = info.Data
>>>>>>> ea1148039e70e6b1dadf6c892b49e547d0f10ac7
return result, 0
}

View File

@@ -41,11 +41,11 @@ func (f *FightC) GetInputByPlayer(c common.PlayerI, isOpposite bool) *input.Inpu
// 判断当前玩家是否为我方玩家
isOurPlayer := c == f.Our.Player
// 逻辑简化:当"是否为我方玩家"与"是否需要对方"状态一致时,返回对方输入,否则返回我方输入
if isOurPlayer == isOpposite {
return f.Opp
// 当isOurPlayer与isOpposite值不同时返回我方相同时返回对方
if isOurPlayer != isOpposite {
return f.Our
}
return f.Our
return f.Opp
}
func (f *FightC) GetInputByAction(c BattleActionI, isOpposite bool) *input.Input {
@@ -320,35 +320,34 @@ func (f *FightC) battleLoop() {
switch {
case faction.ItemID >= 30001 && faction.ItemID <= 300010: //胶囊
f.Broadcast(func(ff *input.Input) {
//todo 将血量和技能pp传回enterturn
tt, ok := ff.Player.(*player.Player)
mo, ism := f.Opp.Player.(*player.AI_player)
if ok && ism && mo.CanCapture { //如果获取玩家
//todo 将血量和技能pp传回enterturn
tt, ok := f.Our.Player.(*player.Player)
mo, ism := f.Opp.Player.(*player.AI_player)
ok, _ := f.Our.Capture(f.Opp.CurrentPet, faction.ItemID, -1)
if ok { //todo 待补充
tt.Service.PetAdd(*f.Opp.CurrentPet.Info)
tt.CatchPetInfo(info.CatchMonsterOutboundInfo{
CatchTime: uint32(f.Opp.CurrentPet.Info.CatchTime),
PetId: uint32(f.Opp.CurrentPet.ID),
})
ff.Player.SendFightEndInfo(info.FightOverInfo{
if ok && ism && mo.CanCapture { //如果获取玩家
WinnerId: f.ownerID,
})
f.closefight = true
} else {
tt.CatchPetInfo(info.CatchMonsterOutboundInfo{})
}
ok, _ := f.Our.Capture(f.Opp.CurrentPet, faction.ItemID, -1)
if ok { //todo 待补充
tt.Service.PetAdd(*f.Opp.CurrentPet.Info)
tt.CatchPetInfo(info.CatchMonsterOutboundInfo{
CatchTime: uint32(f.Opp.CurrentPet.Info.CatchTime),
PetId: uint32(f.Opp.CurrentPet.ID),
})
tt.SendFightEndInfo(info.FightOverInfo{
} else { //说明不是可以捕捉的
WinnerId: f.ownerID,
})
f.closefight = true
} else {
tt.CatchPetInfo(info.CatchMonsterOutboundInfo{})
}
})
} else { //说明不是可以捕捉的
tt.CatchPetInfo(info.CatchMonsterOutboundInfo{})
}
// 当 ItemID 在 30001-300010 之间时执行的逻辑
fmt.Println("ItemID 在范围内")
case faction.ItemID == 300001:
@@ -465,6 +464,9 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *SelectSk
func (f *FightC) enterturn(fattack, sattack BattleActionI) {
if f.closefight { //战斗结束
return
}
f.initAttackers(fattack) //初始化先后手
var attacker, defender *input.Input

View File

@@ -28,7 +28,7 @@ type Input struct {
func NewInput(c common.FightI, p common.PlayerI) *Input {
ret := &Input{FightC: c, Player: p}
t := NodeM[1000000]
t, _ := ret.GetDamageEffect(1)
ret.AddEffect(deepcopy.Copy(t).(Effect)) //添加默认基类,实现继承
p.SetFightC(c) //给玩家设置战斗容器
return ret

View File

@@ -44,8 +44,13 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) {
BaseAction: NewBaseAction(c.GetInfo().UserID),
}
f.Switch = append(f.Switch, ret)
if c.GetInfo().UserID == f.ownerID {
f.GetInputByPlayer(c, false).CurrentPet, ret.Reason = f.GetInputByPlayer(c, false).GetPet(id)
f.GetInputByPlayer(c, false).CurrentPet, ret.Reason = f.GetInputByPlayer(c, false).GetPet(id)
} else {
f.GetInputByPlayer(c, true).CurrentPet, ret.Reason = f.GetInputByPlayer(c, true).GetPet(id)
}
f.actionChan <- ret
}

View File

@@ -17,7 +17,7 @@ func NewPlayer(opts ...PlayerOption) *Player {
p.StopChan = make(chan struct{})
// 启动刷怪协程
go func(stopChan chan struct{}, currentMap int) {
go func(stopChan chan struct{}) {
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
@@ -35,7 +35,7 @@ func NewPlayer(opts ...PlayerOption) *Player {
}
}
}(p.StopChan, int(p.Info.MapID))
}(p.StopChan)
for _, opt := range opts {
opt(p)
}