SimulationCraft
SimulationCraft is a tool to explore combat mechanics in the popular MMO RPG World of Warcraft (tm).
azerite_data.hpp
1 // ==========================================================================
2 // Dedmonwakeen's Raid DPS/TPS Simulator.
3 // Send questions to [email protected]
4 // ==========================================================================
5 #ifndef AZERITE_DATA_HPP
6 #define AZERITE_DATA_HPP
7 
8 #include <vector>
9 #include <unordered_map>
10 #include <functional>
11 
12 #include "util/util.hpp"
13 #include "rapidjson/document.h"
14 #include "report/reports.hpp"
15 
16 #include "util/timespan.hpp"
17 
20 struct spell_data_t;
21 struct item_t;
22 struct player_t;
23 struct sim_t;
24 struct action_t;
25 struct expr_t;
26 struct special_effect_t;
27 struct spelleffect_data_t;
28 
29 namespace azerite
30 {
31 class azerite_state_t;
32 }
33 
43 {
45  const player_t* m_player;
47  const spell_data_t* m_spell;
49  std::vector<unsigned> m_ilevels;
51  mutable std::vector<double> m_value;
53  const azerite_power_entry_t* m_data;
54 
56  bool check_combat_rating_penalty( size_t index = 1 ) const;
57 public:
59  enum time_type
60  {
61  MS = 0,
62  S,
63  };
64 
65  using azerite_value_fn_t = std::function<double(const azerite_power_t&)>;
66 
68  azerite_power_t( const player_t* p, const azerite_power_entry_t* data, const std::vector<const item_t*>& items );
69  azerite_power_t( const player_t* p, const azerite_power_entry_t* data, std::vector<unsigned> ilevels );
70 
73  operator const spell_data_t*() const;
74 
76  bool ok() const;
78  bool enabled() const;
80  const spell_data_t* spell() const;
82  const spell_data_t& spell_ref() const;
84  double value( size_t index = 1 ) const;
86  double value( const azerite_value_fn_t& fn ) const;
88  timespan_t time_value( size_t index = 1, time_type tt = MS ) const;
90  double percent( size_t index = 1 ) const;
92  std::vector<double> budget( size_t index ) const;
95  std::vector<double> budget( const spelleffect_data_t* effect ) const;
96  std::vector<double> budget( const spelleffect_data_t& effect ) const;
98  std::vector<unsigned> ilevels() const;
100  unsigned n_items() const;
102  const azerite_power_entry_t* data() const;
103 };
104 
105 enum class essence_type : unsigned
106 {
107  INVALID,
108  MAJOR,
109  MINOR,
110  PASSIVE
111 };
112 
113 enum class essence_spell : unsigned
114 {
115  BASE = 0u,
116  UPGRADE
117 };
118 
120 {
122  const player_t* m_player;
124  const azerite_essence_entry_t* m_essence;
126  std::vector<const spell_data_t*> m_base_major, m_base_minor;
128  std::vector<const spell_data_t*> m_upgrade_major, m_upgrade_minor;
130  unsigned m_rank;
132  essence_type m_type;
133 
134 public:
137  azerite_essence_t( const player_t* player );
139  azerite_essence_t( const player_t* player, essence_type t, unsigned rank,
140  const azerite_essence_entry_t* essence );
142  azerite_essence_t( const player_t* player, const spell_data_t* passive );
143 
145  bool enabled() const;
146 
147  const player_t* player() const
148  { return m_player; }
149 
150  const char* name() const;
151 
152  unsigned rank() const
153  { return m_rank; }
154 
155  bool is_minor() const
156  { return m_type == essence_type::MINOR; }
157 
158  bool is_major() const
159  { return m_type == essence_type::MAJOR; }
160 
161  bool is_passive() const
162  { return m_type == essence_type::PASSIVE; }
163 
164  // Accessor to return neck item
165  const item_t* item() const;
166 
168  const spell_data_t* spell( unsigned rank, essence_spell s, essence_type t = essence_type::INVALID ) const;
170  const spell_data_t* spell( unsigned rank, essence_type t = essence_type::INVALID ) const;
172  const spell_data_t& spell_ref( unsigned rank, essence_spell s, essence_type t = essence_type::INVALID ) const;
174  const spell_data_t& spell_ref( unsigned rank, essence_type t = essence_type::INVALID ) const;
176  std::vector<const spell_data_t*> spells( essence_spell s = essence_spell::BASE, essence_type t = essence_type::INVALID ) const;
177 };
178 
179 namespace azerite
180 {
186 {
188  player_t* m_player;
190  std::unordered_map<unsigned, std::vector<const item_t*>> m_items;
192  std::unordered_map<unsigned, std::vector<const item_t*>> m_spell_items;
194  std::unordered_map<unsigned, std::vector<unsigned>> m_overrides;
195 
196 public:
198 
202  void initialize();
203 
205  azerite_power_t get_power( unsigned id );
207  azerite_power_t get_power( util::string_view name, bool tokenized = false );
208 
210  bool is_enabled( unsigned id ) const;
212  bool is_enabled( util::string_view name, bool tokenized = false ) const;
214  size_t rank( unsigned id ) const;
216  size_t rank( util::string_view name, bool tokenized = false ) const;
217 
219  bool parse_override( sim_t*, util::string_view /*name*/, util::string_view /*value*/ );
221  std::string overrides_str() const;
223  void copy_overrides( const std::unique_ptr<azerite_state_t>& other );
224 
226  std::unique_ptr<expr_t> create_expression( util::span<const util::string_view> expr_str ) const;
227 
229  std::vector<unsigned> enabled_spells() const;
230 
231  // Generate HTML report table output for the azerite data
232  report::sc_html_stream& generate_report( report::sc_html_stream& root ) const;
233 };
234 
236 {
237  class slot_state_t
238  {
239  essence_type m_type;
240  unsigned m_id;
241  unsigned m_rank;
242 
243  public:
244  slot_state_t() : m_type( essence_type::INVALID ), m_id( 0u ), m_rank( 0u )
245  { }
246 
247  slot_state_t( essence_type t, unsigned id, unsigned rank ) :
248  m_type( t ), m_id( id ), m_rank( rank )
249  { }
250 
251  unsigned rank() const
252  { return m_rank; }
253 
254  bool enabled() const
255  { return rank() != 0; }
256 
257  unsigned id() const
258  { return m_id; }
259 
260  essence_type type() const
261  { return m_type; }
262 
263  std::string str() const
264  {
265  return util::to_string( m_id ) + ":" +
266  util::to_string( m_rank ) + ":" +
267  ( type() == essence_type::MAJOR ? '1' : '0' );
268  }
269  };
270 
271  const player_t* m_player;
272  std::vector<slot_state_t> m_state;
273  std::string m_option_str;
274 
275 public:
276  azerite_essence_state_t( const player_t* player );
277 
278  azerite_essence_t get_essence( unsigned id ) const;
279  azerite_essence_t get_essence( util::string_view name, bool tokenized = false ) const;
280 
282  bool add_essence( essence_type type, unsigned id, unsigned rank );
283 
285  void copy_state( const std::unique_ptr<azerite_essence_state_t>& other );
286 
287  bool parse_azerite_essence( sim_t*, util::string_view /* name */, util::string_view /* value */ );
288 
290  std::unique_ptr<expr_t> create_expression( util::span<const util::string_view> expr_str ) const;
291 
292  std::vector<unsigned> enabled_essences() const;
293 
294  std::string option_str() const;
295 
296  void update_traversal_nodes();
297 
298  // Generate HTML report table output for the azerite data
299  report::sc_html_stream& generate_report( report::sc_html_stream& root ) const;
300 };
301 
303 std::unique_ptr<azerite_state_t> create_state( player_t* );
305 std::unique_ptr<azerite_essence_state_t> create_essence_state( player_t* );
307 void initialize_azerite_powers( player_t* actor );
309 void initialize_azerite_essences( player_t* actor );
311 void register_azerite_powers();
313 void register_azerite_target_data_initializers( sim_t* );
315 action_t* create_action( player_t* p, util::string_view name, util::string_view options );
316 
318 std::tuple<int, int, int> compute_value( const azerite_power_t& power,
319  const spelleffect_data_t& effect );
320 
322 void parse_blizzard_azerite_information( item_t& item, const rapidjson::Value& data );
323 
324 namespace special_effects
325 {
326 void resounding_protection( special_effect_t& effect );
327 void elemental_whirl( special_effect_t& effect );
328 void blood_siphon( special_effect_t& effect );
329 void lifespeed( special_effect_t& effect );
330 void on_my_way( special_effect_t& effect );
331 void champion_of_azeroth( special_effect_t& effect );
332 void unstable_flames( special_effect_t& );
333 void thunderous_blast( special_effect_t& );
334 void filthy_transfusion( special_effect_t& );
335 void retaliatory_fury( special_effect_t& );
336 void blood_rite( special_effect_t& );
337 void glory_in_battle( special_effect_t& );
338 void sylvanas_resolve( special_effect_t& );
339 void tidal_surge( special_effect_t& );
340 void heed_my_call( special_effect_t& );
341 void azerite_globules( special_effect_t& );
342 void overwhelming_power( special_effect_t& );
343 void earthlink( special_effect_t& );
344 void wandering_soul( special_effect_t& );
345 void swirling_sands( special_effect_t& );
346 void tradewinds( special_effect_t& );
347 void unstable_catalyst( special_effect_t& );
348 void stand_as_one( special_effect_t& );
349 void archive_of_the_titans( special_effect_t& );
350 void laser_matrix( special_effect_t& );
351 void incite_the_pack( special_effect_t& );
352 void dagger_in_the_back( special_effect_t& );
353 void rezans_fury( special_effect_t& );
354 void secrets_of_the_deep( special_effect_t& );
355 void combined_might( special_effect_t& );
356 void relational_normalization_gizmo( special_effect_t& );
357 void barrage_of_many_bombs( special_effect_t& );
358 void meticulous_scheming( special_effect_t& );
359 void synaptic_spark_capacitor( special_effect_t& );
360 void ricocheting_inflatable_pyrosaw( special_effect_t& );
361 void gutripper( special_effect_t& );
362 void battlefield_focus_precision( special_effect_t& );
363 void endless_hunger( special_effect_t& effect );
364 void apothecarys_concoctions( special_effect_t& effect );
365 void shadow_of_elune( special_effect_t& effect );
366 void treacherous_covenant( special_effect_t& effect );
367 void seductive_power( special_effect_t& effect );
368 void bonded_souls( special_effect_t& effect );
369 void fight_or_flight( special_effect_t& effect );
370 void undulating_tides( special_effect_t& effect );
371 void loyal_to_the_end( special_effect_t& effect );
372 void arcane_heart( special_effect_t& effect );
373 void clockwork_heart( special_effect_t& effect );
374 void personcomputer_interface( special_effect_t& effect );
375 void heart_of_darkness( special_effect_t& effect );
376 void impassive_visage( special_effect_t& effect );
377 void gemhide(special_effect_t& effect);
378 void crystalline_carapace(special_effect_t& effect);
379 } // Namespace special_effects ends
380 
381 namespace azerite_essences
382 {
383 void stamina_milestone( special_effect_t& effect );
384 void the_crucible_of_flame( special_effect_t& effect );
385 void essence_of_the_focusing_iris( special_effect_t& effect );
386 void blood_of_the_enemy( special_effect_t& effect );
387 void condensed_life_force( special_effect_t& effect );
388 void conflict_and_strife( special_effect_t& effect );
389 void purification_protocol( special_effect_t& effect );
390 void ripple_in_space( special_effect_t& effect );
391 void the_unbound_force( special_effect_t& effect );
392 void worldvein_resonance( special_effect_t& effect );
393 void strive_for_perfection( special_effect_t& effect );
394 void vision_of_perfection( special_effect_t& effect );
395 void anima_of_life_and_death( special_effect_t& effect );
396 void nullification_dynamo( special_effect_t& effect );
397 void aegis_of_the_deep( special_effect_t& effect );
398 void sphere_of_suppression( special_effect_t& effect );
399 void breath_of_the_dying( special_effect_t& effect );
400 void spark_of_inspiration( special_effect_t& effect );
401 void formless_void( special_effect_t& effect );
402 void strength_of_the_warden( special_effect_t& effect );
403 void unwavering_ward( special_effect_t& effect );
404 void spirit_of_preservation( special_effect_t& effect );
405 void touch_of_the_everlasting( special_effect_t& effect );
406 } // Namepsace azerite_essences ends
407 
408 // Vision of Perfection CDR helper
409 double vision_of_perfection_cdr( const azerite_essence_t& essence );
410 
411 } // Namespace azerite ends
412 
413 #endif /* AZERITE_DATA_HPP */
414 
Definition: azerite.hpp:12
Definition: azerite.hpp:29
Definition: sc_druid.cpp:2641
Definition: spell_data.hpp:398
Definition: action.hpp:47
Definition: unique_gear.cpp:62
std::string to_string(const T &t)
Converts value to std::string using the default format for type T.
Definition: util.hpp:238
A class representing a single azerite power and the actors items associated with the power...
Definition: azerite_data.hpp:42
time_type
Time type conversion for azerite_power_t::time_value.
Definition: azerite_data.hpp:59
Definition: azerite_data.hpp:235
Definition: item.hpp:60
Class for representing InGame time.
Definition: timespan.hpp:37
Definition: player.hpp:109
Definition: io.hpp:64
Action expression.
Definition: expressions.hpp:79
Definition: spell_data.hpp:145
Definition: sc_demon_hunter.cpp:52
A state class that holds the composite of all azerite-related state an actor has. ...
Definition: azerite_data.hpp:185
Definition: core.h:1208
Simulation engine.
Definition: sim.hpp:61
Definition: azerite_data.cpp:339
Definition: azerite_data.hpp:119
Definition: special_effect.hpp:39