Created
May 22, 2023 08:15
-
-
Save GeertHauwaerts/a66b3d372f7102e8abf5899226605495 to your computer and use it in GitHub Desktop.
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
<?php | |
new IdelonAnvilMaterials([ | |
'Bullfrog Horn', | |
'Frog Leg', | |
'Frog Leg', | |
'Bullfrog Horn', | |
'Spore Cap', | |
'Spore Cap', | |
'Spore Cap', | |
'Spore Cap', | |
]); | |
class IdelonAnvilMaterials | |
{ | |
const MATERIALS = [ | |
'Spore Cap' => 38, | |
'Frog Leg' => 446, | |
'Bean Slices' => 1129, | |
'Slime Sludge' => 13342, | |
'Carror Cube' => 5710, | |
'Gublin Ear' => 8443, | |
'Bullfrog Horn' => 11503, | |
'Pocket Sand' => 14844, | |
'Crabby Cakey' => 18449, | |
'Coconotnotto' => 22302, | |
'Pincer Arm' => 36119, | |
'High Steaks' => 56115, | |
'Wakka Cherry' => 69153, | |
'Shrapshell' => 83052, | |
'Melty Cube' => 97751, | |
'Sticky Stick' => 137768, | |
'Pen' => 161274, | |
'Sippy Straw' => 253626, | |
'Ram Wool' => 181978, | |
'Purple Mush Cap' => 286469, | |
'Half Eaten Donut' => 276091, | |
'Genie Lamp' => 305321, | |
'Bottle Cap' => 335497, | |
'Tongue Bone' => 495864, | |
'Empty Oyster Shell' => 852041, | |
'Condensed Zap' => 1725370, | |
]; | |
private $farm = []; | |
public function __construct($players = []) | |
{ | |
foreach ($players as $material) { | |
$materials = $this->getMaterials($material); | |
foreach ($materials as $name => $quantity) { | |
if (!isset($this->farm[$name])) { | |
$this->farm[$name] = 0; | |
} | |
$this->farm[$name] += $quantity; | |
} | |
} | |
foreach (array_keys(self::MATERIALS) as $material) { | |
printf("%-20s %20s\n", $material, number_format($this->farm[$material], 0, ',', '.')); | |
} | |
} | |
private function getMaterials($material): array | |
{ | |
$materials = []; | |
$completed = true; | |
foreach (self::MATERIALS as $name => $quantity) { | |
if ($name === $material || !$completed) { | |
$completed = false; | |
$materials[$name] = $quantity; | |
} | |
} | |
return $materials; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment