|
@@ -13,32 +13,62 @@
|
|
|
|
|
|
Race::Race(QString race_name, QObject *parent) : QObject(parent)
|
|
Race::Race(QString race_name, QObject *parent) : QObject(parent)
|
|
{
|
|
{
|
|
- race_name_ = race_name;
|
|
|
|
|
|
+ race_id_ = race_name;
|
|
|
|
+
|
|
|
|
+ units_factory_.addClass<Warrior, QString>("Warrior");
|
|
|
|
+ units_factory_.addClass<Warrior, QString>("Mage");
|
|
|
|
|
|
QFile file(":/assets/units/" + race_name + "/units.txt");
|
|
QFile file(":/assets/units/" + race_name + "/units.txt");
|
|
QTextStream in(&file);
|
|
QTextStream in(&file);
|
|
QString unit_name = in.readLine();
|
|
QString unit_name = in.readLine();
|
|
|
|
|
|
- units_factory_.addClass<Warrior, QString>("Warrior");
|
|
|
|
- units_factory_.addClass<Warrior, QString>("Mage");
|
|
|
|
-
|
|
|
|
while (!in.atEnd()) {
|
|
while (!in.atEnd()) {
|
|
|
|
+ all_units_list_.push_back(createUnit(unit_name));
|
|
available_units_list_.push_back(unit_name);
|
|
available_units_list_.push_back(unit_name);
|
|
- race_name = in.readLine();
|
|
|
|
|
|
+ unit_name = in.readLine();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ QFile file0(":/assets/units/" + race_name + "/racename.txt");
|
|
|
|
+ QTextStream in0(&file);
|
|
|
|
+ race_name_ = in0.readLine();
|
|
|
|
+
|
|
|
|
+ QFile file1(":/assets/units/" + race_name + "/descr.txt");
|
|
|
|
+ QTextStream in1(&file);
|
|
|
|
+ race_descr_ = in1.readAll();
|
|
|
|
+
|
|
|
|
+ race_icon_.load(":/assets/units/" + race_name + "/descr.txt");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+QString Race::getRaceId() {
|
|
|
|
+ return race_id_;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+QString Race::getRaceName() {
|
|
|
|
+ return race_name_;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+QImage Race::getRaceIcon() {
|
|
|
|
+ return race_icon_;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+QString Race::getRaceDescr() {
|
|
|
|
+ return race_descr_;
|
|
|
|
+}
|
|
|
|
|
|
Unit* Race::createUnit(QString unit_name) {
|
|
Unit* Race::createUnit(QString unit_name) {
|
|
assert(std::count(available_units_list_.begin(), available_units_list_.end(), unit_name) != 0);
|
|
assert(std::count(available_units_list_.begin(), available_units_list_.end(), unit_name) != 0);
|
|
|
|
|
|
- QFile file(":/asserts/units/" + race_name_ + "/" + unit_name + "/baseclass.txt");
|
|
|
|
|
|
+ QFile file(":/asserts/units/" + race_id_ + "/" + unit_name + "/baseclass.txt");
|
|
QTextStream in(&file);
|
|
QTextStream in(&file);
|
|
QString class_id = in.readLine();
|
|
QString class_id = in.readLine();
|
|
|
|
|
|
- return units_factory_.createObject<QString>(class_id, race_name_ + "|" + unit_name);
|
|
|
|
|
|
+ return units_factory_.createObject<QString>(class_id, race_id_ + "|" + unit_name);
|
|
}
|
|
}
|
|
|
|
|
|
const std::vector<QString>& Race::getAvailableUnitsList() {
|
|
const std::vector<QString>& Race::getAvailableUnitsList() {
|
|
return available_units_list_;
|
|
return available_units_list_;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+const std::vector<Unit*> &Race::getAllUnitsList() {
|
|
|
|
+ return all_units_list_;
|
|
|
|
+}
|