12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- //
- // Created by IgorBat on 21.04.2018.
- //
- #include "abstractfactory.h"
- #include "effects/effect.h"
- #include <iostream>
- #include <algorithm>
- #include <cassert>
- #include <string>
- #include <QFile>
- #include <QString>
- #include <QTextStream>
- Effect::Effect(QString parameters) {
- QStringList params = parameters.split("|");
- assert(params.size() >= 3);
- effect_name_ = params[0];
- count_ = params[1].toInt();
- durability_ = params[2].toInt();
- QString effect_folder = ":/assets/effects/" + effect_name_ + "/";
- loadEffectDescr(effect_folder);
- loadEffectIcon(effect_folder);
- }
- void Effect::loadUnitDescr(QString effect_folder) {
- QFile file(effect_folder + "descr.txt");
- file.open(QIODevice::ReadOnly);
- QTextStream in(&file);
- in.setCodec("UTF-8");
- effect_descr_ = in.readAll();
- }
- void Effect::loadUnitIcon(QString effect_folder) {
- effect_icon_.load(effect_folder + "icon.png");
- }
- QString Effect::getEffectName() const {
- return effect_name_;
- }
- QString Effect::getEffectDescr() const {
- return effect_descr_;
- }
- QImage Effect::getEffectIcon() const {
- return effect_icon_;
- }
- int Effect::getCount(){
- return count_;
- }
- void Effect::setCount(int value){
- count_ = value;
- }
- int Effect::getDurability(){
- return durability_;
- };
- void Effect::setDurability(int value){
- durability_ = value;
- }
|