80 lines
2.8 KiB
Go
80 lines
2.8 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/modules/player/model"
|
|
|
|
"blazing/logic/service/fight"
|
|
"blazing/logic/service/player"
|
|
)
|
|
|
|
// dispatchFightActionEnvelope 把控制器层收到的统一动作结构分发回现有 FightI 接口。
|
|
func (h Controller) dispatchFightActionEnvelope(c *player.Player, envelope fight.FightActionEnvelope) {
|
|
if c == nil || c.FightC == nil {
|
|
return
|
|
}
|
|
|
|
switch envelope.ActionType {
|
|
case fight.FightActionTypeSkill:
|
|
go c.FightC.UseSkillAt(c, envelope.SkillID, envelope.ActorIndex, envelope.EncodedTargetIndex())
|
|
case fight.FightActionTypeItem:
|
|
go c.FightC.UseItemAt(c, envelope.CatchTime, envelope.ItemID, envelope.ActorIndex, envelope.EncodedTargetIndex())
|
|
case fight.FightActionTypeChange:
|
|
go c.FightC.ChangePetAt(c, envelope.CatchTime, envelope.ActorIndex)
|
|
case fight.FightActionTypeEscape:
|
|
go c.FightC.Over(c, model.BattleOverReason.PlayerEscape)
|
|
case fight.FightActionTypeChat:
|
|
go c.FightC.Chat(c, envelope.Chat)
|
|
}
|
|
}
|
|
|
|
// buildLegacyUseSkillEnvelope 把旧 2405 技能包映射成统一动作结构。
|
|
func buildLegacyUseSkillEnvelope(data *UseSkillInInfo) fight.FightActionEnvelope {
|
|
if data == nil {
|
|
return fight.NewSkillActionEnvelope(0, 0, 0, fight.SkillTargetOpponent, 0)
|
|
}
|
|
return fight.NewSkillActionEnvelope(data.SkillId, 0, 0, fight.SkillTargetOpponent, 0)
|
|
}
|
|
|
|
// buildIndexedUseSkillEnvelope 把 7505 多战位技能包映射成统一动作结构。
|
|
func buildIndexedUseSkillEnvelope(data *UseSkillAtInboundInfo) fight.FightActionEnvelope {
|
|
if data == nil {
|
|
return fight.NewSkillActionEnvelope(0, 0, 0, fight.SkillTargetOpponent, 0)
|
|
}
|
|
return fight.NewSkillActionEnvelope(
|
|
data.SkillId,
|
|
int(data.ActorIndex),
|
|
int(data.TargetIndex),
|
|
data.TargetRelation,
|
|
data.AtkType,
|
|
)
|
|
}
|
|
|
|
// buildLegacyUseItemEnvelope 把旧 2406 道具包映射成统一动作结构。
|
|
func buildLegacyUseItemEnvelope(data *UsePetItemInboundInfo) fight.FightActionEnvelope {
|
|
if data == nil {
|
|
return fight.NewItemActionEnvelope(0, 0, 0, 0, fight.SkillTargetOpponent)
|
|
}
|
|
return fight.NewItemActionEnvelope(data.CatchTime, data.ItemId, 0, 0, fight.SkillTargetOpponent)
|
|
}
|
|
|
|
// buildLegacyChangeEnvelope 把旧 2407 切宠包映射成统一动作结构。
|
|
func buildLegacyChangeEnvelope(data *ChangePetInboundInfo) fight.FightActionEnvelope {
|
|
if data == nil {
|
|
return fight.NewChangeActionEnvelope(0, 0)
|
|
}
|
|
return fight.NewChangeActionEnvelope(data.CatchTime, 0)
|
|
}
|
|
|
|
// buildLegacyEscapeEnvelope 构造旧 2410 逃跑包对应的统一动作结构。
|
|
func buildLegacyEscapeEnvelope() fight.FightActionEnvelope {
|
|
return fight.NewEscapeActionEnvelope()
|
|
}
|
|
|
|
// buildChatEnvelope 把战斗聊天包映射成统一动作结构。
|
|
func buildChatEnvelope(data *ChatInfo) fight.FightActionEnvelope {
|
|
if data == nil {
|
|
return fight.NewChatActionEnvelope("")
|
|
}
|
|
return fight.NewChatActionEnvelope(data.Message)
|
|
}
|