Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarStatusTypes.hpp
blob: 0a39501705528a282742d8e6d7c513748545fcd5 (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
85
86
87
88
89
#pragma once

#include "StarJson.hpp"
#include "StarStrongTypedef.hpp"
#include "StarDataStream.hpp"
#include "StarIdMap.hpp"

namespace Star {

STAR_EXCEPTION(StatusException, StarException);

// Multipliers act exactly the way you'd expect: 0.0 is a 100% reduction of the
// base stat, while 2.0 is a 100% increase. Since these are *base* multipliers
// they do not interact with each other, thus stacking a 0.0 and a 2.0 leaves
// the stat unmodified
struct StatBaseMultiplier {
  String statName;
  float baseMultiplier;

  bool operator==(StatBaseMultiplier const& rhs) const;
};

DataStream& operator>>(DataStream& ds, StatBaseMultiplier& baseMultiplier);
DataStream& operator<<(DataStream& ds, StatBaseMultiplier const& baseMultiplier);

struct StatValueModifier {
  String statName;
  float value;

  bool operator==(StatValueModifier const& rhs) const;
};

DataStream& operator>>(DataStream& ds, StatValueModifier& valueModifier);
DataStream& operator<<(DataStream& ds, StatValueModifier const& valueModifier);

// Unlike base multipliers, these all stack multiplicatively with the final
// stat value (including all base and value modifiers) such that an effective
// multiplier of 0.0 will ALWAYS reduce the stat to 0 regardless of other
// effects
struct StatEffectiveMultiplier {
  String statName;
  float effectiveMultiplier;

  bool operator==(StatEffectiveMultiplier const& rhs) const;
};

DataStream& operator>>(DataStream& ds, StatEffectiveMultiplier& effectiveMultiplier);
DataStream& operator<<(DataStream& ds, StatEffectiveMultiplier const& effectiveMultiplier);

typedef MVariant<StatValueModifier, StatBaseMultiplier, StatEffectiveMultiplier> StatModifier;

StatModifier jsonToStatModifier(Json const& config);
Json jsonFromStatModifier(StatModifier const& modifier);

typedef uint32_t StatModifierGroupId;
typedef IdMap<StatModifierGroupId, List<StatModifier>> StatModifierGroupMap;

// Unique stat effects are identified uniquely by name.
typedef String UniqueStatusEffect;

// Second element here is *percentage* of duration remaining, based on the
// highest duration that the effect has had
typedef List<pair<UniqueStatusEffect, Maybe<float>>> ActiveUniqueStatusEffectSummary;

// Persistent status effects can either be a modifier effect or unique effect
typedef MVariant<StatModifier, UniqueStatusEffect> PersistentStatusEffect;

// Reads either a name of a unique stat effect or a stat modifier object
PersistentStatusEffect jsonToPersistentStatusEffect(Json const& config);
Json jsonFromPersistentStatusEffect(PersistentStatusEffect const& effect);

// Ephemeral effects are always unique effects and either use the default
// duration in their config or optionally the default
struct EphemeralStatusEffect {
  UniqueStatusEffect uniqueEffect;
  Maybe<float> duration;

  bool operator==(EphemeralStatusEffect const& rhs) const;
};

DataStream& operator>>(DataStream& ds, EphemeralStatusEffect& ephemeralStatusEffect);
DataStream& operator<<(DataStream& ds, EphemeralStatusEffect const& ephemeralStatusEffect);

// Reads either a name of a unique stat effect or an object containing the
// type name and optionally the duration.
EphemeralStatusEffect jsonToEphemeralStatusEffect(Json const& config);
Json jsonFromEphemeralStatusEffect(EphemeralStatusEffect const& effect);

}