aboutsummaryrefslogtreecommitdiff
path: root/src/attack.h
blob: 0a9ad6837cf995e017f7eb1e0a4458b53136e100 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
#include "feature.h"
#include "json.hpp"
#include "weapon.h"

typedef nlohmann::json json;

namespace creature {
    class Creature;
}

namespace entry {
    class Attack : public Feature {
        public:
            Attack(const json& data, const json& base): Feature(base), weapon(data["attack"], data["attack"]) {}
            virtual ~Attack() {}

            virtual std::string getText(const creature::Creature& c) const override {return weapon.getText(c) + " " + Entry::getText();}
            Weapon getWeapon(void) {return weapon;}

            json toJson(void) const {
                auto data = Feature::toJson();
                data["attack"] = weapon.toJson();
                return data;
            }

        private:
            const Weapon weapon;
    };
}