Skip to content

[player] Provide virtual bool validate_actor() #10312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions engine/class_modules/apl/apl_monk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,49 +850,45 @@ void default_apl( monk_t* player )
// Shared Defaults
namespace monk
{
void monk_t::validate_actor()
bool monk_t::validate_actor()
{
if ( specialization() == MONK_MISTWEAVER && !sim->allow_experimental_specializations )
{
if ( !quiet )
sim->error( "Mistweaver Monk for {} is not currently supported.", *this );
quiet = true;
return;
return false;
}

if ( main_hand_weapon.type == WEAPON_NONE )
{
if ( !quiet )
sim->error( "{} has no weapon equipped at the Main-Hand slot.", *this );
quiet = true;
return;
return false;
}

if ( main_hand_weapon.group() == WEAPON_2H && off_hand_weapon.group() == WEAPON_1H )
{
if ( !quiet )
sim->error( "{} both a 1-hand and 2-hand weapon equipped at once.", *this );
quiet = true;
return;
return false;
}

switch ( specialization() )
{
case MONK_BREWMASTER:
case MONK_MISTWEAVER:
case MONK_WINDWALKER:
return;
return true;
default:
sim->error( "No specialization was selected for {}.", *this );
quiet = true;
return;
return false;
}

return false;
}

void monk_t::init_blizzard_action_list()
{
validate_actor();

action_priority_list_t* default_ = get_action_priority_list( "default" );

switch ( specialization() )
Expand Down Expand Up @@ -1026,8 +1022,6 @@ std::string monk_t::default_temporary_enchant() const

void monk_t::init_action_list()
{
validate_actor();

if ( action_list_str.empty() )
{
clear_action_priority_lists();
Expand Down
2 changes: 1 addition & 1 deletion engine/class_modules/monk/sc_monk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ struct monk_t : public stagger_t<parse_player_effects_t, monk_t>
std::string default_temporary_enchant() const override;
void init_action_list() override;
void init_blizzard_action_list() override;
void validate_actor();
bool validate_actor() override;
bool validate_fight_style( fight_style_e style ) const override;
parsed_assisted_combat_rule_t parse_assisted_combat_rule( const assisted_combat_rule_data_t &rule,
const assisted_combat_step_data_t &step ) const override;
Expand Down
47 changes: 27 additions & 20 deletions engine/class_modules/sc_shaman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,7 @@ struct shaman_t : public parse_player_effects_t
void init_items() override;
void init_special_effects() override;
void init_finished() override;
bool validate_actor() override;
std::string create_profile( save_e ) override;
void create_special_effects() override;
action_t* create_proc_action( util::string_view /* name */, const special_effect_t& /* effect */ ) override;
Expand Down Expand Up @@ -14370,6 +14371,31 @@ void shaman_t::init_finished()
apply_player_effects();
}

bool shaman_t::validate_actor()
{
if ( !( primary_role() == ROLE_ATTACK && specialization() == SHAMAN_ENHANCEMENT ) &&
!( primary_role() == ROLE_SPELL && specialization() == SHAMAN_ELEMENTAL ) &&
!( primary_role() == ROLE_SPELL && specialization() == SHAMAN_RESTORATION ) )
{
if ( !quiet )
sim->errorf( "Player %s's role (%s) or spec(%s) isn't supported yet.", name(),
util::role_type_string( primary_role() ), util::specialization_string( specialization() ) );
return false;
}

// Restoration isn't supported atm
if ( !sim->allow_experimental_specializations && specialization() == SHAMAN_RESTORATION &&
primary_role() == ROLE_HEAL )
{
if ( !quiet )
sim->errorf( "Restoration Shaman healing for player %s is not currently supported.", name() );

return false;
}

return true;
}

// shaman_t::apply_affecting_auras ==========================================

void shaman_t::apply_affecting_auras( action_t& action )
Expand Down Expand Up @@ -15073,27 +15099,8 @@ void shaman_t::init_action_list_restoration_dps()

void shaman_t::init_action_list()
{
if ( !( primary_role() == ROLE_ATTACK && specialization() == SHAMAN_ENHANCEMENT ) &&
!( primary_role() == ROLE_SPELL && specialization() == SHAMAN_ELEMENTAL ) &&
!( primary_role() == ROLE_SPELL && specialization() == SHAMAN_RESTORATION ) )
{
if ( !quiet )
sim->errorf( "Player %s's role (%s) or spec(%s) isn't supported yet.", name(),
util::role_type_string( primary_role() ), util::specialization_string( specialization() ) );
quiet = true;
return;
}

// Restoration isn't supported atm
if ( !sim->allow_experimental_specializations && specialization() == SHAMAN_RESTORATION &&
primary_role() == ROLE_HEAL )
{
if ( !quiet )
sim->errorf( "Restoration Shaman healing for player %s is not currently supported.", name() );

quiet = true;
if ( quiet )
return;
}

// After error checks, initialize secondary actions for various things
windfury_mh = new windfury_attack_t( "windfury_attack", this, find_spell( 25504 ), &( main_hand_weapon ) );
Expand Down
7 changes: 7 additions & 0 deletions engine/player/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3826,6 +3826,13 @@ void player_t::init_background_actions()

void player_t::create_actions()
{
// if actor is not valid, set `quiet` and skip the rest of action creation
if ( !validate_actor() )
{
quiet = true;
return;
}

if( is_player() && !is_enemy() && !is_pet() )
consumable::create_consumeable_actions( this );

Expand Down
2 changes: 2 additions & 0 deletions engine/player/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,8 @@ struct player_t : public actor_t
virtual void validate_sim_options() {}
virtual bool validate_fight_style( fight_style_e ) const
{ return true; }
virtual bool validate_actor()
{ return true; }
virtual void init_meta_gem();
virtual void init_resources( bool force = false );
virtual std::vector<std::string> get_item_actions();
Expand Down