5 Commits 2df12b5b2c ... fd5ce3aaaa

Auteur SHA1 Message Date
  igorbat99 fd5ce3aaaa Done: basic spell/skill model. TODO: Spell:traits il y a 6 ans
  igorbat99 d3846026aa add effects il y a 6 ans
  igorbat99 0ce676c818 did traits il y a 6 ans
  igorbat99 ecd9ca323a icons il y a 6 ans
  igorbat99 53507c8b3b made old gods great again(anf files in true directory) il y a 6 ans

+ 0 - 0
assets/effects/README.md


+ 2 - 0
assets/effects/effects.txt

@@ -0,0 +1,2 @@
+melledamage
+selfheal

+ 1 - 0
assets/effects/melledamage/descr.txt

@@ -0,0 +1 @@
+Effect of instance damage to Unit.

BIN
assets/effects/melledamage/icon.png


+ 1 - 0
assets/effects/selfheal/descr.txt

@@ -0,0 +1 @@
+Effect of instance damage to Unit.

BIN
assets/effects/selfheal/icon.png


+ 10 - 0
assets/skills/README.md

@@ -0,0 +1,10 @@
+# Папка skills 
+Cодержит файлы исходные файлы базовых классов, папки с файлами для каждой расы
+skilla.txt - содержит имена папок активных скиллов, обрабатывающихся исходным кодом
+Кроме всего прочего здесь находятся непосредственно папки рас (как активных, так и находящихся в разработке). 
+
+# Папки скиллов
+Каждая из папок скиллов устроена следующим образом:
+* desct.txt - файл с описанием скилла
+* icon.png - иконка скилла
+* traits.txt - файл с начальными характеристиками эффектов, установливаемыми для скилла при его сборке по умолчанию

+ 1 - 0
assets/skills/melledamage/descr.txt

@@ -0,0 +1 @@
+Effect of instance damage to Unit.

BIN
assets/skills/melledamage/icon.png


+ 4 - 0
assets/skills/melledamage/traits.txt

@@ -0,0 +1,4 @@
+1
+1
+0
+melledamage|10|0

+ 1 - 0
assets/skills/selfheal/descr.txt

@@ -0,0 +1 @@
+Effect of instance heal to Unit.

BIN
assets/skills/selfheal/icon.png


+ 4 - 0
assets/skills/selfheal/traits.txt

@@ -0,0 +1,4 @@
+1
+1
+0
+selfheal|5|0

+ 2 - 0
assets/skills/skills.txt

@@ -0,0 +1,2 @@
+melledamage
+selfheal

+ 56 - 0
include/effects/effect.h

@@ -0,0 +1,56 @@
+//
+// Created by IgorBat on 17.03.2018.
+//
+
+#ifndef THE_GAME_EFFECT_H
+#define THE_GAME_EFFECT_H
+
+#pragma once
+#include <iostream>
+#include <vector>
+//#include "AbstractFactory.h"
+
+class Unit;
+class Cell;
+
+class Effect : public QObject {
+    Q_OBJECT
+
+public:
+    explicit Effect(QString parameters);
+
+    virtual ~Effect() {}
+
+    int getCount();
+    void setCount(int value);
+
+    int getDurability;
+    void setDurability(int value);
+
+    //---------------------------------------------//
+    //----------------GUI section------------------//
+    //---------------------------------------------//
+    QString getEffectName() const;
+    QString getEffectDescr() const;
+    QImage getEffectIcon() const;
+
+    //---------------------------------------------//
+    //-----------Parameters load section-----------//
+    //---------------------------------------------//
+
+private:
+    void loadEffectDescr(QString effect_folder);
+    void loadEffectIcon(QString effect_folder);
+public:
+    virtual void OperateOnCell(Cell* cell) = 0;
+    virtual void OperateOnUnit(Unit* unit) = 0;
+protected:
+    int count_;
+    int durability_;
+
+    // GUI values
+    QString effect_name_;
+    QString effect_descr_;
+    QImage effect_icon_;
+};
+#endif //THE_GAME_EFFECT_H

+ 15 - 0
include/effects/melledamage.h

@@ -0,0 +1,15 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+
+#ifndef GAME_CLIENT_MELLEDAMAGE_H
+#define GAME_CLIENT_MELLEDAMAGE_H
+#pragma once
+#include <cassert>
+#include "effect\effect.h"
+
+class melledamage : public Effect {
+    void OperateOnCell(Cell* cell);
+    void OperateOnUnit(Unit* unit);
+};
+#endif //GAME_CLIENT_MELLEDAMAGE_H

+ 16 - 0
include/effects/selfheal.h

@@ -0,0 +1,16 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+
+#ifndef GAME_CLIENT_SELFHEAL_H
+#define GAME_CLIENT_SELFHEAL_H
+#pragma once
+#include <cassert>
+#include "effect\effect.h"
+
+class selfheal : public Effect {
+    void OperateOnCell(Cell* cell);
+    void OperateOnUnit(Unit* unit);
+};
+
+#endif //GAME_CLIENT_SELFHEAL_H

+ 0 - 45
include/skills/effect.h

@@ -1,45 +0,0 @@
-//
-// Created by IgorBat on 17.03.2018.
-//
-
-#ifndef THE_GAME_EFFECT_H
-#define THE_GAME_EFFECT_H
-
-#pragma once
-#include <iostream>
-#include <vector>
-//#include "AbstractFactory.h"
-
-class Unit;
-class Cell;
-
-enum typeEffect{instancePoint, ongoingPoint, instanceUnit, ongoingUnit};
-enum specieEffect{agility_, attack_range_, damage_per_hit_, intelligence_};
-
-class Effect {
-
-private:
-    int count_;
-    typeEffect typeEffect_;
-    specieEffect specieEffect_;
-public:
-    Effect() = delete;
-    Effect(std::string path) {
-
-    }
-    virtual ~Effect() = delete;
-
-    int getCount();
-    void setCount(int value);
-
-    typeEffect getType();
-    void setType(typeEffect value);
-
-    specieEffect getSpecie();
-    void setSpecie(specieEffect value);
-
-    void OperateOnCell(Cell*);
-    void OperateOnUnit(Unit*);
-    //logic here. 
-};
-#endif //THE_GAME_EFFECT_H

+ 15 - 0
include/skills/melledamage.h

@@ -0,0 +1,15 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+
+#ifndef GAME_CLIENT_MELLEDAMAGE_H
+#define GAME_CLIENT_MELLEDAMAGE_H
+#pragma once
+#include <cassert>
+#include "skills\spell.h"
+
+class melledamage : public Effect {
+    void CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom);
+};
+
+#endif //GAME_CLIENT_MELLEDAMAGE_H

+ 16 - 0
include/skills/selfheal.h

@@ -0,0 +1,16 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+
+#ifndef GAME_CLIENT_SELFHEAL_H
+#define GAME_CLIENT_SELFHEAL_H
+#pragma once
+#include <cassert>
+#include "skills\spell.h"
+
+class selfheal : public Spell {
+    void CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom);
+
+};
+
+#endif //GAME_CLIENT_SELFHEAL_H

+ 27 - 11
include/skills/spell.h

@@ -18,20 +18,18 @@ class Unit{
 class Cell{
     std :: list <Effect> effectsOnCell;
 };
-class Spell {
+class Spell : public QObject {
+    Q_OBJECT
 
 protected:
     std :: list <Effect> effects_;
-
 private:
     int distance_;
     bool forCell_;
 public:
-    Spell() = delete;
-    Spell(std::string path) {
+    explicit Spell(QString parameters);
 
-    }
-    virtual ~Spell() = delete;
+    virtual ~Spell() {}
 
     int getDistance();
     void setDistance(int value);
@@ -39,14 +37,32 @@ public:
     bool getForCell();
     void setForCell(bool value);
 
-    //int lenOfSmallestPath(Cell* destination);
+    virtual bool canCastToCell(Cell* destination, Cell* from);
+
+    virtual void CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom) = 0;
 
-    virtual bool canCastForDistance(int distance);
+    int getDistance();
+    void setDistance(int Value);
 
-    virtual bool canCastToCell(Cell* destination);
+    bool getForCell();
+    void setForCell(bool Value);
 
-    virtual void castToCell(Cell* destination);
+    QString getSpellName() const;
+    QString getSpellDescr() const;
+    QImage getSpellIcon() const;
+
+    //---------------------------------------------//
+    //-----------Parameters load section-----------//
+    //---------------------------------------------//
+
+private:
+    void loadSpellTraits(QString spell_folder);
+    void loadSpellDescr(QString spell_folder);
+    void loadSpellIcon(QString spell_folder);
 
-    void CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom);
+    // GUI values
+    QString spell_name_;
+    QString spell_descr_;
+    QImage spell_icon_;
 };
 #endif //THE_GAME_SPELL_H

+ 67 - 0
source/effects/effect.cpp

@@ -0,0 +1,67 @@
+//
+// 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];
+    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;
+}

+ 19 - 0
source/effects/melledamage.cpp

@@ -0,0 +1,19 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+
+#pragma once
+#include <cassert>
+#include "effect\melledamage.h"
+#include "units\unit.h"
+#include <string>
+
+void melledamage::OperateOnCell(Cell* cell){
+    throw std :: string("CAN'T TOUCH THIS")
+}
+
+void melledamage::OperateOnUnit(Unit* unit){
+    int temp = unit -> reduceIncomingDamage("p", count_);
+    unit ->setHealthPoints(unit -> getHealthPoints() - temp);
+    //check_on_death
+}

+ 19 - 0
source/effects/selfheal.cpp

@@ -0,0 +1,19 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+
+
+#pragma once
+#include <cassert>
+#include "effect\selfdamage.h"
+#include "units\unit.h"
+#include <string>
+
+void melledamage::OperateOnCell(Cell* cell){
+    throw std :: string("CAN'T TOUCH THIS")
+}
+
+void melledamage::OperateOnUnit(Unit* unit){
+    unit.setHealthPoints(unit.getHealthPoints() + count_);
+    //check_on_death
+}

+ 0 - 4
source/skills/effect.cpp

@@ -1,4 +0,0 @@
-//
-// Created by IgorBat on 21.04.2018.
-//
-

+ 7 - 0
source/skills/melledamage.cpp

@@ -0,0 +1,7 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+
+void melledamage::CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom){
+    effects_[0] -> OperateOnUnit(whom);
+}

+ 7 - 0
source/skills/selfheal.cpp

@@ -0,0 +1,7 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+
+void selfheal::CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom){
+    effects_[0] -> OperateOnUnit(who);
+}

+ 71 - 0
source/skills/spell.cpp

@@ -2,3 +2,74 @@
 // Created by IgorBat on 21.04.2018.
 //
 
+#include "abstractfactory.h"
+#include "skills/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_ = param[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) {
+    /*
+     * you can do it by yourself, i need to sleep
+     */
+
+}
+
+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 setDistance(int value){
+    distance_ = value;
+}
+
+bool getForCell(){
+    return forCell_;
+}
+void setForCell(bool value){
+    forCell_ = value;
+}
+bool Spell::canCastToCell(Cell* destination, Cell* from){
+    if(from -> lenOfActualPath(destination) == 1) return true;
+    return false;
+}