Skip to content
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

Add Guild minigame statistics totals and averages #38

Merged
merged 3 commits into from
Jun 27, 2020
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
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

280 changes: 280 additions & 0 deletions .idea/inspectionProfiles/Project.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions app/Http/Controllers/Guild/BedWarsController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/**
/*
* Copyright (c) 2020 Max Korlaar
* All rights reserved.
*
Expand Down Expand Up @@ -109,16 +109,16 @@ private function getBedWarsMemberList(Guild $guild): array {

$totalDeaths = $deaths + $finalDeaths;

$games = $stats->getInt('games_played_bedwars', 0);
$gamesPlayed = $stats->getInt('games_played_bedwars', 0);

if ($totalDeaths !== 0) {
$totalKd = round($totalKills / $totalDeaths, 2);
} else {
$totalKd = 'N/A';
}

if ($wins !== 0 && $games !== 0) {
$winsPercentage = round(($wins / ($games)) * 100, 2);
if ($wins !== 0 && $gamesPlayed !== 0) {
$winsPercentage = round(($wins / $gamesPlayed) * 100, 1);
} else {
$winsPercentage = 0;
}
Expand All @@ -138,15 +138,19 @@ private function getBedWarsMemberList(Guild $guild): array {
return [
'wins' => $wins,
'kills' => $totalKills,
'deaths' => $totalDeaths,
'kd' => $totalKd,
'wins_percentage' => $winsPercentage,
'games_played' => $gamesPlayed,
'beds_broken' => $stats->getInt('beds_broken_bedwars'),

'kills_normal' => $kills,
'kd_normal' => $kd,
'kills_normal' => $kills,
'deaths_normal' => $deaths,
'kd_normal' => $kd,

'kills_final' => $finalKills,
'kd_final' => $finalKd
'kills_final' => $finalKills,
'deaths_final' => $finalDeaths,
'kd_final' => $finalKd
];
});
}
Expand Down
5 changes: 5 additions & 0 deletions app/Http/Controllers/Guild/MemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Illuminate\View\View;
use Log;
use Plancke\HypixelPHP\color\ColorUtils;
use Plancke\HypixelPHP\exceptions\HypixelPHPException;
use Plancke\HypixelPHP\responses\guild\Guild;
Expand Down Expand Up @@ -78,6 +79,10 @@ public function getMembers(Request $request, string $nameOrId) {
return $memberList;
}

if ($guild->getID() === null || $guild->getID() === '') {
Log::error('Guild ID is empty or null', ['guild' => $guild, 'id' => $guild->getID(), 'name' => $nameOrId]);
}

return view('guild.members', [
'guild' => $guild,
'urls' => [
Expand Down
68 changes: 42 additions & 26 deletions app/Http/Controllers/Guild/SkyWarsController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/*
/*
* Copyright (c) 2020 Max Korlaar
* All rights reserved.
*
Expand Down Expand Up @@ -30,7 +30,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

namespace App\Http\Controllers\Guild;
namespace App\Http\Controllers\Guild;

use App\Exceptions\HypixelFetchException;
use App\Utilities\HypixelAPI;
Expand Down Expand Up @@ -97,80 +97,96 @@ private function getSkyWarsMemberList(Guild $guild): array {
/** @var GameStats $stats */
$stats = $player->getStats()->getGameFromID(GameTypes::SKYWARS);

$kills = $stats->getInt('kills');
if ($stats->getInt('deaths') > 0) {
$kd = round($kills / $stats->getInt('deaths'), 2);
$kills = $stats->getInt('kills');
$deaths = $stats->getInt('deaths');
if ($deaths > 0) {
$kd = round($kills / $deaths, 2);
} else {
$kd = 'N/A';
}

$wins = $stats->getInt('wins');
if (($wins + $stats->getInt('losses')) > 0) {
$winsPercentage = round(($wins / ($wins + $stats->getInt('losses'))) * 100, 1);
$wins = $stats->getInt('wins');
$losses = $stats->getInt('losses');
if (($wins + $losses) > 0) {
$winsPercentage = round(($wins / ($wins + $losses)) * 100, 1);
} else {
$winsPercentage = 0;
}

$killsSolo = $stats->getInt('kills_solo');
if ($stats->getInt('deaths_solo') > 0) {
$kdSolo = round($killsSolo / $stats->getInt('deaths_solo'), 2);
$killsSolo = $stats->getInt('kills_solo');
$deathsSolo = $stats->getInt('deaths_solo');
if ($deathsSolo > 0) {
$kdSolo = round($killsSolo / $deathsSolo, 2);
} else {
$kdSolo = 'N/A';
}

$winsSolo = $stats->getInt('wins_solo');
if (($winsSolo + $stats->getInt('losses_solo')) > 0) {
$winsPercentageSolo = round(($winsSolo / ($winsSolo + $stats->getInt('losses_solo'))) * 100, 1);
$winsSolo = $stats->getInt('wins_solo');
$lossesSolo = $stats->getInt('losses_solo');
if (($winsSolo + $lossesSolo) > 0) {
$winsPercentageSolo = round(($winsSolo / ($winsSolo + $lossesSolo)) * 100, 1);
} else {
$winsPercentageSolo = 0;
}

$killsTeam = $stats->getInt('kills_team');
if ($stats->getInt('deaths_team') > 0) {
$kdTeams = round($killsTeam / $stats->getInt('deaths_team'), 2);
$killsTeam = $stats->getInt('kills_team');
$deathsTeam = $stats->getInt('deaths_team');
if ($deathsTeam > 0) {
$kdTeams = round($killsTeam / $deathsTeam, 2);
} else {
$kdTeams = 'N/A';
}

$winsTeam = $stats->getInt('wins_team');
if (($winsTeam + $stats->getInt('losses_team')) > 0) {
$winsPercentageTeams = round(($winsTeam / ($winsTeam + $stats->getInt('losses_team'))) * 100, 1);
$winsTeam = $stats->getInt('wins_team');
$lossesTeam = $stats->getInt('losses_team');
if (($winsTeam + $lossesTeam) > 0) {
$winsPercentageTeams = round(($winsTeam / ($winsTeam + $lossesTeam)) * 100, 1);
} else {
$winsPercentageTeams = 0;
}

$killsMega = $stats->getInt('kills_mega');
if ($stats->getInt('deaths_mega') > 0) {
$kdMega = round($killsMega / $stats->getInt('deaths_mega'), 2);
$killsMega = $stats->getInt('kills_mega');
$deathsMega = $stats->getInt('deaths_mega');
if ($deathsMega > 0) {
$kdMega = round($killsMega / $deathsMega, 2);
} else {
$kdMega = 'N/A';
}

$winsMega = $stats->getInt('wins_mega');
if (($winsMega + $stats->getInt('losses_mega')) > 0) {
$winsPercentageMega = round(($winsMega / ($winsMega + $stats->getInt('losses_mega'))) * 100, 1);
$winsMega = $stats->getInt('wins_mega');
$lossesMega = $stats->getInt('losses_mega');
if (($winsMega + $lossesMega) > 0) {
$winsPercentageMega = round(($winsMega / ($winsMega + $lossesMega)) * 100, 1);
} else {
$winsPercentageMega = 0;
}

return [
'wins' => $wins,
'losses' => $losses,
'kills' => $kills,
'deaths' => $deaths,
'kd' => $kd,
'wins_percentage' => $winsPercentage,

'wins_solo' => $winsSolo,
'losses_solo' => $lossesSolo,
'kills_solo' => $killsSolo,
'deaths_solo' => $deathsSolo,
'kd_solo' => $kdSolo,
'wins_percentage_solo' => $winsPercentageSolo,

'wins_teams' => $winsTeam,
'losses_teams' => $lossesTeam,
'kills_teams' => $killsTeam,
'deaths_teams' => $deathsTeam,
'kd_teams' => $kdTeams,
'wins_percentage_teams' => $winsPercentageTeams,

'wins_mega' => $winsMega,
'losses_mega' => $lossesMega,
'kills_mega' => $killsMega,
'deaths_mega' => $deathsMega,
'kd_mega' => $kdMega,
'wins_percentage_mega' => $winsPercentageMega,
];
Expand Down
19 changes: 11 additions & 8 deletions app/Http/Controllers/Guild/TNTGamesController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/**
/*
* Copyright (c) 2020 Max Korlaar
* All rights reserved.
*
Expand Down Expand Up @@ -30,7 +30,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

namespace App\Http\Controllers\Guild;
namespace App\Http\Controllers\Guild;

use App\Exceptions\HypixelFetchException;
use App\Utilities\HypixelAPI;
Expand Down Expand Up @@ -99,8 +99,8 @@ private function getTNTGamesMemberList(Guild $guild): array {
$killsWizards = $stats->getInt('kills_capture');
$deathsWizards = $stats->getInt('deaths_capture');

$recordTNTRun = gmdate("i:s", $stats->getInt('record_tntrun'));
$recordPVPRun = gmdate("i:s", $stats->getInt('record_pvprun'));
$recordTNTRun = gmdate('i:s', $stats->getInt('record_tntrun'));
$recordPVPRun = gmdate('i:s', $stats->getInt('record_pvprun'));

if ($deathsWizards > 0) {
$kdWizards = round($killsWizards / $deathsWizards, 2);
Expand All @@ -112,17 +112,20 @@ private function getTNTGamesMemberList(Guild $guild): array {
'wins_bowspleef' => $stats->getInt('wins_bowspleef'),
'shots_bowspleef' => $stats->getInt('tags_bowspleef'),

'wins_tntrun' => $stats->getInt('wins_tntrun'),
'record_tntrun' => $recordTNTRun,
'wins_tntrun' => $stats->getInt('wins_tntrun'),
'record_tntrun' => $recordTNTRun,
'record_tntrun_raw' => $stats->getInt('record_tntrun'),

'wins_pvprun' => $stats->getInt('wins_pvprun'),
'record_pvprun' => $recordPVPRun,
'wins_pvprun' => $stats->getInt('wins_pvprun'),
'record_pvprun' => $recordPVPRun,
'record_pvprun_raw' => $stats->getInt('record_pvprun'),

'wins_tnttag' => $stats->getInt('wins_tntag'),
'kills_tnttag' => $stats->getInt('kills_tntag'),

'wins_wizards' => $stats->getInt('wins_capture'),
'kills_wizards' => $killsWizards,
'deaths_wizards' => $deathsWizards,
'assists_wizards' => $stats->getInt('assists_capture'),
'kd_wizards' => $kdWizards,
];
Expand Down
Loading