diff --git a/modules/library/api_usegift.go b/modules/library/api_usegift.go index fdf9557d2..470d2c854 100644 --- a/modules/library/api_usegift.go +++ b/modules/library/api_usegift.go @@ -56,13 +56,13 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe code = pb.ErrorCode_LibraryGiveMaxCount return } - last := 1 - for iPos, v := range c { - for ; last <= iPos; last++ { + var last int32 = 1 + for _, v := range c { + for ; last <= v.K; last++ { attenuation[int32(last)] = v.V // 3,1000|6,500|9,250 } } - for i := _heroObj.Givecount; i <= _heroObj.Givecount+req.Counts; i++ { + for i := _heroObj.Givecount + 1; i <= _heroObj.Givecount+req.Counts; i++ { addExp += attenuation[i] } @@ -106,9 +106,8 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe code = pb.ErrorCode_ConfigNoFound return } - // 100*1 + 100*0.5 + 100*0.25 - addExp *= itemConf.SpecialType / 1000 - _heroObj.Favorexp += addExp + addExp *= itemConf.SpecialType + _heroObj.Favorexp += addExp / 1000 // 折算出等级 for { @@ -116,8 +115,8 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe _heroObj.Favorexp = 0 break } - if _exp[_heroObj.Favorlv] <= _heroObj.Favorexp { - _heroObj.Favorexp -= _exp[_heroObj.Favorlv] + if _exp[_heroObj.Favorlv-1] <= _heroObj.Favorexp { + _heroObj.Favorexp -= _exp[_heroObj.Favorlv-1] _heroObj.Favorlv += 1 upLv++ } else {