refactor: 重构战斗初始化传递宠物列表
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -99,7 +99,7 @@ func (Controller) PlayerFightBoss(data1 *fight.ChallengeBossInboundInfo, p *play
|
||||
|
||||
ai.Prop[0] = 2
|
||||
var fighc *fight.FightC
|
||||
fighc, _ = fight.NewFight(p, ai, func(foi model.FightOverInfo) {
|
||||
fighc, _ = fight.NewFight(p, ai, p.GetPetInfo(100), ai.GetPetInfo(0), func(foi model.FightOverInfo) {
|
||||
if mdata.WinBonusID != 0 {
|
||||
if len(bosinfo[0].Rule) == 0 {
|
||||
if foi.Reason == 0 && foi.WinnerId == p.Info.UserID {
|
||||
@@ -177,7 +177,7 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf
|
||||
p.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC //打野怪
|
||||
p.Fightinfo.Mode = info.BattleMode.MULTI_MODE //多人模式
|
||||
|
||||
fight.NewFight(p, ai, func(foi model.FightOverInfo) {
|
||||
fight.NewFight(p, ai, p.GetPetInfo(100), ai.GetPetInfo(0), func(foi model.FightOverInfo) {
|
||||
//p.Done.Exec(model.MilestoneMode.Moster, []uint32{p.Info.MapID, monsterInfo.PetList[0].ID, uint32(foi.Reason)}, nil)
|
||||
if foi.Reason == 0 && foi.WinnerId == p.Info.UserID && p.CanGet() {
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/modules/config/service"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"blazing/logic/service/common"
|
||||
@@ -16,9 +17,28 @@ func (h Controller) PetMelee(data *fight.StartPetWarInboundInfo, c *player.Playe
|
||||
|
||||
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, func(foi model.FightOverInfo) {
|
||||
_, err = fight.NewFight(p, c, mepet[:3], mepet[3:], func(foi model.FightOverInfo) {
|
||||
if foi.Reason == 0 { //我放获胜
|
||||
|
||||
if foi.WinnerId == c.GetInfo().UserID {
|
||||
@@ -65,14 +85,21 @@ func (h Controller) PetKing(data *fight.PetKingJoinInboundInfo, c *player.Player
|
||||
// 按顺序:草、水、火、电、战斗、飞行、机械、地面、冰
|
||||
|
||||
//println("11", c.GetPetInfo()[0].Type(), ElementTypeNumbers[data.FightType-1])
|
||||
if c.GetPetInfo()[0].Type() != int(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, func(foi model.FightOverInfo) {
|
||||
var u1, u2 []model.PetInfo
|
||||
if c.Fightinfo.Mode == info.BattleMode.SINGLE_MODE {
|
||||
u1, u2 = p.GetInfo().PetList[:1], c.GetInfo().PetList[:1]
|
||||
} else {
|
||||
u1, u2 = p.GetInfo().PetList, c.GetInfo().PetList
|
||||
}
|
||||
_, err = fight.NewFight(p, c, u1, u2, func(foi model.FightOverInfo) {
|
||||
if foi.Reason == 0 { //我放获胜
|
||||
switch data.Type {
|
||||
case 11:
|
||||
|
||||
@@ -55,7 +55,7 @@ func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInbou
|
||||
return
|
||||
}
|
||||
|
||||
_, err = fight.NewFight(v, c, func(foi model.FightOverInfo) {
|
||||
_, err = fight.NewFight(v, c, v.GetPetInfo(100), v.GetPetInfo(100), func(foi model.FightOverInfo) {
|
||||
|
||||
//println("好友对战测试", foi.Reason)
|
||||
|
||||
|
||||
@@ -187,7 +187,9 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
|
||||
}
|
||||
|
||||
ai := player.NewAI_player(monsterInfo)
|
||||
_, err = fight.NewFight(c, ai, func(foi model.FightOverInfo) {
|
||||
|
||||
_, err = fight.NewFight(c, ai, c.GetPetInfo(100), ai.GetPetInfo(0), func(foi model.FightOverInfo) {
|
||||
|
||||
if foi.Reason == 0 && foi.WinnerId == c.Info.UserID { //我放获胜
|
||||
switch data.Head.CMD {
|
||||
case 2429: //试炼之塔
|
||||
|
||||
@@ -67,7 +67,7 @@ func (h Controller) ArenaFightOwner(data1 *fight.ARENA_FIGHT_OWENR, c *player.Pl
|
||||
c.Fightinfo.Mode = info.BattleMode.SINGLE_MODE
|
||||
c.Fightinfo.Status = info.BattleMode.FIGHT_ARENA
|
||||
|
||||
_, err = fight.NewFight(c, c.GetSpace().Owner.ARENA_Player, func(foi model.FightOverInfo) { //我方邀请擂主挑战,我方先手
|
||||
_, err = fight.NewFight(c, c.GetSpace().Owner.ARENA_Player, c.Info.PetList[:1], c.GetSpace().Owner.ARENA_Player.GetInfo().PetList[:1], func(foi model.FightOverInfo) { //我方邀请擂主挑战,我方先手
|
||||
|
||||
if foi.Reason != 0 && foi.WinnerId == c.GetInfo().UserID { //异常退出
|
||||
|
||||
|
||||
Reference in New Issue
Block a user