-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed Affix Damage and replaced it with damage_amount. There are fa…
…iling tests.
- Loading branch information
Showing
14 changed files
with
248 additions
and
56 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
app/Console/AfterDeployment/ChangeDamageAmountOnAffixes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<?php | ||
|
||
namespace App\Console\AfterDeployment; | ||
|
||
use App\Flare\ExponentialCurve\Curve\ExponentialAttributeCurve; | ||
use App\Flare\Models\ItemAffix; | ||
use App\Flare\Values\ItemAffixType; | ||
use App\Flare\Values\RandomAffixDetails; | ||
use Illuminate\Console\Command; | ||
|
||
class ChangeDamageAmountOnAffixes extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'change:damage-amount-on-affixes'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Changes the damage amount on affixes'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(ExponentialAttributeCurve $exponentialAttributeCurve) { | ||
$regularStackingAffixes = ItemAffix::whereNotNull('damage') | ||
->where('randomly_generated', false) | ||
->where('affix_type', ItemAffixType::DAMAGE_STACKING) | ||
->orderBy('skill_level_required', 'asc') | ||
->get(); | ||
|
||
$damageAmounts = $this->generateFloats( | ||
$exponentialAttributeCurve, | ||
$regularStackingAffixes->count(), | ||
0.02, | ||
0.6, | ||
0.5, | ||
0.03, | ||
); | ||
|
||
$regularStackingAffixes->each(function($affix, $index) use($damageAmounts) { | ||
$affix->update([ | ||
'damage_amount' => $damageAmounts[$index], | ||
]); | ||
}); | ||
|
||
$regularNonStackingAffixes = ItemAffix::whereNotNull('damage') | ||
->where('randomly_generated', false) | ||
->where('affix_type', ItemAffixType::DAMAGE_IRRESISTIBLE) | ||
->orderBy('skill_level_required', 'asc') | ||
->get(); | ||
|
||
$damageAmounts = $this->generateFloats( | ||
$exponentialAttributeCurve, | ||
$regularNonStackingAffixes->count(), | ||
0.02, | ||
1.25, | ||
0.5, | ||
0.03, | ||
); | ||
|
||
$regularNonStackingAffixes->each(function($affix, $index) use($damageAmounts) { | ||
$affix->update([ | ||
'damage_amount' => $damageAmounts[$index], | ||
]); | ||
}); | ||
|
||
$affixCots = [ | ||
RandomAffixDetails::BASIC, | ||
RandomAffixDetails::MEDIUM, | ||
RandomAffixDetails::LEGENDARY, | ||
RandomAffixDetails::MYTHIC, | ||
]; | ||
|
||
foreach ($affixCots as $cost) { | ||
$stackingUniqueAffixes = ItemAffix::whereNotNull('damage') | ||
->where('randomly_generated', true) | ||
->where('irresistible_damage', false) | ||
->where('damage_can_stack', true) | ||
->where('affix_type', ItemAffixType::RANDOMLY_GENERATED) | ||
->where('cost', $cost) | ||
->get(); | ||
|
||
$stackingUniqueAffixes->each(function($affix) use($cost) { | ||
$damageValues = (new RandomAffixDetails($cost))->getDamageRange(); | ||
|
||
$affix->update([ | ||
'damage_amount' => rand($damageValues[0], $damageValues[1]) / 100, | ||
]); | ||
}); | ||
|
||
$nonStackingUniqueAffixes = ItemAffix::where('randomly_generated', true) | ||
->where('affix_type', ItemAffixType::RANDOMLY_GENERATED) | ||
->where('irresistible_damage', true) | ||
->where('damage_can_stack', false) | ||
->where('cost', $cost) | ||
->get(); | ||
|
||
$nonStackingUniqueAffixes->each(function($affix) use($cost) { | ||
$damageValues = (new RandomAffixDetails($cost))->getDamageRange(); | ||
|
||
$affix->update([ | ||
'damage_amount' => rand($damageValues[0], $damageValues[1]) / 100, | ||
]); | ||
}); | ||
} | ||
} | ||
|
||
protected function generateFloats(ExponentialAttributeCurve $exponentialAttributeCurve, float $size, float $min, float $max, float $increase, float $range): array { | ||
$curve = $exponentialAttributeCurve->setMin($min) | ||
->setMax($max) | ||
->setIncrease($increase) | ||
->setRange($range); | ||
|
||
return $curve->generateValues($size, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
database/migrations/2024_01_04_213628_add_affix_damage_amount_to_item_affixes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('item_affixes', function (Blueprint $table) { | ||
$table->float('damage_amount', 12, 8)->nullable(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('item_affixes', function (Blueprint $table) { | ||
// | ||
}); | ||
} | ||
}; |
28 changes: 28 additions & 0 deletions
28
database/migrations/2024_01_04_224949_drop_damage_from_item_affixes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('item_affixes', function (Blueprint $table) { | ||
$table->dropColumn('damage'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('item_affixes', function (Blueprint $table) { | ||
// | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.