#Nested Hash maps( multiple questions)

8 messages · Page 1 of 1 (latest)

forest wagon
#

Hi! I'm making a small game for fun, and in order to create the character - I need to let the player choose proficiencies for skills. The problems -

  • I am going for nested hash maps because it seems to be the best for my purpose. I can't figure out how many nests i need. So, skills are divided by job - so an antiquitarian has appraisal and a craft specialty. And within each skill I have 3 values (a full score, half score, and a fifth score). I say again, I'm unsure whether it's a map in a map, or if its 3.
  • Are you allowed to make maps by initializing only the key but not the values? Because I need user input for the values.
    Thanks!
midnight caveBOT
#

This post has been reserved for your question.

Hey @forest wagon! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

round valve
#

wouldnt that be a oop problem? why the hash maps?
maps can be effectively initialized without a value by setting the value to null (pretty sure that's the default anyways)

from what i see something like the code bellow will let you get a list of avaliable skills related to each class. could change the "Skill" enum to a interface for more control. "CharacterClass" could be a 'abstract class' instead of a enum too. would all depend on your exact combat system

public enum Skill{
    smack

    SkillLevel skillLevel; //enum or what ever
    //...
}

public enum CharacterClass{
    catSlayer{...}

    EnumSet<Skill> skills;
    
    private CharacterClass(Skill... skills){
      this.skills = new EnumSet<Skill>(List.of(skills)); //some thing like this
    }
    //...
    
}

abstract class Character{
    var classes = new CharacterClass[2];//dual classes at most
}
forest wagon
#

I tried implementing OOP into this but got tired(ik, I shoulda tried but it gave me way too many headaches).
I don’t really know what abstract classes or enums are, sorry

forest wagon
#

Chocolate emoji?(confused)

round valve
#

idk what to say aside from oop is the solution. i suggest you just go ahead and try to do without it but keep a open mind and look into it, eventually you'll either understand oop or get frustrated enough trying to go without it that your end up reinventing oop. either way you learn it.

forest wagon
#

Understood! So, should I make the player character an object?