feat: 支持多精灵战斗位操作
This commit is contained in:
@@ -18,6 +18,8 @@ func NewFight(p1, p2 common.PlayerI, b1, b2 []model.PetInfo, fn func(model.Fight
|
||||
// fmt.Println("NewFight", p1.GetInfo().UserID)
|
||||
f := &FightC{}
|
||||
f.ownerID = p1.GetInfo().UserID
|
||||
f.OurPlayers = []common.PlayerI{p1}
|
||||
f.OppPlayers = []common.PlayerI{p2}
|
||||
|
||||
f.Switch = make(map[uint32]*action.ActiveSwitchAction)
|
||||
f.callback = fn //战斗结束的回调
|
||||
@@ -33,20 +35,22 @@ func NewFight(p1, p2 common.PlayerI, b1, b2 []model.PetInfo, fn func(model.Fight
|
||||
f.ReadyInfo.Status = f.Info.Status
|
||||
|
||||
var err errorcode.ErrorCode
|
||||
f.Our, err = f.initplayer(p1, b1)
|
||||
our, err := f.initplayer(p1, b1)
|
||||
if err > 0 {
|
||||
return nil, err
|
||||
|
||||
}
|
||||
f.Our = []*input.Input{our}
|
||||
|
||||
f.Opp, err = f.initplayer(p2, b2)
|
||||
opp, err := f.initplayer(p2, b2)
|
||||
if err > 0 {
|
||||
return nil, err
|
||||
|
||||
}
|
||||
f.Opp = []*input.Input{opp}
|
||||
|
||||
f.ReadyInfo.OurInfo, f.ReadyInfo.OurPetList = initfightready(f.Our)
|
||||
f.ReadyInfo.OpponentInfo, f.ReadyInfo.OpponentPetList = initfightready(f.Opp)
|
||||
f.ReadyInfo.OurInfo, f.ReadyInfo.OurPetList = initfightready(f.Our[0])
|
||||
f.ReadyInfo.OpponentInfo, f.ReadyInfo.OpponentPetList = initfightready(f.Opp[0])
|
||||
var loadtime time.Duration = 120 * time.Second
|
||||
//说明是PVE
|
||||
|
||||
@@ -57,16 +61,16 @@ func NewFight(p1, p2 common.PlayerI, b1, b2 []model.PetInfo, fn func(model.Fight
|
||||
f.FightStartOutboundInfo = f.buildFightStartInfo()
|
||||
if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC {
|
||||
|
||||
f.Opp.Finished = true //PVE 默认boss数据直接加载完成
|
||||
f.Opp[0].Finished = true //PVE 默认boss数据直接加载完成
|
||||
loadtime = 60 * time.Second
|
||||
//f.handleNPCFightSpecial(&fightStartInfo)
|
||||
|
||||
if f.Opp.Player.(*player.AI_player).CanCapture > 0 {
|
||||
f.Opp.CanCapture = f.Opp.Player.(*player.AI_player).CanCapture
|
||||
if f.Opp[0].Player.(*player.AI_player).CanCapture > 0 {
|
||||
f.Opp[0].CanCapture = f.Opp[0].Player.(*player.AI_player).CanCapture
|
||||
f.FightStartOutboundInfo.Info2.Catchable = 1 //可以捕捉就置1
|
||||
}
|
||||
f.Opp.AttackValue.Prop = f.Opp.Player.(*player.AI_player).Prop
|
||||
f.FightStartOutboundInfo.Info2.Prop = f.Opp.AttackValue.Prop
|
||||
f.Opp[0].AttackValue.Prop = f.Opp[0].Player.(*player.AI_player).Prop
|
||||
f.FightStartOutboundInfo.Info2.Prop = f.Opp[0].AttackValue.Prop
|
||||
}
|
||||
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
@@ -79,14 +83,14 @@ func NewFight(p1, p2 common.PlayerI, b1, b2 []model.PetInfo, fn func(model.Fight
|
||||
|
||||
cool.Cron.AfterFunc(loadtime, func() {
|
||||
//fmt.Println(f.Our.UserID, "战斗超时结算")
|
||||
if !f.Our.Finished || !f.Opp.Finished { //如果有任一没有加载完成
|
||||
if !f.Our[0].Finished || !f.Opp[0].Finished { //如果有任一没有加载完成
|
||||
f.closefight = true //阻止继续添加action
|
||||
f.Reason = model.BattleOverReason.PlayerOffline
|
||||
switch {
|
||||
case !f.Opp.Finished: //邀请方没加载完成 先判断邀请方,如果都没加载完成,就算做房主胜利
|
||||
f.WinnerId = f.Our.Player.GetInfo().UserID
|
||||
case !f.Our.Finished: //被邀请方没加载完成
|
||||
f.WinnerId = f.Opp.Player.GetInfo().UserID
|
||||
case !f.Opp[0].Finished: //邀请方没加载完成 先判断邀请方,如果都没加载完成,就算做房主胜利
|
||||
f.WinnerId = f.Our[0].Player.GetInfo().UserID
|
||||
case !f.Our[0].Finished: //被邀请方没加载完成
|
||||
f.WinnerId = f.Opp[0].Player.GetInfo().UserID
|
||||
}
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
//todo 将血量和技能pp传回enterturn
|
||||
|
||||
Reference in New Issue
Block a user