Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8990643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:32:38+00:00 2026-06-15T22:32:38+00:00

I have to make a function that returns the spells a character has. So

  • 0

I have to make a function that returns the spells a character has.

So I have 3 parameters: a level (an int from 1-50), an enum representing a character class (only 8 classes) and an enum representing a race (3-4 races).

This function has to return an array with spell IDs. The higher the level, the more spells a character has.

What I did so far is hard-coded everything, but when I have to modify something it is a mess. I don’t know what kind of data-structure best suits my needs without recurring to horrible ifs that are hard to change/mantain.

Also, the language is C# and I am using Xna/.NET 4.0

Update

public static int[] ListOfSpells(int level, CharacterClass chClass, CharacterRace chRace)
{
    switch (chClass)
    {
        case CharacterClass.Mage:
            return new int[] { 1, 2, 3 };
        case CharacterClass.Knight:
            return new int[] { 2, 5, 6 };
        case CharacterClass.Paladin:
            return new int[] { 3, 5, 6, 2 };
        default:
            return new int[] { };
    }
}
 
// classes
 
public enum CharacterClass : short
{
    Mage = 0x00,
    Warlock,
    Priest,
 
    Monk,
    Knight,
    Assassin,
 
    Paladin,
    Hunter,
    Warrior
}
 
// races
 
public enum CharacterRace : short
{
    Human = 0x00,
    Elf
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:32:39+00:00Added an answer on June 15, 2026 at 10:32 pm

    A database if definitly what you need. You can maybe make it works with IEnumerable/Array now, but database will gave you the flexibility that you want for the future of your game.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

gcc 4.4.2 c89 I have a function that has to run (config_relays). It make
I am trying to make a user defined function that returns nothing. I have
I have a class MyClass in which there is one function that returns a
I have a function that returns a struct that has two fields, :key :event.
I have a function that returns a float from 0 to 255. I would
I have been fruitlessly trying for several hours to make a function that filter
I have a javascript function that calls a generic function to make an ajax
I have: void add_all_msgs(std::deque<Message>::iterator &iter); How can I make that function generic, so it
I have a PHP function that I want to make available publically on the
I have an application that I make a call to a DLL function that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.