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 577517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:09:42+00:00 2026-05-13T14:09:42+00:00

I am programming a game as an exercise and I’ve run into a design

  • 0

I am programming a game as an exercise and I’ve run into a design problem. My role playing game will have the typical classes like Fighter, Wizard, Theif, Cleric. How do I design my classes so that players can multi-class? For example, one player might start off as a Fighter (and gain the related skills fighters have), then multi-class to a Wizard (at that point they gain wizard spells), and later on multi-class yet again to a rogue (now gaining all abilities rogues have). So this player is now a Fighter-Wizard-Rogue. I don’t know to represent this in C#.

At first I tried to use the decorator pattern but I’m unable to multi-class multiple times with this. Any pointers on how to design this?

Only thing I can think of is having an IList<CharacterBaseClass> property for each character and adding Fighter, Wizard, Rogue, etc to this as the player multi-classes. So something like this..

class CharacterBaseClass
{
   public IList<CharacterBaseClass> MultiClasses { get; set; }
   // constructors, etc
}

and each time they mutli-class I add to the IList

// player starts off as Fighter
Warrior player1 = new Warrior();

// now multi-class to Wizard
player1.MultiClasses.Add(new Wizard()); 

// now multi-class to Theif
player1.MultiClasses.Add(new Theif());    

I’m sure there must be a better way than this?

  • 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-05-13T14:09:43+00:00Added an answer on May 13, 2026 at 2:09 pm

    With the decorator pattern, you could possibly do it.

    Character person = new Character("Rambo");
    person = new Fighter(person); // decorate him with Fighter skills
    person = new Thief(person);   // also decorate him with Thief skills
    

    Personally I would probably look at attaching classes to the character instead:

    Character person = new Character("Rambo");
    person.AttachClass(new Fighter());
    person.AttachClass(new Thief());
    

    Of course, if you need complex interactions between the classes, so that not only does a Fighter/Thief gets bonuses and skills from each, but he gets something more as well, perhaps the only correct route for that might be to create specific multi-classes for all the combinations:

    Character person = new Character("Rambo");
    person.AttachClass(new FighterThief());
    

    This would of course just explode with all the combinations.

    What about a pure table-driven effort?

    Place all applicable skills, spells, bonuses, effects, etc. in a hunking big table, then define the classes by linking a specific class to the specific items in that table. This way it would be much simpler to create hybrid classes by linking across different base classes.

    To use a decorator pattern and still get proper access to everything, each class (in the programming sense of the word) needs to be implemented properly as a decorator class.

    For instance:

    public class BaseClass
    {
        protected BaseClass(BaseClass underlyingCharacterClass);
        public abstract bool CanCastSpells();
        public abstract List<Spell> GetAvailableSpells();
        protected BaseClass UnderlyingCharacterClass;
    }
    
    public class Wizard : BaseClass
    {
        public override bool CanCastSpells() { return true; }
        public override List<Spell> GetAvailableSpells()
        {
            List<Spell> result = new List<Spell>();
            if (UnderlyingCharacterClass != null)
                result.AddRange(UnderlyingCharacterClass.GetAvailableSpells());
            result.Add(new WizardSpell1());
            ...
            return result;
        }
    }
    
    public class Thief : BaseClass
    {
        public override bool CanCastSpells()
        {
            if (UnderlyingCharacterClass != null)
                return UnderlyingCharacterClass.CanCastSpells();
            return false;
        }
        public override List<Spell> GetAvailableSpells()
        {
            List<Spell> result = new List<Spell>();
            if (UnderlyingCharacterClass != null)
                result.AddRange(UnderlyingCharacterClass.GetAvailableSpells());
            return result;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 326k
  • Answers 326k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer this is called "cartesian product", php man page on arrays… May 14, 2026 at 1:45 am
  • Editorial Team
    Editorial Team added an answer The best I've come up with so far looks like… May 14, 2026 at 1:45 am
  • Editorial Team
    Editorial Team added an answer This works in IE, Chrome and Safari (which should be… May 14, 2026 at 1:45 am

Related Questions

I am about to employ a new programmer for our ASP.NET MVC projects. I
I am programming a Tetris clone and in my game I store my tetromino
I am programming a simple C# console application. The spec is: A game consists
I am just finishing up an Artificial Intelligence course where, as part of the
Summary: Can I program a thick client game in C without reinventing wheels ,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.