aboutsummaryrefslogtreecommitdiff
path: root/game/gst.h
blob: 906b372eec7180f0e1e4c03ece51e7c28ae7fae3 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef GST_H
#define GST_H

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

#include "ground.h"
#include "entity.h"
#include "tile.h"
#include "player.h"
#include "tech.h"

class Ability {
    public:
    Ability(std::string name) : name(name) {}
    std::string name;
};

class Bonus {
    public: 
    Bonus(float amt, int id, bool atk) : amt(amt), id(id), atk(atk) {}
    float amt; int id; bool atk;
    enum Id { ground, type, ability, tech };
    std::string id_string () {
        switch (id) {
            case ground: return "Ground";
            case type: return "Class";
            case ability: return "Ability";
            case tech: return "Tech";
        }
    }
};

class BattleResult {
    public:
    BattleResult(float atk_hp, float def_hp) 
        : atk_hp(atk_hp), def_hp(def_hp) {}
    float atk_hp, def_hp;
};

class Gst {
    public:
    Gst(int sx, int sy) : ground(sx, sy) {}
    
    std::vector<Tech> techs;
    std::vector<Ability> abilities;
    std::vector<EntityInfo> infos;
    std::vector<Tile> tiles;
    std::vector<Entity> entities;
    Ground ground;
    
    std::vector<Player> players;
    
    EntityInfo* get_info (std::string name);
    EntityInfo* get_info (int id);
    bool info_has_ability (EntityInfo* info, std::string name);
    Entity& get_at (int x, int y);
    
    float get_type_bonus (Entity &atk, Entity &def);
    std::vector<Bonus> get_bonuses (Entity &atk, Entity &def);
    float get_damage (Entity &atk, Entity &def);
    float get_damage (Entity &atk, Entity &def, float atk_hp);
    bool get_first_strike (Entity &atk, Entity &def);
    BattleResult battle_res (Entity &atk, Entity &def);
    void battle (Entity &atk, Entity &def);
    void clear_dead();    
    int get_range(Entity &ent);
    
    std::vector<int> get_possible_builds (Entity &ent);
    
    bool check_req_build(Entity &ent, EntityInfo *info);
    
    bool check_obstructed (Entity &ent);
    
    int turn { 0 };
    int day { 0 };
    
    void end_day ();
};

#endif