Sfoglia il codice sorgente

Version 0.3.1. Merged effects

Ivan Arkhipov 6 anni fa
parent
commit
8dc39feb88
56 ha cambiato i file con 400 aggiunte e 191 eliminazioni
  1. 2 0
      assets/effects/README.md
  2. 3 2
      assets/effects/effects.txt
  3. 0 0
      assets/effects/meleedamage/descr.txt
  4. 0 0
      assets/effects/meleedamage/icon.png
  5. 1 1
      assets/effects/selfheal/descr.txt
  6. 1 0
      assets/effects/selfmove/descr.txt
  7. 0 0
      assets/effects/selfmove/icon.png
  8. 0 1
      assets/skills/melledamage/descr.txt
  9. 0 4
      assets/skills/melledamage/traits.txt
  10. 0 1
      assets/skills/selfheal/descr.txt
  11. 0 4
      assets/skills/selfheal/traits.txt
  12. 0 2
      assets/skills/skills.txt
  13. 5 1
      assets/spells/README.md
  14. 1 0
      assets/spells/meleedamagespell/descr.txt
  15. 0 0
      assets/spells/meleedamagespell/icon.png
  16. 2 0
      assets/spells/meleedamagespell/traits.txt
  17. 1 0
      assets/spells/selfhealspell/descr.txt
  18. BIN
      assets/spells/selfhealspell/icon.png
  19. 2 0
      assets/spells/selfhealspell/traits.txt
  20. 1 0
      assets/spells/selfmovespell/descr.txt
  21. BIN
      assets/spells/selfmovespell/icon.png
  22. 2 0
      assets/spells/selfmovespell/traits.txt
  23. 3 0
      assets/spells/spells.txt
  24. 44 37
      client.pro
  25. 8 0
      include/effects/effect.h
  26. 19 0
      include/effects/meleedamage.h
  27. 0 15
      include/effects/melledamage.h
  28. 7 3
      include/effects/selfheal.h
  29. 17 0
      include/effects/selfmove.h
  30. 2 0
      include/gui/guiscenemanager.h
  31. 0 15
      include/skills/melledamage.h
  32. 19 0
      include/spells/meleedamagespell.h
  33. 6 4
      include/spells/selfhealspell.h
  34. 13 0
      include/spells/selfmovespell.h
  35. 7 16
      include/spells/spell.h
  36. 32 0
      include/spellsmanager.h
  37. 1 0
      include/units/unit.h
  38. 9 0
      res/common_data.qrc
  39. 2 11
      res/effect_data.qrc
  40. 3 1
      res/hotseat_prebattle.qrc
  41. 8 8
      res/spell_data.qrc
  42. 27 0
      source/effects/meleedamage.cpp
  43. 0 19
      source/effects/melledamage.cpp
  44. 18 10
      source/effects/selfheal.cpp
  45. 22 0
      source/effects/selfmove.cpp
  46. 0 2
      source/gui/guiscenemanager.cpp
  47. 0 7
      source/skills/melledamage.cpp
  48. 0 7
      source/skills/selfheal.cpp
  49. 16 0
      source/spells/meleedamagespell.cpp
  50. 18 0
      source/spells/selfhealspell.cpp
  51. 14 0
      source/spells/selfmovespell.cpp
  52. 28 13
      source/spells/spell.cpp
  53. 28 0
      source/spellsmanager.cpp
  54. 5 5
      source/units/unit.cpp
  55. 2 1
      ui/main_menu/mainmenubackground.cpp
  56. 1 1
      ui/main_menu/mainmenubackground.ui

+ 2 - 0
assets/effects/README.md

@@ -0,0 +1,2 @@
+в файле effects.txt названия эффектов,
+в соответствующих папках файлы descr.txt, icon.png

+ 3 - 2
assets/effects/effects.txt

@@ -1,2 +1,3 @@
-melledamage
-selfheal
+meleedamage
+selfheal
+selfmove

+ 0 - 0
assets/effects/melledamage/descr.txt → assets/effects/meleedamage/descr.txt


+ 0 - 0
assets/effects/melledamage/icon.png → assets/effects/meleedamage/icon.png


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

@@ -1 +1 @@
-Effect of instance damage to Unit.
+Effect of instance heal to Unit.

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

@@ -0,0 +1 @@
+Effect of instance changing location of Unit.

+ 0 - 0
assets/skills/melledamage/icon.png → assets/effects/selfmove/icon.png


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

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

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

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

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

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

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

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

+ 0 - 2
assets/skills/skills.txt

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

+ 5 - 1
assets/skills/README.md → assets/spells/README.md

@@ -1,6 +1,6 @@
 # Папка skills 
 Cодержит файлы исходные файлы базовых классов, папки с файлами для каждой расы
-skilla.txt - содержит имена папок активных скиллов, обрабатывающихся исходным кодом
+skills.txt - содержит имена папок активных скиллов, обрабатывающихся исходным кодом
 Кроме всего прочего здесь находятся непосредственно папки рас (как активных, так и находящихся в разработке). 
 
 # Папки скиллов
@@ -8,3 +8,7 @@ skilla.txt - 
 * desct.txt - файл с описанием скилла
 * icon.png - иконка скилла
 * traits.txt - файл с начальными характеристиками эффектов, установливаемыми для скилла при его сборке по умолчанию
+формат :
+<n>, далее в n строках
+<effectname>|<count>|<duration>
+

+ 1 - 0
assets/spells/meleedamagespell/descr.txt

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

+ 0 - 0
assets/skills/selfheal/icon.png → assets/spells/meleedamagespell/icon.png


+ 2 - 0
assets/spells/meleedamagespell/traits.txt

@@ -0,0 +1,2 @@
+1
+meleedamage|10|0

+ 1 - 0
assets/spells/selfhealspell/descr.txt

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

BIN
assets/spells/selfhealspell/icon.png


+ 2 - 0
assets/spells/selfhealspell/traits.txt

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

+ 1 - 0
assets/spells/selfmovespell/descr.txt

@@ -0,0 +1 @@
+Spell of instance changing location of Unit.

BIN
assets/spells/selfmovespell/icon.png


+ 2 - 0
assets/spells/selfmovespell/traits.txt

@@ -0,0 +1,2 @@
+1
+selfmove|0|0

+ 3 - 0
assets/spells/spells.txt

@@ -0,0 +1,3 @@
+meleedamagespell
+selfhealspell
+selfmovespell

+ 44 - 37
client.pro

@@ -63,7 +63,7 @@ EXT_RES =                                                                   \
     "$$PWD/res/effect_data.qrc          -o $$DESTDIR/res/data006.gtr"       \
     "$$PWD/res/spell_data.qrc           -o $$DESTDIR/res/data007.gtr"       \
     "$$PWD/res/unit_data.qrc            -o $$DESTDIR/res/data008.gtr"       \
-    "$$PWD/res/common_data.qrc           -o $$DESTDIR/res/data009.gtr"       \
+    "$$PWD/res/common_data.qrc           -o $$DESTDIR/res/data009.gtr"
 
 for (RES, EXT_RES) {
     win32 {
@@ -87,19 +87,23 @@ SOURCES +=                                      \
     source/racemanager.cpp                      \
     source/soundengine.cpp                      \
                                                 \
-\    #source/effects/effect.cpp                   \
-\    #source/effects/melledamage.cpp              \
-\    #source/effects/selfheal.cpp                 \
-                                                \
     source/gui/guiscenemanager.cpp              \
     source/gui/scene.cpp                        \
                                                 \
     source/hotseatgame/gamemanager.cpp          \
     source/hotseatgame/unitsqueue.cpp           \
+    source/hotseatgame/gameproperties.cpp       \
+                                                \
+    source/spellsmanager.cpp                    \
+    source/spells/spell.cpp                     \
+    source/spells/selfhealspell.cpp             \
+    source/spells/meleedamagespell.cpp          \
+    source/spells/selfmovespell.cpp             \
                                                 \
-\   #source/skills/spell.cpp                     \
-\   #source/skills/selfheal.cpp                  \
-\   #source/skills/melledamage.cpp               \
+    source/effects/effect.cpp                   \
+    source/effects/meleedamage.cpp              \
+    source/effects/selfheal.cpp                 \
+    source/effects/selfmove.cpp                 \
                                                 \
     source/units/unit.cpp                       \
                                                 \
@@ -109,12 +113,11 @@ SOURCES +=                                      \
     ui/hotseat_recruitment/recruitmentscene.cpp \
     ui/loading_form/loadingform.cpp             \
     ui/main_menu/mainmenu.cpp                   \
-    ui/main_menu/mainmenubackground.cpp \
-    source/gui/buttoneventlistener.cpp \
-    ui/hotseat_recruitment/iconhint.cpp \
-    ui/dialog_form/dialogform.cpp \
-    ui/about_us/aboutus.cpp \
-    source/hotseatgame/gameproperties.cpp
+    ui/main_menu/mainmenubackground.cpp         \
+    source/gui/buttoneventlistener.cpp          \
+    ui/hotseat_recruitment/iconhint.cpp         \
+    ui/dialog_form/dialogform.cpp               \
+    ui/about_us/aboutus.cpp
 
 HEADERS +=                                      \
     include/abstractfactory.h                   \
@@ -125,20 +128,24 @@ HEADERS +=                                      \
     include/racemanager.h                       \
     include/soundengine.h                       \
                                                 \
-\    #include/effects/effect.h                    \
-\    #include/effects/melledamage.h               \
-\    #include/effects/selfheal.h                  \
-                                                \
     include/gui/guiscenemanager.h               \
     include/gui/scene.h                         \
     include/gui/buttoneventlistener.h           \
                                                 \
     include/hotseatgame/gamemanager.h           \
     include/hotseatgame/unitsqueue.h            \
+    include/hotseatgame/gameproperties.h        \
                                                 \
-\    #include/skills/melledamage.h                \
-\    #include/skills/selfheal.h                   \
-\    #include/skills/spell.h                      \
+    include/spellsmanager.h                     \
+    include/spells/meleedamagespell.h           \
+    include/spells/selfhealspell.h              \
+    include/spells/spell.h                      \
+    include/spells/selfmovespell.h              \
+                                                \
+    include/effects/meleedamage.h               \
+    include/effects/selfheal.h                  \
+    include/effects/effect.h                    \
+    include/effects/selfmove.h                  \
                                                 \
     include/units/unit.h                        \
                                                 \
@@ -151,8 +158,7 @@ HEADERS +=                                      \
     ui/main_menu/mainmenubackground.h           \
     ui/hotseat_recruitment/iconhint.h           \
     ui/dialog_form/dialogform.h                 \
-    ui/about_us/aboutus.h                       \
-    include/hotseatgame/gameproperties.h
+    ui/about_us/aboutus.h
 
 FORMS +=                                        \
     ui/hotseat_game/hotseatgame.ui              \
@@ -160,22 +166,23 @@ FORMS +=                                        \
     ui/hotseat_prebattle/prebattlescene.ui      \
     ui/hotseat_recruitment/recruitmentscene.ui  \
     ui/loading_form/loadingform.ui              \
-    ui/main_menu/mainmenu.ui \
-    ui/main_menu/mainmenubackground.ui \
-    ui/dialog_form/dialogform.ui \
+    ui/main_menu/mainmenu.ui                    \
+    ui/main_menu/mainmenubackground.ui          \
+    ui/dialog_form/dialogform.ui                \
     ui/about_us/aboutus.ui
 
 RESOURCES +=                                    \
-#    res/hotseat_intro.qrc                       \
-#    res/hotseat_recruitment.qrc                 \
-#    res/hotseat_prebattle.qrc                   \
-#    res/hotseat_game.qrc                        \
-#    res/main_menu.qrc                           \
-#    res/hotseat_intro.qrc                       \
-#                                                \
-#    res/effect_data.qrc                         \
-#    res/spell_data.qrc                          \
-#    res/unit_data.qrc                           \
-#    res/common_data.qrc
+    res/hotseat_intro.qrc                       \
+    res/hotseat_recruitment.qrc                 \
+    res/hotseat_prebattle.qrc                   \
+    res/hotseat_game.qrc                        \
+    res/main_menu.qrc                           \
+    res/hotseat_intro.qrc                       \
+                                                \
+    res/effect_data.qrc                         \
+    res/spell_data.qrc                          \
+    res/unit_data.qrc                           \
+    res/common_data.qrc
+#    res/all_data.qrc
 
 RC_ICONS = $$PWD/assets/common/icon.ico

+ 8 - 0
include/effects/effect.h

@@ -21,6 +21,12 @@ class Effect : public QObject {
     Q_OBJECT
 
 public:
+    enum TypeOfTrigger{
+        InCome = 1,
+        AfterAction = 2,
+        AfterEndTurn = 3
+    };
+    Effect() = default;
     explicit Effect(QString parameters);
 
     virtual ~Effect() {}
@@ -48,6 +54,8 @@ private:
 public:
     virtual void OperateOnCell(Cell* cell) = 0;
     virtual void OperateOnUnit(Unit* unit) = 0;
+    virtual void OperateOnUnitToCell(Unit* who, Cell* where) = 0;
+    virtual void Execute(Cell* from, Cell* where, Unit* who, Unit* whom, TypeOfTrigger Type) = 0;
 protected:
     int count_;
     int durability_;

+ 19 - 0
include/effects/meleedamage.h

@@ -0,0 +1,19 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+
+#ifndef GAME_CLIENT_MELEEDAMAGE_H
+#define GAME_CLIENT_MELEEDAMAGE_H
+#include <cassert>
+#include "effects\effect.h"
+
+class MeleeDamage : public Effect {
+public:
+    MeleeDamage() = default;
+
+    void OperateOnCell(Cell* cell);
+    void OperateOnUnit(Unit* unit);
+    void OperateOnUnitToCell(Unit* who, Cell* where);
+    void Execute(Cell* from, Cell* where, Unit* who, Unit* whom, TypeOfTrigger Type);
+};
+#endif //GAME_CLIENT_MELEEDAMAGE_H

+ 0 - 15
include/effects/melledamage.h

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

+ 7 - 3
include/effects/selfheal.h

@@ -4,13 +4,17 @@
 
 #ifndef GAME_CLIENT_SELFHEAL_H
 #define GAME_CLIENT_SELFHEAL_H
-#pragma once
 #include <cassert>
-#include "effect\effect.h"
+#include "effects\effect.h"
+
+class SelfHeal : public Effect {
+public:
+    SelfHeal() = default;
 
-class selfheal : public Effect {
     void OperateOnCell(Cell* cell);
     void OperateOnUnit(Unit* unit);
+    void OperateOnUnitToCell(Unit* who, Cell* where);
+    void Execute(Cell* from, Cell* where, Unit* who, Unit* whom, TypeOfTrigger Type);
 };
 
 #endif //GAME_CLIENT_SELFHEAL_H

+ 17 - 0
include/effects/selfmove.h

@@ -0,0 +1,17 @@
+#ifndef SELFMOVE_H
+#define SELFMOVE_H
+
+#include "effects\effect.h"
+
+class SelfMove : public Effect {
+public:
+    explicit SelfMove(QString param) : Effect(param) {}
+
+    void OperateOnUnitToCell(Unit* who, Cell* where) override;
+    void OperateOnCell(Cell* cell) override;
+    void OperateOnUnit(Unit* unit) override;
+    void Execute(Cell* from, Cell* where, Unit* who, Unit* whom, TypeOfTrigger Type) override;
+};
+
+
+#endif // SELFMOVE_H

+ 2 - 0
include/gui/guiscenemanager.h

@@ -7,6 +7,8 @@
 
 #include <map>
 
+const QString PROJECT_VERSION = "v.0.3.1dev";
+
 class Scene;
 
 class GuiSceneManager : public QObject

+ 0 - 15
include/skills/melledamage.h

@@ -1,15 +0,0 @@
-//
-// 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

+ 19 - 0
include/spells/meleedamagespell.h

@@ -0,0 +1,19 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+
+#ifndef GAME_CLIENT_MELEEDAMAGE_H
+#define GAME_CLIENT_MELEEDAMAGE_H
+
+#include <cassert>
+#include "spells\spell.h"
+
+class MeleeDamageSpell : public Spell {
+public:
+    MeleeDamageSpell(QString param) : Spell(param) {}
+
+    void CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom) override;
+    bool canCastToCell(Cell* destination, Cell* from) override;
+};
+
+#endif //GAME_CLIENT_MELEEDAMAGE_H

+ 6 - 4
include/skills/selfheal.h → include/spells/selfhealspell.h

@@ -4,13 +4,15 @@
 
 #ifndef GAME_CLIENT_SELFHEAL_H
 #define GAME_CLIENT_SELFHEAL_H
-#pragma once
 #include <cassert>
-#include "skills\spell.h"
+#include "spells\spell.h"
 
-class selfheal : public Spell {
-    void CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom);
+class SelfHealSpell : public Spell {
+public:
+    SelfHealSpell(QString param) : Spell(param) {}
 
+    void CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom) override;
+    bool canCastToCell(Cell* destination, Cell* from) override;
 };
 
 #endif //GAME_CLIENT_SELFHEAL_H

+ 13 - 0
include/spells/selfmovespell.h

@@ -0,0 +1,13 @@
+#ifndef SELFMOVESPELL_H
+#define SELFMOVESPELL_H
+#include "spells\spell.h"
+
+class SelfMoveSpell : public Spell {
+public:
+    SelfMoveSpell(QString param) : Spell(param) {}
+
+    void CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom) override;
+    bool canCastToCell(Cell* destination, Cell* from) override;
+};
+
+#endif // SELFMOVESPELL_H

+ 7 - 16
include/skills/spell.h → include/spells/spell.h

@@ -9,20 +9,17 @@
 #include <iostream>
 #include <vector>
 #include <list>
+#include "cell.h"
+#include "units/unit.h"
 //#include "AbstractFactory.h"
-#include "effect.h"
+#include "effects/effect.h"
+#include <memory>
 
-class Unit{
-    std :: list <Effect> effectsOnUnit;
-};
-class Cell{
-    std :: list <Effect> effectsOnCell;
-};
 class Spell : public QObject {
     Q_OBJECT
 
 protected:
-    std :: list <Effect> effects_;
+    std :: vector <std::shared_ptr<Effect> > effects_;
 private:
     int distance_;
     bool forCell_;
@@ -37,16 +34,10 @@ public:
     bool getForCell();
     void setForCell(bool value);
 
-    virtual bool canCastToCell(Cell* destination, Cell* from);
-
+    virtual bool canCastToCell(Cell* destination, Cell* from) = 0;
+    bool isNeirbor(Cell* destination, Cell* from);
     virtual void CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom) = 0;
 
-    int getDistance();
-    void setDistance(int Value);
-
-    bool getForCell();
-    void setForCell(bool Value);
-
     QString getSpellName() const;
     QString getSpellDescr() const;
     QImage getSpellIcon() const;

+ 32 - 0
include/spellsmanager.h

@@ -0,0 +1,32 @@
+#ifndef SPELLSMANAGER_H
+#define SPELLSMANAGER_H
+#include <QObject>
+#include <QString>
+#include <QImage>
+
+#include <vector>
+
+#include "abstractfactory.h"
+#include "effects/effect.h"
+#include "spells/spell.h"
+
+class SpellManager : public QObject
+{
+    Q_OBJECT
+public:
+    std::shared_ptr<Spell> createSpell(QString spell_name);
+    std::shared_ptr<Effect> createEffect(QString effect_name);
+    static SpellManager& getInstance(){
+        static SpellManager instance;
+        return instance;
+    }
+private:
+    SpellManager();
+    SpellManager(const SpellManager&) = delete;
+    SpellManager &operator=(SpellManager&) = delete;
+    ObjectFactory<Spell, QString> spells_factory_;
+    ObjectFactory<Effect, QString> effects_factory_;
+    std::vector<QString> available_spells_list_;
+    std::vector<std::shared_ptr<Unit>> all_spells_list_;
+};
+#endif // SPELLSMANAGER_H

+ 1 - 0
include/units/unit.h

@@ -36,6 +36,7 @@ public:
 
     int getHealthPoints();
   	void setHealthPoints(int value);
+
     int getMaxHealthPoints();
 
     int getMagicDefence();

+ 9 - 0
res/common_data.qrc

@@ -39,5 +39,14 @@
         <file>../assets/common/logo.gif</file>
         <file>../assets/common/buttons/to_battle_button.png</file>
         <file>../assets/common/buttons/to_battle_button_hover.png</file>
+        <file>../assets/common/window/strong_translucent-border-botleft.png</file>
+        <file>../assets/common/window/strong_translucent-border-botright.png</file>
+        <file>../assets/common/window/strong_translucent-border-left.png</file>
+        <file>../assets/common/window/strong_translucent-border-right.png</file>
+        <file>../assets/common/window/strong_translucent-border-top.png</file>
+        <file>../assets/common/window/strong_translucent-border-topleft.png</file>
+        <file>../assets/common/window/strong_translucent-border-topright.png</file>
+        <file>../assets/common/window/strong_translucent-background.png</file>
+        <file>../assets/common/window/strong_translucent-border_bottom.png</file>
     </qresource>
 </RCC>

+ 2 - 11
res/effect_data.qrc

@@ -1,19 +1,10 @@
 <RCC>
     <qresource prefix="/">
-        <file>../assets/effects/melledamage/descr.txt</file>
-        <file>../assets/effects/melledamage/icon.png</file>
         <file>../assets/effects/selfheal/descr.txt</file>
         <file>../assets/effects/selfheal/icon.png</file>
         <file>../assets/effects/effects.txt</file>
         <file>../assets/effects/README.md</file>
-        <file>../assets/common/window/strong_translucent-background.png</file>
-        <file>../assets/common/window/strong_translucent-border_bottom.png</file>
-        <file>../assets/common/window/strong_translucent-border-botleft.png</file>
-        <file>../assets/common/window/strong_translucent-border-botright.png</file>
-        <file>../assets/common/window/strong_translucent-border-left.png</file>
-        <file>../assets/common/window/strong_translucent-border-right.png</file>
-        <file>../assets/common/window/strong_translucent-border-top.png</file>
-        <file>../assets/common/window/strong_translucent-border-topleft.png</file>
-        <file>../assets/common/window/strong_translucent-border-topright.png</file>
+        <file>../assets/effects/meleedamage/descr.txt</file>
+        <file>../assets/effects/meleedamage/icon.png</file>
     </qresource>
 </RCC>

+ 3 - 1
res/hotseat_prebattle.qrc

@@ -1,3 +1,5 @@
 <RCC>
-    <qresource prefix="/"/>
+    <qresource prefix="/">
+        <file>../assets/hotseat_intro/image.gif</file>
+    </qresource>
 </RCC>

+ 8 - 8
res/spell_data.qrc

@@ -1,12 +1,12 @@
 <RCC>
     <qresource prefix="/">
-        <file>../assets/skills/melledamage/descr.txt</file>
-        <file>../assets/skills/melledamage/icon.png</file>
-        <file>../assets/skills/melledamage/traits.txt</file>
-        <file>../assets/skills/selfheal/descr.txt</file>
-        <file>../assets/skills/selfheal/icon.png</file>
-        <file>../assets/skills/selfheal/traits.txt</file>
-        <file>../assets/skills/README.md</file>
-        <file>../assets/skills/skills.txt</file>
+        <file>../assets/spells/meleedamagespell/descr.txt</file>
+        <file>../assets/spells/meleedamagespell/icon.png</file>
+        <file>../assets/spells/meleedamagespell/traits.txt</file>
+        <file>../assets/spells/selfhealspell/descr.txt</file>
+        <file>../assets/spells/selfhealspell/icon.png</file>
+        <file>../assets/spells/selfhealspell/traits.txt</file>
+        <file>../assets/spells/README.md</file>
+        <file>../assets/spells/spells.txt</file>
     </qresource>
 </RCC>

+ 27 - 0
source/effects/meleedamage.cpp

@@ -0,0 +1,27 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+
+#include <cassert>
+#include "effects\meleedamage.h"
+#include "units\unit.h"
+#include <string>
+
+void MeleeDamage::OperateOnCell(Cell* cell){
+    throw std :: string("CAN'T TOUCH THIS");
+}
+
+void MeleeDamage::OperateOnUnitToCell(Unit* who, Cell* where){
+    throw std :: string("CAN'T TOUCH THIS");
+}
+
+void MeleeDamage::OperateOnUnit(Unit* unit){
+    unit->setHealthPoints(  unit->getHealthPoints() -
+                            (count_ - 2.5 * double(count_) * double(unit->getPhysicDefence()) / 100.0));
+}
+
+void MeleeDamage::Execute(Cell* from, Cell* where, Unit* who, Unit* whom, TypeOfTrigger Type){
+    if(Type == 1){
+        OperateOnUnit(whom);
+    }
+}

+ 0 - 19
source/effects/melledamage.cpp

@@ -1,19 +0,0 @@
-//
-// Created by IgorBat on 23.04.2018.
-//
-
-#pragma once
-#include <cassert>
-#include "effects\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
-}

+ 18 - 10
source/effects/selfheal.cpp

@@ -1,19 +1,27 @@
 //
 // Created by IgorBat on 23.04.2018.
 //
-
-
-#pragma once
 #include <cassert>
-#include "effect\selfdamage.h"
+#include "effects\selfheal.h"
+#include "cell.h"
 #include "units\unit.h"
 #include <string>
 
-void melledamage::OperateOnCell(Cell* cell){
-    throw std :: string("CAN'T TOUCH THIS")
+void SelfHeal::OperateOnCell(Cell* cell){
+    throw std :: string("CAN'T TOUCH THIS");
+}
+
+void SelfHeal::OperateOnUnit(Unit* unit){
+    unit->setHealthPoints(std :: min(unit->getHealthPoints() + count_, unit->getMaxHealthPoints()));
+    //check_on_is_it_max
+}
+
+void SelfHeal::OperateOnUnitToCell(Unit* who, Cell* where){
+    throw std :: string("CAN'T TOUCH THIS");
+}
+
+void SelfHeal::Execute(Cell* from, Cell* where, Unit* who, Unit* whom, TypeOfTrigger Type){
+    if(Type == 1)
+        OperateOnUnit(who);
 }
 
-void melledamage::OperateOnUnit(Unit* unit){
-    unit.setHealthPoints(unit.getHealthPoints() + count_);
-    //check_on_death
-}

+ 22 - 0
source/effects/selfmove.cpp

@@ -0,0 +1,22 @@
+#include <cassert>
+#include "effects\selfmove.h"
+#include "cell.h"
+#include "units\unit.h"
+#include <string>
+
+void SelfMove::OperateOnCell(Cell* cell){
+    throw std :: string("CAN'T TOUCH THIS");
+}
+
+void SelfMove::OperateOnUnit(Unit* unit){
+    throw std :: string("CAN'T TOUCH THIS");
+}
+
+void SelfMove::OperateOnUnitToCell(Unit* unit, Cell* cell){
+    unit->setLocation(cell);
+}
+
+void SelfMove::Execute(Cell* from, Cell* where, Unit* who, Unit* whom, TypeOfTrigger Type){
+    if(Type == 1)
+        OperateOnUnitToCell(who, where);
+}

+ 0 - 2
source/gui/guiscenemanager.cpp

@@ -15,8 +15,6 @@
 #include <QFontDatabase>
 #include <QTimer>
 
-#define PROJECT_VERSION "v.0.3.0dev"
-
 GuiSceneManager::GuiSceneManager(QObject *parent) : QObject(parent) {
     window_ = new QMainWindow(nullptr, Qt::Window | Qt::FramelessWindowHint);
     window_->setWindowTitle(QString("Honourished ") + PROJECT_VERSION);

+ 0 - 7
source/skills/melledamage.cpp

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

+ 0 - 7
source/skills/selfheal.cpp

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

+ 16 - 0
source/spells/meleedamagespell.cpp

@@ -0,0 +1,16 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+#include <cassert>
+#include "spells/meleedamagespell.h"
+#include "units/unit.h"
+#include "cell.h"
+#include <string>
+
+void MeleeDamageSpell::CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom){
+    effects_[0] -> OperateOnUnit(whom);
+}
+
+bool MeleeDamageSpell::canCastToCell(Cell* destination, Cell* from){
+    return isNeirbor(destination, from);
+}

+ 18 - 0
source/spells/selfhealspell.cpp

@@ -0,0 +1,18 @@
+//
+// Created by IgorBat on 23.04.2018.
+//
+#pragma once
+#include <cassert>
+#include "spells/selfhealspell.h"
+#include "units/unit.h"
+#include "cell.h"
+#include <string>
+
+
+void SelfHealSpell::CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom){
+    effects_[0] -> OperateOnUnit(who);
+}
+
+bool SelfHealSpell::canCastToCell(Cell* destination, Cell* from){
+    return isNeirbor(destination, from);
+}

+ 14 - 0
source/spells/selfmovespell.cpp

@@ -0,0 +1,14 @@
+#include <cassert>
+#include "spells/selfmovespell.h"
+#include "units/unit.h"
+#include "cell.h"
+#include <string>
+
+
+void SelfMoveSpell::CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom){
+    effects_[0] -> OperateOnUnitToCell(who, where);
+}
+
+bool SelfMoveSpell::canCastToCell(Cell* destination, Cell* from){
+    return isNeirbor(destination, from);
+}

+ 28 - 13
source/skills/spell.cpp → source/spells/spell.cpp

@@ -3,7 +3,7 @@
 //
 
 #include "abstractfactory.h"
-#include "skills/spell.h"
+#include "spells/spell.h"
 
 #include <iostream>
 #include <algorithm>
@@ -13,11 +13,12 @@
 #include <QFile>
 #include <QString>
 #include <QTextStream>
+#include <spellsmanager.h>
 
-Spell::Spell(QString parameters) {
+Spell::Spell(QString parameters) : QObject(nullptr) {
     QStringList params = parameters.split("\n");
     assert(params.size() >= 1);
-    spell_name_ = param[0];
+    spell_name_ = params[0];
     QString spell_folder = ":/assets/skills/" + spell_name_ + "/";
 
     loadSpellDescr(spell_folder);
@@ -38,10 +39,19 @@ void Spell::loadSpellIcon(QString spell_folder) {
 }
 
 void Spell::loadSpellTraits(QString spell_folder) {
-    /*
-     * you can do it by yourself, i need to sleep
-     */
-
+    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){
+        auto list = params[i].split('|');
+        auto object_ptr =SpellManager::getInstance().createEffect(list[0]);
+        effects_.push_back(object_ptr);
+    }
 }
 
 QString Spell::getSpellName() const {
@@ -59,17 +69,22 @@ QImage Spell::getSpellIcon() const {
 int Spell::getDistance(){
     return distance_;
 }
-void setDistance(int value){
+void Spell::setDistance(int value){
     distance_ = value;
 }
 
-bool getForCell(){
+bool Spell::getForCell(){
     return forCell_;
 }
-void setForCell(bool value){
+void Spell::setForCell(bool value){
     forCell_ = value;
 }
-bool Spell::canCastToCell(Cell* destination, Cell* from){
-    if(from -> lenOfActualPath(destination) == 1) return true;
-    return false;
+
+bool Spell::isNeirbor(Cell* destination, Cell* from){
+    return from -> getleft() == destination ||
+           from -> getleftDown() == destination ||
+           from -> getleftUp() == destination ||
+           from -> getright() == destination ||
+           from -> getrightDown() == destination ||
+           from -> getrightUp() == destination;
 }

+ 28 - 0
source/spellsmanager.cpp

@@ -0,0 +1,28 @@
+#include <spellsmanager.h>
+#include <spells/meleedamagespell.h>
+#include <spells/selfhealspell.h>
+#include <spells/selfmovespell.h>
+
+#include <effects/effect.h>
+#include <effects/meleedamage.h>
+#include <effects/selfheal.h>
+#include <effects/selfmove.h>
+
+SpellManager::SpellManager(){
+    spells_factory_.addClass<MeleeDamageSpell, QString>("MeleeDamageSpell");
+    spells_factory_.addClass<SelfHealSpell, QString>("SelfHealSpell");
+    spells_factory_.addClass<SelfMoveSpell, QString>("SelfMoveSpell");
+
+    effects_factory_.addClass<SelfMove, QString>("SelfMove");
+    //effects_factory_.addClass<MeleeDamage, QString>("MeleeDamage");
+    //effects_factory_.addClass<SelfHeal, QString>("SelfHeal");
+
+
+}
+std::shared_ptr<Spell> SpellManager::createSpell(QString spell_name){
+    return spells_factory_.createObject(spell_name, QString());
+}
+
+std::shared_ptr<Effect> SpellManager::createEffect(QString effect_name){
+    return effects_factory_.createObject(effect_name, QString());
+}

+ 5 - 5
source/units/unit.cpp

@@ -122,10 +122,6 @@ int Unit::getLevel() {
 	return level_;
 }
 
-int Unit::getHealthPoints() {
-	return health_points_;
-}
-
 int Unit::getActivityPoints(){
 	return activity_points_;
 }
@@ -142,10 +138,14 @@ void Unit::setLocation(Cell* to) {
 	location_ = to;
 }
 
-int Unit::getMaxHealthPoints(){
+int Unit::getMaxHealthPoints() {
  	return max_health_points_;  
 }
   	
+int Unit::getHealthPoints() {
+    return health_points_;
+}
+
 void Unit::setHealthPoints(int value){
 	health_points_ = value;
 }

+ 2 - 1
ui/main_menu/mainmenubackground.cpp

@@ -1,6 +1,6 @@
 #include "mainmenubackground.h"
 #include "ui_mainmenubackground.h"
-
+#include <gui/guiscenemanager.h>
 #include <QMovie>
 
 MainMenuBackground::MainMenuBackground(QWidget *parent) :
@@ -10,6 +10,7 @@ MainMenuBackground::MainMenuBackground(QWidget *parent) :
     ui->setupUi(this);
     movie = new QMovie(":/assets/main_menu/tree.gif");
     ui->tree_label->setMovie(movie);
+    ui->version->setText("Версия: " + PROJECT_VERSION);
     movie->start();
 }
 

+ 1 - 1
ui/main_menu/mainmenubackground.ui

@@ -78,7 +78,7 @@ color: rgb(255, 255, 255);
 border-image: none;</string>
         </property>
         <property name="text">
-         <string>Версия: 0.3.0dev</string>
+         <string>Версия: 0.0.0</string>
         </property>
         <property name="alignment">
          <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>