Search Unity

Re: Determining a string representation from a calculated range of scores

Discussion in 'Game Design' started by AaronWood1981, Sep 15, 2020.

  1. AaronWood1981

    AaronWood1981

    Joined:
    Oct 22, 2018
    Posts:
    1
    Hello,

    I was hoping someone might have some insights towards a better design for this use case.
    In my game I am determining the hero's title based on their current score in the game.

    A common example would be a personality quiz, or any academic test where you answer a series of questisons and it calculates a score at the end and gives you some sort of rating.

    Score, Grade (string)
    100-90 A+
    89-85 A
    84-80 A
    etc...

    Obviously I can implement this with a simple if block, and I have, but it doesn't seem like a very elegant or versatile solution if I wish to include more titles in the future, or change the range of scores which yield a certain title.

    I'm sure this isn't a difficult problem, I just can't think of a better way. Ultimately I want to become a better programmer and thought some others might have some insights here.

    Thanks in advance
     
  2. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    More a scripting question than a Game Design question.

    What is inelegant or not versatile about it? What behavior would you prefer it to have that a simple "if block" or switch would not?
     
  3. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    How many axes of information do you want? I'd think about implementing it as a table.

    Eg: If you had "Good / Evil" on one axis and "Power" on another, then you could look up names for "good weak people" and "evil weak people" and "neutral experienced people" and "powerful good people".

    You could potentially then have different tables for different classes. Eg: A good, powerful fighter = a paladin. An evil, weak fighter is a bandit. A good, powerful magic user is a "sage", and so on.
     
    Martin_H likes this.