F
F
fuckingfamouscoder2020-04-23 16:01:02
Python
fuckingfamouscoder, 2020-04-23 16:01:02

How to make a system of levels and experience with a formula, a task in the header?

Good afternoon, Khabarovsk citizens!
The customer provided the following level system:

system
1 - 10 уровни (1ед опыта = 1 уровень)
11-20 уровни (2ед опыта = 1 уровень)
21-30 уровни (3.5ед опыта = 1 уровень)
31-40 уровни (5ед опыта = 1 уровень)
41-50 уровни (5.5ед опыта = 1 уровень)
51-60 уровни (6.5ед опыта = 1 уровень)
61-70 уровни (7ед опыта = 1 уровень)
71-100 уровень (10ед опыта = 1 уровень)

Experience is given as mini-games, and the function for checking the level and writing to the database when you click on the Profile button, help me make a level system, it looks like this for me now. But from level 21-30, I started to get wildly confused, I can’t calculate the formula :(
Explvl is parsed from the database earlier
def chklvl():
    if explvl <= 10:
        lvl = int(explvl)
        *запись в бд обновлённого уровня*
  
    elif explvl >10 and <= 30
        lvl = (explvl + 10) // 2
        *запись в бд обновлённого уровня*

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Morph34, 2020-04-23
@Morph34

if 0<explvl<=10:
   lvl=explvl
elif 10<explvl<=30:
   lvl=10+(explvl-10)//2
elif 30<explvl<=65:
    lvl=20+(explvl-30)//3.5
elif 65<explvl<=115:
    lvl=30+(explvl-65)//5
elif 115<explvl<=170:
    lvl=40+(explvl-115)//5.5

And so on...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question