124 lines
3.1 KiB
Go
124 lines
3.1 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/modules/config/service"
|
|
"blazing/modules/player/model"
|
|
|
|
"blazing/logic/service/common"
|
|
"blazing/logic/service/fight"
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/player"
|
|
)
|
|
|
|
//大乱斗
|
|
|
|
func (h Controller) PetMelee(data *StartPetWarInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
c.Fightinfo.Mode = info.BattleMode.PET_MELEE
|
|
c.Fightinfo.Status = info.BattleMode.PET_MELEE
|
|
var mepet []model.PetInfo
|
|
|
|
for i, v := range service.NewMELEEService().Def() {
|
|
|
|
if v.Lv == 0 {
|
|
v.Lv = 100
|
|
|
|
}
|
|
|
|
pet := model.GenPetInfo(int(v.MonID), 24, int(v.Nature), int(v.Effect[0]), int(v.Lv), nil, 0)
|
|
|
|
pet.ConfigBoss(v)
|
|
pet.CatchTime = c.GetInfo().UserID + uint32(i)*1000000
|
|
pet.Cure()
|
|
mepet = append(mepet, *pet)
|
|
|
|
}
|
|
if len(mepet) < 6 {
|
|
return nil, errorcode.ErrorCodes.ErrSystemError
|
|
}
|
|
err = c.JoinFight(func(p common.PlayerI) bool {
|
|
_, err = fight.NewFight(p, c, mepet[:3], mepet[3:], func(foi model.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 == model.BattleOverReason.PlayerOffline {
|
|
if foi.WinnerId == c.GetInfo().UserID {
|
|
|
|
p.MessWin(false)
|
|
|
|
} else {
|
|
|
|
c.MessWin(false)
|
|
}
|
|
}
|
|
|
|
}) ///开始对战,房主方以及被邀请方
|
|
return err <= 0
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
// PetKing 处理控制器请求。
|
|
func (h Controller) PetKing(data *PetKingJoinInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
c.Fightinfo.Status = info.BattleMode.PET_TOPLEVEL
|
|
// ElementTypeNumbers 是控制器层共享变量。
|
|
var ElementTypeNumbers = []int{1, 2, 3, 5, 11, 4, 6, 7, 9}
|
|
|
|
switch data.Type {
|
|
case 5:
|
|
c.Fightinfo.Mode = info.BattleMode.SINGLE_MODE
|
|
case 6:
|
|
c.Fightinfo.Mode = info.BattleMode.MULTI_MODE
|
|
case 11:
|
|
//草","水","火","电","战斗","飞行","机械","地面","冰"
|
|
// 按顺序:草、水、火、电、战斗、飞行、机械、地面、冰
|
|
|
|
//println("11", c.GetPetInfo()[0].Type(), ElementTypeNumbers[data.FightType-1])
|
|
if c.GetPetInfo(0)[0].Type() != int(ElementTypeNumbers[data.FightType-1]) {
|
|
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrVictoryConditionNotMet)
|
|
}
|
|
c.Fightinfo.Mode = info.BattleMode.SINGLE_MODE
|
|
c.Fightinfo.FightType = data.FightType
|
|
}
|
|
|
|
err = c.JoinFight(func(p common.PlayerI) bool {
|
|
|
|
_, err = fight.NewFight(p, c, p.GetInfo().PetList, c.GetInfo().PetList, func(foi model.FightOverInfo) {
|
|
if foi.Reason == 0 { //我放获胜
|
|
switch data.Type {
|
|
case 11:
|
|
if foi.WinnerId == c.GetInfo().UserID {
|
|
c.ItemAdd(80000000+int64(ElementTypeNumbers[data.FightType-1]), 1)
|
|
} else {
|
|
p.ItemAdd(80000000+int64(ElementTypeNumbers[data.FightType-1]), 1)
|
|
}
|
|
default:
|
|
if foi.WinnerId == c.GetInfo().UserID {
|
|
c.Info.MonKingWin += 1
|
|
} else {
|
|
p.GetInfo().MonKingWin += 1
|
|
}
|
|
}
|
|
|
|
}
|
|
}) ///开始对战,房主方以及被邀请方
|
|
return err <= 0
|
|
})
|
|
|
|
return
|
|
}
|