diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index e3ddf538..9cbfbad8 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -101,12 +101,9 @@ func (f *FightC) initplayer(c common.PlayerI, opp bool) bool { } temp := input.NewInput(f, c) temp.AllPet = make([]*info.BattlePetEntity, 0) - + temp.InitAttackValue() for i := 0; i < len(c.GetInfo().PetList); i++ { - if f.Info.MAXPET == 0 || i < int(f.Info.MAXPET) { - - temp.AllPet = append(temp.AllPet, info.CreateBattlePetEntity(&c.GetInfo().PetList[i], f.rand)) - } + temp.AllPet = append(temp.AllPet, info.CreateBattlePetEntity(&c.GetInfo().PetList[i], f.rand)) } @@ -123,6 +120,12 @@ func (f *FightC) initplayer(c common.PlayerI, opp bool) bool { // 同类型(都>0或都=0)保持原有顺序 return i < j }) + + switch f.Info.Mode { + case info.BattleMode.SINGLE_MODE: + temp.AllPet = temp.AllPet[:1] + default: + } if opp { f.Opp = temp //这里是对方的 copier.Copy(&f.Info.OpponentInfo, f.Opp.Player.GetInfo()) @@ -165,11 +168,7 @@ func NewFight(mode, status info.EnumBattleMode, p1 common.PlayerI, p2 common.Pla f.ownerID = p1.GetInfo().UserID f.Info.Status = status //房主 f.Info.Mode = mode - switch mode { - case info.BattleMode.SINGLE_MODE: - f.Info.MAXPET = 1 - default: - } + f.StartTime = time.Now() seed := f.StartTime.UnixNano() ^ int64(p1.GetInfo().UserID) ^ int64(p2.GetInfo().UserID) // ^ int64(f.Round) // 用异或运算混合多维度信息 f.rand = rand.New(rand.NewSource(seed)) @@ -526,8 +525,8 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { f.First, f.Second = f.Our, f.Opp } - f.First.InitAttackValue() - f.Second.InitAttackValue() + f.First.ResetAttackValue() + f.Second.ResetAttackValue() switch { case sattack != nil: diff --git a/logic/service/fight/info/info.go b/logic/service/fight/info/info.go index 25881655..7bd1ed25 100644 --- a/logic/service/fight/info/info.go +++ b/logic/service/fight/info/info.go @@ -99,14 +99,15 @@ func NewAttackValue(userid uint32) *AttackValue { // AttackValue 战斗中的攻击数值信息 type AttackValue struct { - UserID uint32 `json:"userId" fieldDescription:"玩家的米米号 与野怪对战userid = 0"` - SkillID uint32 `json:"skillId" fieldDescription:"使用技能的id"` - AttackTime uint32 `json:"attackTime" fieldDescription:"是否击中 如果为0 则miss 如果为1 则击中,2为必中"` - LostHp uint32 `json:"lostHp" fieldDescription:"我方造成的伤害"` - GainHp int32 `json:"gainHp" fieldDescription:"我方获得血量"` - RemainHp int32 `json:"remainHp" fieldDescription:"我方剩余血量"` - MaxHp uint32 `json:"maxHp" fieldDescription:"我方最大血量"` - State uint32 `json:"state" fieldDescription:"固定值0 需要后续测试"` + UserID uint32 `json:"userId" fieldDescription:"玩家的米米号 与野怪对战userid = 0"` + SkillID uint32 `json:"skillId" fieldDescription:"使用技能的id"` + AttackTime uint32 `json:"attackTime" fieldDescription:"是否击中 如果为0 则miss 如果为1 则击中,2为必中"` + LostHp uint32 `json:"lostHp" fieldDescription:"我方造成的伤害"` + GainHp int32 `json:"gainHp" fieldDescription:"我方获得血量"` + RemainHp int32 `json:"remainHp" fieldDescription:"我方剩余血量"` + MaxHp uint32 `json:"maxHp" fieldDescription:"我方最大血量"` + //颜色 + State uint32 `json:"state" ` SkillListLen uint32 `struc:"sizeof=SkillList"` SkillList []model.SkillInfo `json:"skillList" fieldDescription:"根据精灵的数据插入技能 最多4条 不定长"` IsCritical uint32 `json:"isCritical" fieldDescription:"是否暴击"` @@ -198,7 +199,7 @@ type FightUserInfo struct { // NoteReadyToFightInfo 战斗准备就绪消息结构体,NoteReadyToFightInfo type NoteReadyToFightInfo struct { - MAXPET uint32 `struc:"skip"` // 最大精灵数 struc:"skip"` + //MAXPET uint32 `struc:"skip"` // 最大精灵数 struc:"skip"` // 战斗类型ID(与野怪战斗为3,与人战斗为1,前端似乎未使用) // @UInt long Status EnumBattleMode `fieldDesc:"战斗类型ID 但前端好像没有用到 与野怪战斗为3,与人战斗似乎是1" ` diff --git a/logic/service/fight/input/input.go b/logic/service/fight/input/input.go index fb8a9d87..22322c0e 100644 --- a/logic/service/fight/input/input.go +++ b/logic/service/fight/input/input.go @@ -54,21 +54,15 @@ func (i *Input) GetPetInfo() *info.BattlePetEntity { return i.CurrentPet +} +func (i *Input) ResetAttackValue() { + i.AttackValue.SkillID = 0 + } // 这个每回合都会调用 func (i *Input) InitAttackValue() { - var old *info.AttackValue - if i.AttackValue != nil { - old = i.AttackValue - - } i.AttackValue = info.NewAttackValue(i.Player.GetInfo().UserID) - if old != nil { - i.AttackValue.Prop = old.Prop - i.AttackValue.Status = old.Status - i.AttackValue.SkillList = old.SkillList - } } func (i *Input) GetPet(id uint32) (ii *info.BattlePetEntity, Reason info.ChangePetInfo) {