219 lines
6.5 KiB
Go
219 lines
6.5 KiB
Go
package logic
|
|
|
|
//type PlayerArena struct {
|
|
// Season uint32 `bson:"season"`
|
|
// Score int32 `bson:"score"`
|
|
// Matches []uint64 `bson:"matches"`
|
|
//
|
|
// Records []*PlayerArenaBattleRecord `bson:"records"`
|
|
//}
|
|
//
|
|
//func (this *PlayerArena) Matched(playerId uint64) bool {
|
|
// for i := range this.Matches {
|
|
// if playerId == this.Matches[i] {
|
|
// return true
|
|
// }
|
|
// }
|
|
// return false
|
|
//}
|
|
//
|
|
//func (this *Player) checkArenaEnter() {
|
|
// var copyArenaTable = this.manager.tables.CopyArena.Get(1)
|
|
// if copyArenaTable == nil {
|
|
// return
|
|
// }
|
|
//
|
|
// var season = this.manager.arenaManager.CopyArenaSeason()
|
|
// if season == nil {
|
|
// return
|
|
// }
|
|
//
|
|
// this.EnterArena(season, copyArenaTable)
|
|
//}
|
|
//
|
|
//func (this *Player) EnterArena(season *CopyArenaSeason, copyArenaTable *data.CopyArena) {
|
|
// if this.Arena != nil && this.Arena.Season == season.Season {
|
|
// return
|
|
// }
|
|
//
|
|
// if this.CheckFunctionOpen(29000, 29002) != nil {
|
|
// return
|
|
// }
|
|
//
|
|
// if this.Arena == nil {
|
|
// this.Arena = &PlayerArena{}
|
|
// }
|
|
//
|
|
// var score = int32(copyArenaTable.InitialIntegral)
|
|
//
|
|
// season.SavePlayer(this, uint32(copyArenaTable.Id), 0, 0, score)
|
|
//
|
|
// this.Arena.Season = season.Season
|
|
// this.Arena.Score = score
|
|
// this.Arena.Matches = season.Matches(this, uint32(copyArenaTable.Id), 4, nil)
|
|
//
|
|
// this.SaveField("arena", this.Arena)
|
|
//}
|
|
//
|
|
//func calcArenaScore(win bool, baseScore, myScore, enemyScore int32) int32 {
|
|
// baseScore = int32(math.Abs(float64(baseScore)))
|
|
// if win {
|
|
// return baseScore + int32((float64(enemyScore)/float64(myScore)-1.0)*30.0)
|
|
// } else {
|
|
// return -(baseScore - int32((float64(enemyScore)/float64(myScore)-1.0)*30.0))
|
|
// }
|
|
//}
|
|
//
|
|
//func (this *Player) PassedCopyArena(copyArenaTable *data.CopyArena, victorious bool, enemyPlayer *RankingPlayer) (int32, int32) {
|
|
// if this.Arena == nil {
|
|
// return 0, 0
|
|
// }
|
|
//
|
|
// var season = this.manager.arenaManager.CopyArenaSeason()
|
|
// if season == nil {
|
|
// return 0, 0
|
|
// }
|
|
//
|
|
// var myMaxScore = this.Arena.Score
|
|
// var enemyMaxScore = int32(copyArenaTable.InitialIntegral)
|
|
// if score, ok := enemyPlayer.Scores[uint32(copyArenaTable.Id)]; ok {
|
|
// enemyMaxScore = score.MaxScore
|
|
// }
|
|
//
|
|
// var myScore = calcArenaScore(victorious, int32(util.If(victorious, copyArenaTable.VictoryIntegral, copyArenaTable.FailureIntegral)), myMaxScore, enemyMaxScore)
|
|
// var enemyScore = calcArenaScore(!victorious, int32(util.If(!victorious, copyArenaTable.VictoryIntegral, copyArenaTable.FailureIntegral)), enemyMaxScore, myMaxScore)
|
|
//
|
|
// this.Arena.Score += myScore
|
|
// this.SaveField("arena.score", this.Arena.Score)
|
|
//
|
|
// this.ArenaBattleRecord(true, myScore, enemyPlayer)
|
|
//
|
|
// season.SavePlayer(this, uint32(copyArenaTable.Id), 0, 0, this.Arena.Score)
|
|
//
|
|
// //If not robot
|
|
// if enemyPlayer.PlayerId > 999999999 {
|
|
// season.DefendRecord(enemyPlayer.PlayerId, enemyScore, &RankingPlayer{PlayerId: this.PlayerId, Name: this.Role.Name, Avatar: this.Role.Avatar})
|
|
// }
|
|
//
|
|
// this.Arena.Matches = season.Matches(this, uint32(copyArenaTable.Id), 4, this.Arena.Matches)
|
|
// this.SaveField("arena.matches", this.Arena.Matches)
|
|
//
|
|
// _ = this.Send(proto.ModIdLevel, proto.MsgIdCopyArenaStatus, this.BuildMsgCopyArenaStatusAck())
|
|
//
|
|
// return myScore, enemyScore
|
|
//}
|
|
//
|
|
//func (this *Player) ArenaBattleRecord(attack bool, score int32, enemyPlayer *RankingPlayer) {
|
|
// this.Arena.Records = append(this.Arena.Records, &PlayerArenaBattleRecord{
|
|
// Attack: attack,
|
|
// PlayerId: enemyPlayer.PlayerId,
|
|
// Name: enemyPlayer.Name,
|
|
// Avatar: enemyPlayer.Avatar,
|
|
// Score: score,
|
|
// })
|
|
//
|
|
// if len(this.Arena.Records) < 20 {
|
|
// this.Arena.Records = this.Arena.Records[1:]
|
|
// }
|
|
//
|
|
// this.SaveField("arena.records", this.Arena.Records)
|
|
//}
|
|
//
|
|
//func (this *Player) BuildMsgCopyArenaStatusAck() *proto.MsgCopyArenaStatusAck {
|
|
// var season = this.manager.arenaManager.CopyArenaSeason()
|
|
// if season == nil {
|
|
// return &proto.MsgCopyArenaStatusAck{}
|
|
// }
|
|
//
|
|
// var copyArenaTable = this.manager.tables.CopyArena.Get(1)
|
|
// if copyArenaTable == nil {
|
|
// return &proto.MsgCopyArenaStatusAck{}
|
|
// }
|
|
//
|
|
// var arenaPlayer = season.GetPlayer(this.PlayerId)
|
|
//
|
|
// var copyArenaStatus = &proto.CopyArenaStatus{
|
|
// CopyStatus: proto.CopyStatus{CopyType: uint32(proto.CopyTypeSpeed), IndexId: uint32(copyArenaTable.Id)},
|
|
// BeginTime: season.BeginTime,
|
|
// EndTime: season.EndTime,
|
|
// }
|
|
//
|
|
// if arenaPlayer != nil {
|
|
// var score = arenaPlayer.Scores[copyArenaStatus.IndexId]
|
|
// if score != nil {
|
|
// copyArenaStatus.MaxScore = score.MaxScore
|
|
// copyArenaStatus.RankIndex = score.RankIndex
|
|
// }
|
|
// }
|
|
//
|
|
// return &proto.MsgCopyArenaStatusAck{CopyArenaStatus: copyArenaStatus}
|
|
//}
|
|
//
|
|
//func (this *Player) BuildMsgCopyArenaRankListAck(copyId uint32) *proto.MsgCopyArenaRankListAck {
|
|
// var myRank = &proto.ArenaPlayer{
|
|
// PlayerId: this.PlayerId,
|
|
// IsRobot: false,
|
|
// Name: this.Role.Name,
|
|
// Avatar: this.Role.Avatar,
|
|
// Capacity: this.RigAttrsCapacity(),
|
|
// }
|
|
//
|
|
// var copoment *PlayerRigComponent
|
|
// copoment = this.RigComponent[this.Rig.Head]
|
|
// if copoment != nil {
|
|
// myRank.RigHead = copoment.Id
|
|
// }
|
|
//
|
|
// copoment = this.RigComponent[this.Rig.Body]
|
|
// if copoment != nil {
|
|
// myRank.RigBody = copoment.Id
|
|
// }
|
|
//
|
|
// copoment = this.RigComponent[this.Rig.Tail]
|
|
// if copoment != nil {
|
|
// myRank.RigTail = copoment.Id
|
|
// }
|
|
//
|
|
// var season = this.manager.arenaManager.CopyArenaSeason()
|
|
// if season == nil {
|
|
// return &proto.MsgCopyArenaRankListAck{MyRank: myRank}
|
|
// }
|
|
//
|
|
// var score *RankingScore
|
|
// var rankingPlayer = season.GetPlayer(this.PlayerId)
|
|
// if rankingPlayer != nil {
|
|
// score = rankingPlayer.Scores[copyId]
|
|
// }
|
|
//
|
|
// if score != nil {
|
|
// myRank.CopyId = score.CopyId
|
|
// myRank.Duration = score.Duration
|
|
// myRank.MaxDepth = score.MaxDepth
|
|
// myRank.MaxScore = score.MaxScore
|
|
// myRank.RankIndex = score.RankIndex
|
|
// }
|
|
//
|
|
// var rankList []*proto.ArenaPlayer
|
|
// for _, rank := range season.GetRanking(copyId, 50) {
|
|
// if rank.player.PlayerId == this.PlayerId {
|
|
// rankList = append(rankList, myRank)
|
|
// } else {
|
|
// rankList = append(rankList, &proto.ArenaPlayer{
|
|
// PlayerId: rank.player.PlayerId,
|
|
// IsRobot: rank.player.PlayerId < 1000000000,
|
|
// Name: rank.player.Name,
|
|
// Avatar: rank.player.Avatar,
|
|
// Capacity: rank.player.Capacity,
|
|
// RigHead: rank.player.RigHead,
|
|
// RigBody: rank.player.RigBody,
|
|
// RigTail: rank.player.RigTail,
|
|
// CopyId: rank.score.CopyId,
|
|
// MaxScore: rank.score.MaxScore,
|
|
// RankIndex: rank.score.RankIndex,
|
|
// })
|
|
// }
|
|
// }
|
|
//
|
|
// return &proto.MsgCopyArenaRankListAck{MyRank: myRank, RankList: rankList}
|
|
//}
|