123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- //
- // 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>
- #include <QImage>
- Effect::Effect(QString parameters) {
- QStringList params = parameters.split("|");
- assert(params.size() >= 3);
- effect_name_ = params[0];
- setCount(params[1].toInt());
- setDurability(params[2].toInt());
- QString effect_folder = ":/assets/effects/" + effect_name_ + "/";
- loadEffectDescr(effect_folder);
- loadEffectIcon(effect_folder);
- }
- void Effect::loadEffectDescr(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::loadEffectIcon(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;
- }
|