2025-09-04 02:00:57 +08:00
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/logic/service/fight/info"
|
|
|
|
|
"blazing/modules/blazing/model"
|
|
|
|
|
|
|
|
|
|
"github.com/jinzhu/copier"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type PlayerI interface {
|
|
|
|
|
ID() uint32
|
|
|
|
|
MapID() uint32
|
|
|
|
|
GetInfo() model.PlayerInfo
|
|
|
|
|
SendPack(b []byte) error
|
|
|
|
|
SendReadyToFightInfo(info.FightStartOutboundInfo)
|
|
|
|
|
SendNoteReadyToFightInfo(info.NoteReadyToFightInfo)
|
|
|
|
|
}
|
|
|
|
|
type FightC struct {
|
2025-09-04 02:11:55 +08:00
|
|
|
Info *info.NoteReadyToFightInfo
|
2025-09-04 02:00:57 +08:00
|
|
|
Our PlayerI
|
|
|
|
|
Opp PlayerI
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-04 03:05:37 +08:00
|
|
|
// 使用技能
|
|
|
|
|
func (f *FightC) UseSkill(c PlayerI, id uint32) {
|
2025-09-04 02:00:57 +08:00
|
|
|
|
2025-09-04 03:05:37 +08:00
|
|
|
}
|
2025-09-04 02:00:57 +08:00
|
|
|
func (f *FightC) ReadyFight(c PlayerI) {
|
|
|
|
|
|
|
|
|
|
rett := info.FightStartOutboundInfo{}
|
|
|
|
|
copier.Copy(&rett.Info1, &f.Info.OurPetList[0]) //复制自己的信息
|
|
|
|
|
switch f.Info.FightId { //判断战斗类型
|
|
|
|
|
case 1:
|
|
|
|
|
//1v1
|
|
|
|
|
|
|
|
|
|
if c == f.Our { //这个时候是房主发来的消息
|
|
|
|
|
f.Info.AFinished = true
|
|
|
|
|
if f.Info.BFinished {
|
|
|
|
|
|
|
|
|
|
copier.Copy(&rett.Info2, &f.Info.OpponentPetList[0]) //复制对方信息
|
2025-09-04 03:05:37 +08:00
|
|
|
f.Our.SendReadyToFightInfo(rett)
|
|
|
|
|
f.Opp.SendReadyToFightInfo(rett)
|
2025-09-04 02:00:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
f.Our = c
|
|
|
|
|
f.Info.BFinished = true
|
|
|
|
|
if f.Info.AFinished { //如果房主完成
|
|
|
|
|
|
|
|
|
|
copier.Copy(&rett.Info2, &f.Info.OurPetList[0]) //复制房主信息,因为这时候不是房主发来的消息
|
2025-09-04 03:05:37 +08:00
|
|
|
f.Our.SendReadyToFightInfo(rett)
|
|
|
|
|
f.Opp.SendReadyToFightInfo(rett)
|
2025-09-04 02:00:57 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 3: //野怪战斗
|
|
|
|
|
|
|
|
|
|
copier.Copy(&rett.Info2, &f.Info.OpponentPetList[0])
|
|
|
|
|
rett.Info1.UserID = f.Info.OurInfo.UserID
|
2025-09-04 03:05:37 +08:00
|
|
|
f.Our.SendReadyToFightInfo(rett)
|
|
|
|
|
f.Opp.SendReadyToFightInfo(rett)
|
2025-09-04 02:00:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
func (f *FightC) NewFight(i *info.NoteReadyToFightInfo, plays PlayerI) {
|
|
|
|
|
f.Our = plays
|
2025-09-04 02:11:55 +08:00
|
|
|
f.Info = i
|
2025-09-04 02:00:57 +08:00
|
|
|
|
|
|
|
|
f.Info.FightId = i.FightId
|
|
|
|
|
switch i.FightId {
|
|
|
|
|
case 1:
|
|
|
|
|
//1v1
|
|
|
|
|
|
|
|
|
|
case 3: //野怪战斗
|
|
|
|
|
plays.SendNoteReadyToFightInfo(*i)
|
2025-09-04 03:05:37 +08:00
|
|
|
f.Opp = &AI_player{
|
|
|
|
|
fightinfo: *i,
|
|
|
|
|
}
|
2025-09-04 02:00:57 +08:00
|
|
|
|
2025-09-04 03:05:37 +08:00
|
|
|
//这时候应该建立一个虚拟的player
|
2025-09-04 02:00:57 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-04 03:07:46 +08:00
|
|
|
for { //战斗回合循环
|
2025-09-04 02:00:57 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|