diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index aa23da666..845a4f269 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -129,10 +129,9 @@ func (this *Room) AiOperator() { if this.NexPower != this.curPower { this.round++ } - for _, v := range szMap { // - if v.CurEnergy > 0 { - this.player2.Energy += v.CurEnergy - } + + if len(szMap) > 0 { + this.player2.Energy += szMap[len(szMap)-1].CurEnergy } if bAddPs { @@ -317,13 +316,11 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr } this.player1.Ps = MaxPs } - for _, v := range szMap { // - if v.CurEnergy > 0 { - if color == 1 { - this.player1.Energy += v.CurEnergy - } else { - this.player2.Energy += v.CurEnergy - } + if len(szMap) > 0 { + if color == 1 { + this.player1.Energy += szMap[len(szMap)-1].CurEnergy + } else { + this.player2.Energy += szMap[len(szMap)-1].CurEnergy } } if this.player1.Ps <= 0 { // 权限给下一个人