- I probably read in a table of default weapons (type, name, attributes, ...)
- I suspect that I will have different classes of these weapons (by Weapon group for example)
- See this table
- I can also decorate these with various modifications.
-
weapon = make_shared (bunch of parameters);
weapon = make_shared(weapon, bunch of parameters);
weapon = make_shared(weapon, bunch of parameters);
// vs
weapon = AxeWeaponFactory.MakeWeapon(WeaponTypeT::GREAT_AXE, WeaponDecorator::PLUS_ONE_HIT, ...)
- This is probably based on the following:
class WeaponAddOnFactory {
public:
virtual MakeWeaponAddOn(weapon, type, vector< attribute> attribs) = 0;
}
class WeaponFactory {
public:
virtual WeaponPtrT MakeWeapon(type, vector<attribute> attribs) = 0 ;
}
class AxeWeaponFactory: public WeaponFactory {
public:
WeaponPtrT MakeWeapon(type, vector<attribute> attribs) override {
WeaponPtr newWeapon;
if (type == WeaponTypeT::RANDOM) {
type = RandomAxeType;
}
switch (type)
case WeaponTypeT::AXE:
newWeapon = make_shared AxeWeaponPtr("Axe", ...);
break;
case WeaponTypeT::GREAT_AXE:
newWeapon = make_shared AxeWeaponPtr("Axe", ...);
break;
}
WeaponAddOnFactory f; // probably a singleton
for ( auto attrib: attribs) {
newWeapon = f.MakeWeaponAddOn(newWeapon, attrib);
}
}
}
- We could build a "store" along with this.
class WeaponStore {
public:
AddFactory(type, WeaponFactory)
...
FillInventory() {
for each empty slot in the inventory
pick a random factory r
AddToInventory(factories[r].MakeWeapon());
}
private:
vector < WeaponFactory> factories;
vector < WeaponT> inventory;
}