ソースを参照

Merge branch 'spelleffects' of GooseHouse/game-client into dev

Ivan Arkhipov 6 年 前
コミット
0c20c95055

+ 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

+ 0 - 31
effect.h

@@ -1,31 +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"
-enum typeEffect{damage, strength};
-class Effect {
-
-private:
-    int count_;
-    typeEffect typeEffect_;
-public:
-    Effect() = delete;
-    Effect(std::string path) {
-
-    }
-    virtual ~Effect() = delete;
-
-    int getCount();
-    void setCount(int value);
-
-    typeEffect getType();
-    void setType(typeEffect value);
-};
-#endif //THE_GAME_EFFECT_H

+ 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

+ 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

+ 68 - 0
include/skills/spell.h

@@ -0,0 +1,68 @@
+//
+// Created by IgorBat on 17.03.2018.
+//
+
+#ifndef THE_GAME_SPELL_H
+#define THE_GAME_SPELL_H
+
+#pragma once
+#include <iostream>
+#include <vector>
+#include <list>
+//#include "AbstractFactory.h"
+#include "effect.h"
+
+class Unit{
+    std :: list <Effect> effectsOnUnit;
+};
+class Cell{
+    std :: list <Effect> effectsOnCell;
+};
+class Spell : public QObject {
+    Q_OBJECT
+
+protected:
+    std :: list <Effect> effects_;
+private:
+    int distance_;
+    bool forCell_;
+public:
+    explicit Spell(QString parameters);
+
+    virtual ~Spell() {}
+
+    int getDistance();
+    void setDistance(int value);
+
+    bool getForCell();
+    void setForCell(bool value);
+
+    virtual bool canCastToCell(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;
+
+    //---------------------------------------------//
+    //-----------Parameters load section-----------//
+    //---------------------------------------------//
+
+private:
+    void loadSpellTraits(QString spell_folder);
+    void loadSpellDescr(QString spell_folder);
+    void loadSpellIcon(QString spell_folder);
+
+    // 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
+}

+ 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);
+}

+ 75 - 0
source/skills/spell.cpp

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

+ 0 - 44
spell.h

@@ -1,44 +0,0 @@
-//
-// Created by IgorBat on 17.03.2018.
-//
-
-#ifndef THE_GAME_SPELL_H
-#define THE_GAME_SPELL_H
-
-#pragma once
-#include <iostream>
-#include <vector>
-//#include "AbstractFactory.h"
-#include "effect.h"
-class Cell;
-
-class Spell {
-
-protected:
-    std::vector <Effect> effects_;
-
-private:
-    int distance_;
-    bool forCell_;
-public:
-    Spell() = delete;
-    Spell(std::string path) {
-
-    }
-    virtual ~Spell() = delete;
-
-    int getDistance();
-    void setDistance(int value);
-
-    bool getForCell();
-    void setForCell(bool value);
-
-    int lenOfActualPath(Cell* destination);
-
-    virtual bool canCastForDistance(int distance);
-
-    virtual bool canCastToCell(Cell* destination);
-
-    virtual void castToCell(Cell* destination);
-};
-#endif //THE_GAME_SPELL_H