<commit_before>#ifndef SWGANH_COMBAT_COMBAT_DATA_H_
#define SWGANH_COMBAT_COMBAT_DATA_H_

#ifndef WIN32
#include <Python.h>
#endif

#include <cstdint>
#include <unordered_map>

#include <anh/hash_string.h>
#include "swganh/command/command_properties.h"

#include <boost/python.hpp>

namespace swganh {
namespace combat {

struct CombatData : swganh::command::CommandProperties
{
    // TEMP
    class StateEffect;
    class DotEffect;
    CombatData(swganh::command::CommandProperties&& properties) 
        : swganh::command::CommandProperties(properties)
        , min_damage(0)
        , max_damage(0)
        , damage_multiplier(0)
        , accuracy_bonus(0)
        , speed_multiplier(0)
        , pool(0)
        , attack_delay_chance(0)
        , state_duration(0)
        , dot_duration(0)
        , dot_type(0)
        , dot_pool(0)
        , dot_strength(0)
        , dot_potency(0)
        , range (0)
        , cone_angle(0)
        , area_range(0)
        , animation_crc(anh::HashString(""))
    {
    }
    CombatData(boost::python::object p_object, swganh::command::CommandProperties& properties );

    int min_damage;
    int max_damage;

    float damage_multiplier;
    int accuracy_bonus;
    float speed_multiplier;
    int pool;
    
    int attack_delay_chance;
    int state_duration;

    // DoTs
    uint32_t dot_duration;
    uint64_t dot_type;
    uint8_t dot_pool;
    uint32_t dot_strength;
    float dot_potency;

    int range;
    int cone_angle;
    int area_range;

    anh::HashString animation_crc;

    void GetPythonData(boost::python::object global);

    bool IsRandomPool();
    int GetDamagingPool();
    
    template <typename T>
    void ExtractData(boost::python::object& p_object, std::string key, T& extract_value)
    {
        if (p_object.contains(key))
        {
            boost::python::extract<T> tmp_x(p_object[key]);
            if (tmp_x.check())
                extract_value = tmp_x();
        }
    }
    
    static std::string HIT_spam() { return "_hit"; }
    static std::string BLOCK_spam() { return "_block"; }
    static std::string DODGE_spam() { return "_evade"; }<commit_msg>Wrapped a python land call with the appropriate lock.<commit_after>#ifndef SWGANH_COMBAT_COMBAT_DATA_H_
#define SWGANH_COMBAT_COMBAT_DATA_H_

#ifndef WIN32
#include <Python.h>
#endif

#include <cstdint>
#include <unordered_map>

#include <anh/hash_string.h>
#include "swganh/command/command_properties.h"
#include "swganh/scripting/utilities.h"
#include <boost/python.hpp>

namespace swganh {
namespace combat {

struct CombatData : swganh::command::CommandProperties
{
    // TEMP
    class StateEffect;
    class DotEffect;
    CombatData(swganh::command::CommandProperties&& properties) 
        : swganh::command::CommandProperties(properties)
        , min_damage(0)
        , max_damage(0)
        , damage_multiplier(0)
        , accuracy_bonus(0)
        , speed_multiplier(0)
        , pool(0)
        , attack_delay_chance(0)
        , state_duration(0)
        , dot_duration(0)
        , dot_type(0)
        , dot_pool(0)
        , dot_strength(0)
        , dot_potency(0)
        , range (0)
        , cone_angle(0)
        , area_range(0)
        , animation_crc(anh::HashString(""))
    {
    }
    CombatData(boost::python::object p_object, swganh::command::CommandProperties& properties );

    int min_damage;
    int max_damage;

    float damage_multiplier;
    int accuracy_bonus;
    float speed_multiplier;
    int pool;
    
    int attack_delay_chance;
    int state_duration;

    // DoTs
    uint32_t dot_duration;
    uint64_t dot_type;
    uint8_t dot_pool;
    uint32_t dot_strength;
    float dot_potency;

    int range;
    int cone_angle;
    int area_range;

    anh::HashString animation_crc;

    void GetPythonData(boost::python::object global);

    bool IsRandomPool();
    int GetDamagingPool();
    
    template <typename T>
    void ExtractData(boost::python::object& p_object, std::string key, T& extract_value)
    {
        swganh::scripting::ScopedGilLock lock;
        if (p_object.contains(key))
        {
            boost::python::extract<T> tmp_x(p_object[key]);
            if (tmp_x.check())
                extract_value = tmp_x();
        }
    }
    
    static std::string HIT_spam() { return "_hit"; }
    static std::string BLOCK_spam() { return "_block"; }
    static std::string DODGE_spam() { return "_evade"; }
{'fraction_non_alphanumeric': 0.10940325497287523, 'fraction_numerical': 0.011301989150090416, 'mean_word_length': 2.874781085814361, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4309744', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1499, 'n_words': 274}