我有一个怪物类,当创建一个实例时,它应该将每个怪物与那里的武器联系起来。前任。狮鹫怪物应该有狮鹫攻击 1 和狮鹫攻击 2,当然攻击的名称是 TBD,但现在还是使用狮鹫攻击 1 和 2。
目前我有这个。
#include <vector>
typedef enum {Living, Dead, Nature} Race;
typedef enum {Gryphon, Oracle, Mercenary,Templar,
Satyr,Fallin Angel,ArcAngel,Satan,Grimreaper,
Unbaptized Babies,Boggart,Succubus,Meat Wagon,
Djinns,Manticore,Water Nymph,Plant Nymph,
Mother Nature, Cannibal Tribesmen,Wyvern,
Vegetable Lamb, Ent, Lava Worm, Alpha Dragon
} MonsterType;
typedef enum {gryphon1,Oracle1, Mercenary1,Templar1,
Satyr1,Fallin Angel1,ArcAngel1,Satan1,Grimreaper1,
Unbaptized Babies1,Boggart1,Succubus1,Meat Wagon1,
Djinns1,Manticore1,Water Nymph1,Plant Nymph1,
Mother Nature1, Cannibal Tribesmen1,Wyvern1,
Vegetable Lamb1, Ent1, Lava Worm1,Alpha Dragon1,
Gryphon2, Oracle2, Mercenary2,Templar2,
Satyr2,Fallin Angel2,ArcAngel2,Satan2,Grimreaper2,
Unbaptized Babies2,Boggart2,Succubus2,Meat Wagon2,
Djinns2,Manticore2,Water Nymph2,Plant Nymph2,
Mother Nature2, Cannibal Tribesmen2,Wyvern2,
Vegetable Lamb2, Ent2, Lava Worm2, Alpha Dragon2
} Weapon;
Class Monsters{
protected:
MonsterType type;
Race race;
std::vector<Weapon> weapon_list;
public:
bool flying;
bool lava;
bool water;
int life;
int karmaCost;
int move;
int crit;
int defMagic;
int defNonMagic;
bool isDead;
bool canMove;
bool canAttack;
bool onFlag;
int nextTurn;
};
我不确定向量,也不确定是否需要它只是我在搞砸的一些实验。但是将武器与怪物联系起来的最佳方法是什么?另请注意,每种武器都有与之相伴的价值,所以
gryphon attack 1 {
int range = 10
int ticks = 5
bool magical = false
int power = 23
bool heals = false
}
gryphon attack 2 {
int range = 5
int ticks = 7
bool magical = true
int power = 29
bool heals = true
}
实际值是从 ini 或网络读取的,所以还不担心实际值,但我需要知道我可以添加值 gryphon->weapon1->range = 5
我对此仍然很陌生,所以如果看起来很不对,请告诉我。