12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- //
- // Created by IgorBat on 21.04.2018.
- //
- #include "abstractfactory.h"
- #include "spells/spell.h"
- #include <iostream>
- #include <algorithm>
- #include <cassert>
- #include <string>
- #include <QFile>
- #include <QString>
- #include <QTextStream>
- Spell::Spell(QString parameters) {
- QStringList params = parameters.split("\n");
- assert(params.size() >= 1);
- spell_name_ = params[0];
- QString spell_folder = ":/assets/skills/" + spell_name_ + "/";
- loadSpellDescr(spell_folder);
- loadSpellIcon(spell_folder);
- loadSpellTraits(spell_folder);
- }
- void Spell::loadSpellDescr(QString spell_folder) {
- QFile file(spell_folder + "descr.txt");
- file.open(QIODevice::ReadOnly);
- QTextStream in(&file);
- in.setCodec("UTF-8");
- spell_descr_ = in.readAll();
- }
- void Spell::loadSpellIcon(QString spell_folder) {
- spell_icon_.load(spell_folder + "icon.png");
- }
- void Spell::loadSpellTraits(QString spell_folder) {
- QFile file(spell_folder + "traits.txt");
- file.open(QIODevice::ReadOnly);
- QTextStream in(&file);
- in.setCodec("UTF-8");
- QString traits_containts = in.readAll();
- QStringList params = traits_containts.split("\n");
- assert(params.size() >= 1);
- size_t countEffects = params[0].toInt();
- for (size_t i = 1; i <= countEffects; ++i){
- effects_.push_back(new Effect(params[i]));
- }
- }
- QString Spell::getSpellName() const {
- return spell_name_;
- }
- QString Spell::getSpellDescr() const {
- return spell_descr_;
- }
- QImage Spell::getSpellIcon() const {
- return spell_icon_;
- }
- int Spell::getDistance(){
- return distance_;
- }
- void Spell::setDistance(int value){
- distance_ = value;
- }
- bool Spell::getForCell(){
- return forCell_;
- }
- void Spell::setForCell(bool value){
- forCell_ = value;
- }
- bool Spell::canCastToCell(Cell* destination, Cell* from){
- //if(from -> lenOfActualPath(destination) == 1) return true;
- return false;
- }
|