forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bonuses.h
94 lines (75 loc) · 2.07 KB
/
bonuses.h
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
85
86
87
88
89
90
91
92
93
94
#pragma once
#ifndef CATA_SRC_BONUSES_H
#define CATA_SRC_BONUSES_H
#include <iosfwd>
#include <map>
#include <vector>
#include "damage.h"
class Character;
class JsonArray;
class JsonObject;
enum scaling_stat : int {
STAT_NULL = 0,
STAT_STR,
STAT_DEX,
STAT_INT,
STAT_PER,
NUM_STATS
};
enum class affected_stat : int {
NONE = 0,
HIT,
CRITICAL_HIT_CHANCE,
DODGE,
BLOCK,
BLOCK_EFFECTIVENESS,
SPEED,
MOVE_COST,
DAMAGE,
ARMOR,
ARMOR_PENETRATION,
TARGET_ARMOR_MULTIPLIER,
NUM_AFFECTED
};
// We'll be indexing bonuses with this
struct affected_type {
public:
explicit affected_type( affected_stat s );
affected_type( affected_stat s, damage_type t );
bool operator<( const affected_type & ) const;
bool operator==( const affected_type & ) const;
affected_stat get_stat() const {
return stat;
}
damage_type get_damage_type() const {
return type;
}
private:
affected_stat stat = affected_stat::NONE;
damage_type type = damage_type::NONE;
};
// This is the bonus we are indexing
struct effect_scaling {
scaling_stat stat;
float scale;
float get( const Character &u ) const;
explicit effect_scaling( const JsonObject &obj );
};
class bonus_container
{
public:
bonus_container();
void load( const JsonObject &jo );
float get_flat( const Character &u, affected_stat stat, damage_type dt ) const;
float get_flat( const Character &u, affected_stat stat ) const;
float get_mult( const Character &u, affected_stat stat, damage_type dt ) const;
float get_mult( const Character &u, affected_stat stat ) const;
std::string get_description() const;
private:
void load( const JsonArray &jarr, bool mult );
using bonus_map = std::map<affected_type, std::vector<effect_scaling>>;
/** All kinds of bonuses by types to damage, hit etc. */
bonus_map bonuses_flat;
bonus_map bonuses_mult;
};
#endif // CATA_SRC_BONUSES_H