Files
bl/logic/service/fightc.go

89 lines
1.8 KiB
Go
Raw Normal View History

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 {
Info *info.NoteReadyToFightInfo
Our PlayerI
Opp PlayerI
}
// 使用技能
func (f *FightC) UseSkill(c PlayerI, id uint32) {
}
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]) //复制对方信息
f.Our.SendReadyToFightInfo(rett)
f.Opp.SendReadyToFightInfo(rett)
}
} else {
f.Our = c
f.Info.BFinished = true
if f.Info.AFinished { //如果房主完成
copier.Copy(&rett.Info2, &f.Info.OurPetList[0]) //复制房主信息,因为这时候不是房主发来的消息
f.Our.SendReadyToFightInfo(rett)
f.Opp.SendReadyToFightInfo(rett)
}
}
case 3: //野怪战斗
copier.Copy(&rett.Info2, &f.Info.OpponentPetList[0])
rett.Info1.UserID = f.Info.OurInfo.UserID
f.Our.SendReadyToFightInfo(rett)
f.Opp.SendReadyToFightInfo(rett)
}
}
func (f *FightC) NewFight(i *info.NoteReadyToFightInfo, plays PlayerI) {
f.Our = plays
f.Info = i
f.Info.FightId = i.FightId
switch i.FightId {
case 1:
//1v1
case 3: //野怪战斗
plays.SendNoteReadyToFightInfo(*i)
f.Opp = &AI_player{
fightinfo: *i,
}
//这时候应该建立一个虚拟的player
}
for { //战斗回合循环
}
}