49 lines
1005 B
Go
49 lines
1005 B
Go
![]() |
package logic
|
||
|
|
||
|
import (
|
||
|
"ecs/proto/pb"
|
||
|
"ecs/servers/game/data"
|
||
|
"math/rand/v2"
|
||
|
)
|
||
|
|
||
|
func (this *Player) EnterBattle(sceneTable *data.Scene) {
|
||
|
this.Temp.Fighting = true
|
||
|
this.Temp.RandSeed = rand.Int64()
|
||
|
|
||
|
this.copyBattle(sceneTable)
|
||
|
this.enterScene(uint32(sceneTable.Id))
|
||
|
}
|
||
|
|
||
|
func (this *Player) EndBattle() {
|
||
|
this.Temp.Fighting = false
|
||
|
this.Temp.RandSeed = 0
|
||
|
this.enterScene(1)
|
||
|
}
|
||
|
|
||
|
func (this *Player) copyBattle(sceneTable *data.Scene) {
|
||
|
var ack, err = this.virtualBattle(sceneTable)
|
||
|
if err != nil {
|
||
|
_ = this.TipNotice(err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if ack.Result {
|
||
|
this.PassedCopy(sceneTable, ack.Score)
|
||
|
}
|
||
|
|
||
|
_ = this.Send(uint16(pb.ModId_ModuleBattle), uint16(pb.MsgId_ModBattleEnter), ack)
|
||
|
}
|
||
|
|
||
|
func (this *Player) virtualBattle(sceneTable *data.Scene) (*pb.BattleEnterAck, error) {
|
||
|
return &pb.BattleEnterAck{
|
||
|
SceneId: uint32(sceneTable.Id),
|
||
|
Result: false,
|
||
|
Score: 0,
|
||
|
Heroes: nil,
|
||
|
Enemies: nil,
|
||
|
BattleRounds: 0,
|
||
|
RoundList: nil,
|
||
|
RewardList: nil,
|
||
|
}, nil
|
||
|
}
|