ソースを参照

add move functions

igorbat99 6 年 前
コミット
8b2e043f1e

+ 2 - 1
assets/effects/effects.txt

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

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

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

BIN
assets/effects/selfmove/icon.png


+ 4 - 0
assets/spells/README.md

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

+ 1 - 3
assets/spells/meleedamagespell/traits.txt

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

+ 1 - 3
assets/spells/selfhealspell/traits.txt

@@ -1,4 +1,2 @@
 1
-1
-0
-selfheal|5|0
+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

+ 2 - 1
assets/spells/spells.txt

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

+ 6 - 2
client.pro

@@ -118,7 +118,9 @@ SOURCES +=                                      \
     source/gui/buttoneventlistener.cpp \
     ui/hotseat_recruitment/iconhint.cpp \
     ui/dialog_form/dialogform.cpp \
-    ui/about_us/aboutus.cpp
+    ui/about_us/aboutus.cpp \
+    source/effects/selfmove.cpp \
+    source/spells/selfmovespell.cpp
 
 HEADERS +=                                      \
     include/abstractfactory.h                   \
@@ -159,7 +161,9 @@ HEADERS +=                                      \
     ui/main_menu/mainmenubackground.h           \
     ui/hotseat_recruitment/iconhint.h           \
     ui/dialog_form/dialogform.h                 \
-    ui/about_us/aboutus.h
+    ui/about_us/aboutus.h \
+    include/effects/selfmove.h \
+    include/spells/selfmovespell.h
 
 FORMS +=                                        \
     ui/hotseat_game/hotseatgame.ui              \

+ 1 - 0
include/effects/effect.h

@@ -48,6 +48,7 @@ private:
 public:
     virtual void OperateOnCell(Cell* cell) = 0;
     virtual void OperateOnUnit(Unit* unit) = 0;
+    virtual void OperateOnUnitToCell(Unit* who, Cell* where) = 0;
 protected:
     int count_;
     int durability_;

+ 1 - 0
include/effects/meleedamage.h

@@ -11,5 +11,6 @@
 class MeleeDamage : public Effect {
     void OperateOnCell(Cell* cell);
     void OperateOnUnit(Unit* unit);
+    void OperateOnUnitToCell(Unit* who, Cell* where);
 };
 #endif //GAME_CLIENT_MELEEDAMAGE_H

+ 1 - 0
include/effects/selfheal.h

@@ -11,6 +11,7 @@
 class SelfHeal : public Effect {
     void OperateOnCell(Cell* cell);
     void OperateOnUnit(Unit* unit);
+    void OperateOnUnitToCell(Unit* who, Cell* where);
 };
 
 #endif //GAME_CLIENT_SELFHEAL_H

+ 13 - 0
include/effects/selfmove.h

@@ -0,0 +1,13 @@
+#ifndef SELFMOVE_H
+#define SELFMOVE_H
+
+#include "effects\effect.h"
+
+class SelfMove : public Effect {
+    void OperateOnUnitAndCell(Unit* who, Cell* where);
+    void OperateOnCell(Cell* cell);
+    void OperateOnUnit(Unit* unit);
+};
+
+
+#endif // SELFMOVE_H

+ 0 - 1
include/spells/selfhealspell.h

@@ -4,7 +4,6 @@
 
 #ifndef GAME_CLIENT_SELFHEAL_H
 #define GAME_CLIENT_SELFHEAL_H
-#pragma once
 #include <cassert>
 #include "spells\spell.h"
 

+ 9 - 0
include/spells/selfmovespell.h

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

+ 4 - 0
source/effects/meleedamage.cpp

@@ -11,6 +11,10 @@ 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){
     //int temp = unit -> reduceIncomingDamage("p", count_);
     //unit ->setHealthPoints(unit -> getHealthPoints() - temp);

+ 4 - 0
source/effects/selfheal.cpp

@@ -15,3 +15,7 @@ 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");
+}

+ 17 - 0
source/effects/selfmove.cpp

@@ -0,0 +1,17 @@
+#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::OperateOnUnitAndCell(Unit* unit, Cell* cell){
+    unit->setLocation(cell);
+}

+ 10 - 0
source/spells/selfmovespell.cpp

@@ -0,0 +1,10 @@
+#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);
+}