Skip to content

Commit

Permalink
Add highest deflector to players command
Browse files Browse the repository at this point in the history
  • Loading branch information
MoT3rror committed Feb 27, 2021
1 parent 688452f commit eac3ea9
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/DiscordMessages/Players.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public function message(): array
case 'earning_bonus':
$table->addColumn('earning_bonus', new Column('EB', Column::ALIGN_LEFT));
break;
case 'highest_deflector':
$table->addColumn('highest_deflector', new Column('Deflector', Column::ALIGN_LEFT));
break;
}
}

Expand All @@ -51,6 +54,7 @@ public function message(): array
'egg_inc' => $user->egg_inc_player_id,
'rank' => str_replace('farmer', '', $user->getPlayerEggRank()),
'earning_bonus' => $user->getPlayerEarningBonusFormatted(),
'highest_deflector' => $user->getHighestDeflectorAttribute(),
];
}

Expand Down
60 changes: 59 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class User extends Authenticatable
'discord_token_expires' => 'datetime',
];

protected $appends = ['player_earning_bonus_formatted', 'player_egg_rank', 'drones', 'soul_eggs', 'eggs_of_prophecy', 'player_earning_bonus', 'soul_eggs_needed_for_next_rank', 'p_e_needed_for_next_rank', 'egg_inc_username'];
protected $appends = ['player_earning_bonus_formatted', 'player_egg_rank', 'drones', 'soul_eggs', 'eggs_of_prophecy', 'player_earning_bonus', 'soul_eggs_needed_for_next_rank', 'p_e_needed_for_next_rank', 'egg_inc_username', 'highest_deflector'];

protected $with = ['roles'];

Expand Down Expand Up @@ -335,6 +335,64 @@ public function getCompleteContractsAttribute(): array
return $complete;
}

public function getHighestDeflectorAttribute(): string
{
$info = $this->getEggPlayerInfo();

if (!$info) {
return '0%';
}
$inventoryitems = collect($info->artifactsDb->inventoryItems)
->where('artifact.spec.name', 'THE_CHALICE')
;

$highest = 0;
$value = 0;
foreach ($inventoryitems as $inventoryitem) {
switch ($inventoryitem->artifact->spec->level) {
case 'INFERIOR':
$value = 5;
break;
case 'LESSER':
$value = 8;
break;
case 'NORMAL':
switch ($inventoryitem->artifact->spec->rarity) {
case 'COMMON':
$value = 12;
break;
case 'RARE':
$value = 13;
break;
}

// rarity: COMMON, RARE, EPIC
break;
case 'GREATER':
switch ($inventoryitem->artifact->spec->rarity) {
case 'COMMON':
$value = 15;
break;
case 'RARE':
$value = 17;
break;
case 'EPIC':
$value = 19;
break;
case 'LEGENDARY':
$value = 20;
break;
}
break;

}
if ($value > $highest) {
$highest = $value;
}
}
return $highest . '%';
}

public function getUsernameWithRolesAttribute()
{
$roles = $this
Expand Down

0 comments on commit eac3ea9

Please sign in to comment.