Files
bl/logic/service/fight/pvp/proxy.go
2026-04-05 05:04:04 +08:00

122 lines
3.2 KiB
Go

package pvp
import (
"blazing/logic/service/common"
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/pvpwire"
"blazing/modules/player/model"
)
type RemoteFightProxy struct {
sessionID string
hostServerID uint32
userID uint32
}
func NewRemoteFightProxy(sessionID string, hostServerID, userID uint32) *RemoteFightProxy {
return &RemoteFightProxy{
sessionID: sessionID,
hostServerID: hostServerID,
userID: userID,
}
}
func (r *RemoteFightProxy) relay(payload pvpwire.BattleCommandPayload) {
if r == nil {
return
}
payload.SessionID = r.sessionID
payload.UserID = r.userID
_ = publishServerMessage(pvpwire.ServerTopic(r.hostServerID), pvpwire.MessageTypeBattleCommand, payload)
}
func (r *RemoteFightProxy) Over(_ common.PlayerI, reason model.EnumBattleOverReason) {
r.relay(pvpwire.BattleCommandPayload{Command: pvpwire.CommandEscape, Reason: uint32(reason)})
}
func (r *RemoteFightProxy) UseSkill(_ common.PlayerI, id uint32) {
r.relay(pvpwire.BattleCommandPayload{Command: pvpwire.CommandUseSkill, SkillID: id})
}
func (r *RemoteFightProxy) UseSkillAt(_ common.PlayerI, id uint32, actorIndex, targetIndex int) {
r.relay(pvpwire.BattleCommandPayload{
Command: pvpwire.CommandUseSkillAt,
SkillID: id,
ActorIndex: actorIndex,
TargetIndex: targetIndex,
})
}
func (r *RemoteFightProxy) GetCurrPET(common.PlayerI) *info.BattlePetEntity {
return nil
}
func (r *RemoteFightProxy) GetCurrPETAt(common.PlayerI, int) *info.BattlePetEntity {
return nil
}
func (r *RemoteFightProxy) GetOverInfo() model.FightOverInfo {
return model.FightOverInfo{}
}
func (r *RemoteFightProxy) Ownerid() uint32 {
return r.userID
}
func (r *RemoteFightProxy) ReadyFight(common.PlayerI) {
r.relay(pvpwire.BattleCommandPayload{Command: pvpwire.CommandReady})
}
func (r *RemoteFightProxy) ChangePet(_ common.PlayerI, id uint32) {
r.relay(pvpwire.BattleCommandPayload{Command: pvpwire.CommandChangePet, CatchTime: id})
}
func (r *RemoteFightProxy) ChangePetAt(_ common.PlayerI, id uint32, actorIndex int) {
r.relay(pvpwire.BattleCommandPayload{
Command: pvpwire.CommandChangePetAt,
CatchTime: id,
ActorIndex: actorIndex,
})
}
func (r *RemoteFightProxy) Capture(common.PlayerI, uint32) {
}
func (r *RemoteFightProxy) LoadPercent(_ common.PlayerI, percent int32) {
r.relay(pvpwire.BattleCommandPayload{Command: pvpwire.CommandLoadPercent, Percent: percent})
}
func (r *RemoteFightProxy) UseItem(_ common.PlayerI, catchTime, itemID uint32) {
r.relay(pvpwire.BattleCommandPayload{
Command: pvpwire.CommandUseItem,
CatchTime: catchTime,
ItemID: itemID,
})
}
func (r *RemoteFightProxy) UseItemAt(_ common.PlayerI, catchTime, itemID uint32, actorIndex, targetIndex int) {
r.relay(pvpwire.BattleCommandPayload{
Command: pvpwire.CommandUseItemAt,
CatchTime: catchTime,
ItemID: itemID,
ActorIndex: actorIndex,
TargetIndex: targetIndex,
})
}
func (r *RemoteFightProxy) Chat(_ common.PlayerI, msg string) {
r.relay(pvpwire.BattleCommandPayload{Command: pvpwire.CommandChat, Message: msg})
}
func (r *RemoteFightProxy) IsFirst(common.PlayerI) bool {
return false
}
func (r *RemoteFightProxy) GetOverChan() chan struct{} {
return nil
}
func (r *RemoteFightProxy) GetAttackValue(bool) *model.AttackValue {
return nil
}