Skip to content

Commit

Permalink
Fixed searching for Taunt charms
Browse files Browse the repository at this point in the history
  • Loading branch information
AthenaADP committed Oct 3, 2018
1 parent b889b34 commit 30abf89
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
5 changes: 3 additions & 2 deletions Armor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,12 @@ String^ Charm::GetName()
return Utility::SlotString( num_slots );
else if( abilities.Count == 1 )
{
return FormatString3( CharmFormat1, L"+" + Convert::ToString( abilities[ 0 ]->amount ), abilities[ 0 ]->ability->name, Utility::SlotString( num_slots ) );
String^ num1 = ( abilities[ 0 ]->amount > 0 ? L"+" : L"" ) + Convert::ToString( abilities[ 0 ]->amount );
return FormatString3( CharmFormat1, num1, abilities[ 0 ]->ability->name, Utility::SlotString( num_slots ) );
}
else if( abilities.Count == 2 )
{
String^ num1 = L"+" + Convert::ToString( abilities[ 0 ]->amount );
String^ num1 = ( abilities[ 0 ]->amount > 0 ? L"+" : L"" ) + Convert::ToString( abilities[ 0 ]->amount );
String^ num2 = ( abilities[ 1 ]->amount > 0 ? L"+" : L"" ) + Convert::ToString( abilities[ 1 ]->amount );
return FormatString5( CharmFormat2, num1, abilities[ 0 ]->ability->name, num2, abilities[ 1 ]->ability->name, Utility::SlotString( num_slots ) );
}
Expand Down
Binary file modified CharmDatabase.cpp
Binary file not shown.
11 changes: 2 additions & 9 deletions Form1.h
Original file line number Diff line number Diff line change
Expand Up @@ -3059,7 +3059,8 @@ namespace MHGUASS

System::Void SortResults()
{
if( cmbSort->SelectedIndex < 1 || sort_off ) return;
if( cmbSort->SelectedIndex < 1 || sort_off )
return;
else if( cmbSort->SelectedIndex == 1 )
final_solutions.Sort( gcnew Comparison< Solution^ >( CompareSolutionByDragonRes ) );
else if( cmbSort->SelectedIndex == 2 )
Expand All @@ -3086,14 +3087,6 @@ namespace MHGUASS
final_solutions.Sort( gcnew Comparison< Solution^ >( CompareSolutionsByExtraSkills ) );
}

bool EndsWithSlots( String^% s )
{
return s->EndsWith( L" ---" ) ||
s->EndsWith( L"O--" ) ||
s->EndsWith( L"OO-" ) ||
s->EndsWith( L"OOO" );
}

void contextMenuStrip1_Closing( System::Object^ sender, ToolStripDropDownClosingEventArgs^ e )
{
if( preview_pane )
Expand Down
36 changes: 33 additions & 3 deletions Solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,22 @@ bool Solution::FixBadSkill( Skill^ skill )
{
if( slots_spare[ dec->slots_required + 1 ] == 0 )
{
Assert( slots_spare[ 3 ] > 0, L"Not enough slots spare" );
slots_spare[ 3 ]--;
slots_spare[ 2 ]++;
}
else
{
Assert( data->solution->slots_spare[ dec->slots_required + 1 ] > 0, L"Not enough slots spare" );
slots_spare[ dec->slots_required + 1 ]--;
slots_spare[ 1 ]++;
}
}
else slots_spare[ dec->slots_required ]--;
else
{
Assert( slots_spare[ dec->slots_required ] > 0, L"Not enough slots spare" );
slots_spare[ dec->slots_required ]--;
}

if( AddDecoration( data->solution, dec, 1, non_body_decorations ) )
return true;
Expand Down Expand Up @@ -742,6 +748,8 @@ void Solution::ReduceSlots()
if( i <= 3 )
{
//if( i > charm->num_slots )
Assert( slots_spare[ i ] > 0, L"Not enough slots spare" );

slots_spare[ i - charm->num_slots ]++;
slots_spare[ i ]--;
total_slots_spare -= charm->num_slots;
Expand Down Expand Up @@ -891,8 +899,13 @@ void Solution::AddExtraSkills()
unsigned spare[4] = { 0, slots_spare[1], slots_spare[2], slots_spare[3] };
for( unsigned size = 4; size --> 1; )
{
Assert( (int)slots_spare[ size ] >= 0, L"Negative slots spare?" );
if( (int)slots_spare[ size ] < 0 )
continue;

for( unsigned i = 0; i < slots_spare[size]; ++i )
{
Assert( spare[ size] > 0, L"Not enough slots spare" );
spare[size]--;
unsigned s = size;
while( s > 0 )
Expand Down Expand Up @@ -974,7 +987,10 @@ bool CalculateTaunt( CalculationData^ data )
if( data->query->taunt_decorations.Count == 0 )
return false;

const int effective_total = data->solution->torso_slots_spare * data->solution->torso_multiplier + ( data->solution->total_slots_spare - data->solution->torso_slots_spare );
const int effective_total =
data->solution->torso_slots_spare * data->solution->torso_multiplier +
data->solution->charm_slots_spare * ( data->solution->charm_up ? 1 : 0 ) +
( data->solution->total_slots_spare - data->solution->torso_slots_spare );
int need = have + 10;
if( need > effective_total )
return false;
Expand All @@ -1000,13 +1016,21 @@ bool CalculateTaunt( CalculationData^ data )
}
}
}

while( data->solution->torso_slots_spare > 0 && need > 0 )
{
AddDecoration( data->solution, best, data->solution->torso_multiplier, data->solution->body_decorations );
need -= data->solution->torso_multiplier;
data->solution->torso_slots_spare--;
}

while( data->solution->charm_slots_spare > 0 && need > 0 )
{
AddDecoration( data->solution, best, data->solution->torso_multiplier, data->solution->charm_decorations );
need -= data->solution->charm_up ? 2 : 1;
data->solution->charm_slots_spare--;
}

while( data->solution->total_slots_spare > 0 && need > 0 )
{
AddDecoration( data->solution, best, 1, data->solution->non_body_decorations );
Expand All @@ -1015,16 +1039,22 @@ bool CalculateTaunt( CalculationData^ data )
{
if( data->solution->slots_spare[2] == 0 )
{
Assert( data->solution->slots_spare[ 3 ] > 0, L"Not enough slots spare" );
data->solution->slots_spare[3]--;
data->solution->slots_spare[2]++;
}
else
{
Assert( data->solution->slots_spare[ 2 ] > 0, L"Not enough slots spare" );
data->solution->slots_spare[2]--;
data->solution->slots_spare[1]++;
}
}
else data->solution->slots_spare[1]--;
else
{
Assert( data->solution->slots_spare[ 1 ] > 0, L"Not enough slots spare" );
data->solution->slots_spare[ 1 ]--;
}
}

return true;
Expand Down

0 comments on commit 30abf89

Please sign in to comment.