From e5a4a2621a095974529c863b66ffb7812aaf8d8d Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 1 Feb 2024 10:25:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=AB=9E=E6=8A=80=E5=9C=BA?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E9=A2=84=E6=89=A3=20=E4=B8=BA=E8=B4=9F?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/arena/api_challenge.go | 1 + modules/arena/modelarena.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/arena/api_challenge.go b/modules/arena/api_challenge.go index 10fb27c5e..cfdc6018a 100644 --- a/modules/arena/api_challenge.go +++ b/modules/arena/api_challenge.go @@ -141,6 +141,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.ArenaChallenge Integral: red.Integral, Dan: red.Dan, } + this.module.modelArena.integralCompute(redplay, &pb.ArenaPlayer{ Uinfo: bule.Uinfo, Integral: bule.Integral, diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index bce910625..eb4220d88 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -410,14 +410,23 @@ func (this *modelArena) integralCompute(red, bule *pb.ArenaPlayer, iswin bool) { if iswin { red.Changeintegral = int32(float64(redactive.KValue) * float64(1-1/float32(1+math.Pow(10, float64(float64(bule.Integral-red.Integral)/400))))) bule.Changeintegral = int32(float64(buleactive.KValue) * float64(0-1/float64(1+math.Pow(10, float64(float64(red.Integral-bule.Integral))/400)))) - red.Integral = red.Integral + red.Changeintegral - bule.Integral = bule.Integral + bule.Changeintegral } else { red.Changeintegral = int32(float64(redactive.KValue) * float64(0-1/float64(1+math.Pow(10, float64(float64(bule.Integral-red.Integral)/400))))) bule.Changeintegral = int32(float64(redactive.KValue) * float64(1-1/float64(1+math.Pow(10, float64(float64(red.Integral-bule.Integral)/400))))) + } + if red.Integral+red.Changeintegral < 0 { + red.Changeintegral = -red.Integral + red.Integral = 0 + } else { red.Integral = red.Integral + red.Changeintegral + } + if bule.Integral+bule.Changeintegral < 0 { + bule.Changeintegral = -bule.Integral + bule.Integral = 0 + } else { bule.Integral = bule.Integral + bule.Changeintegral } + } func (this *modelArena) recoverTicket(session comm.IUserSession, info *pb.DBArenaUser) {