78 lines
1.7 KiB
Go
78 lines
1.7 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
|
|
"blazing/logic/service/common"
|
|
"blazing/logic/service/fight"
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/player"
|
|
)
|
|
|
|
//大乱斗
|
|
|
|
func (h Controller) PetMelee(data *fight.StartPetWarInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
c.Fightinfo.Mode = info.BattleMode.PET_MELEE
|
|
c.Fightinfo.Status = info.BattleMode.PET_MELEE
|
|
|
|
err = c.JoinFight(func(p common.PlayerI) bool {
|
|
_, err = fight.NewFight(p, c, func(foi info.FightOverInfo) {
|
|
if foi.Reason == 0 { //我放获胜
|
|
|
|
if foi.WinnerId == c.GetInfo().UserID {
|
|
c.Info.MessWin += 1
|
|
c.MessWin(true)
|
|
p.MessWin(false)
|
|
|
|
} else {
|
|
p.GetInfo().MessWin += 1
|
|
p.MessWin(true)
|
|
c.MessWin(false)
|
|
}
|
|
|
|
}
|
|
if foi.Reason == info.BattleOverReason.PlayerOffline {
|
|
if foi.WinnerId == c.GetInfo().UserID {
|
|
|
|
p.MessWin(false)
|
|
|
|
} else {
|
|
|
|
c.MessWin(false)
|
|
}
|
|
}
|
|
|
|
}) ///开始对战,房主方以及被邀请方
|
|
return err <= 0
|
|
})
|
|
|
|
return
|
|
}
|
|
func (h Controller) PetKing(data *fight.PetKingJoinInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
c.Fightinfo.Status = info.BattleMode.PET_TOPLEVEL
|
|
|
|
switch data.Type {
|
|
case 5:
|
|
c.Fightinfo.Mode = info.BattleMode.SINGLE_MODE
|
|
case 6:
|
|
c.Fightinfo.Mode = info.BattleMode.MULTI_MODE
|
|
}
|
|
err = c.JoinFight(func(p common.PlayerI) bool {
|
|
_, err = fight.NewFight(p, c, func(foi info.FightOverInfo) {
|
|
if foi.Reason == 0 { //我放获胜
|
|
if foi.WinnerId == c.GetInfo().UserID {
|
|
c.Info.MonKingWin += 1
|
|
} else {
|
|
p.GetInfo().MonKingWin += 1
|
|
}
|
|
|
|
}
|
|
}) ///开始对战,房主方以及被邀请方
|
|
return err <= 0
|
|
})
|
|
|
|
return
|
|
}
|