Making arrays for equipping weapons in a simple rpg game

I have a sword(25 damage), spear(20 damage), arrow(15 damage), dagger(10 damage) and knife(5 damage). I want to make a class for them so that I can equip one of them in battle and use them to inflict damage. Any help? :)
make a class perhaps call it weapon ?

1
2
3
4
5
6
7
8
9
10
11

struct Weapon {
      Weapon( int dmg ) : damage( dmg ) {}
      int damage;
};

Weapon sword( 25 );
Weapon spear( 20 );
Weapon arrow( 15 );
Weapon dagger( 10 );
Weapon knife( 5 );


Then make a character class

1
2
3
4
5
6
7
struct Character {
    Weapon weapon;
};

Character myChara;
myChara.weapon = sword;


About inflicting damage it depends on what you are inflicting too
perhaps give more details about this game logic of yours
Last edited on
Topic archived. No new replies allowed.