Skip to content

Commit

Permalink
Merge pull request #742 from sporchia/v31.0.3
Browse files Browse the repository at this point in the history
V31.0.3
  • Loading branch information
sporchia authored Nov 17, 2019
2 parents 3e36904 + 063661d commit b04fa07
Show file tree
Hide file tree
Showing 96 changed files with 5,340 additions and 3,893 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
.env.debug
.phpunit.result.cache
.php_cs.cache
/.vscode
/.vs
2 changes: 1 addition & 1 deletion app/Boss.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static function all(World $world): BossCollection
|| ($items->has('Bombos') && ($world->config('mode.weapons') === 'swordless' || $items->hasSword()) && $items->canExtendMagic(2) && $items->has('FireRod')))
&& $items->canMeltThings($world) && ($items->has('Hammer') || $items->hasSword()
|| ($items->canExtendMagic(3) && $items->has('FireRod'))
|| ($items->canExtendMagic(2) && $items->has('FireRod') && $items->has('Bombos')));
|| ($items->canExtendMagic(2) && $items->has('FireRod') && $items->has('Bombos') && $world->config('mode.weapons') === 'swordless'));
}),
new static("Vitreous", "Vitreous", function ($locations, $items) use ($world) {
return ($world->config('itemPlacement') !== 'basic' || $items->hasSword(2) || $items->canShootArrows())
Expand Down
64 changes: 45 additions & 19 deletions app/Http/Controllers/CustomizerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,33 @@ public function generateSeed(Request $request)
]);

if ($payload['spoiler']['meta']['tournament'] ?? false) {
if ($payload['spoiler']['meta']['spoilers'] ?? false) {
$return_payload = array_except($return_payload, [
'spoiler.playthrough'
]);
} elseif ($payload['spoiler']['meta']['spoilers_ongen'] ?? false) {
$return_payload = array_except($return_payload, [
'spoiler.playthrough',
]);
} else {
$return_payload['spoiler'] = array_except(array_only($return_payload['spoiler'], [
'meta',
]), ['meta.seed']);
switch ($payload['spoiler']['meta']['spoilers']) {
case "on":
case "generate":
$return_payload = array_except($return_payload, [
'spoiler.playthrough',
]);
break;
case "mystery":
$return_payload['spoiler'] = array_only($return_payload['spoiler'], ['meta']);
$return_payload['spoiler']['meta'] = array_only($return_payload['spoiler']['meta'], [
'logic',
'build',
'tournament',
'spoilers',
'size'
]);
break;
case "off":
default:
$return_payload['spoiler'] = array_except(array_only($return_payload['spoiler'], [
'meta',
]), ['meta.seed']);
}
}

$cached_payload = $return_payload;
if ($payload['spoiler']['meta']['spoilers_ongen'] ?? false) {
if ($payload['spoiler']['meta']['spoilers'] === 'generate') {
// ensure that the cache doesn't have the spoiler, but the original return_payload still does
$cached_payload['spoiler'] = array_except(array_only($return_payload['spoiler'], [
'meta',
Expand Down Expand Up @@ -98,6 +108,14 @@ protected function prepSeed(Request $request, bool $save = false)
'major_glitches' => 'MajorGlitches',
'no_logic' => 'None',
][$request->input('glitches', 'none')];

$spoilers = $request->input('spoilers', 'off');
if (!$request->input('tournament', true)) {
$spoilers = "on";
} else if (!in_array($request->input('spoilers', 'off'), ["on", "off", "generate", "mystery"])) {
$spoilers = "off";
}

$spoiler_meta = [];

$custom_data = array_dot($request->input('custom'));
Expand All @@ -107,7 +125,7 @@ protected function prepSeed(Request $request, bool $save = false)
if (
$request->input('goal', 'ganon') === 'triforce-hunt'
&& ($custom_data['item.Goal.Required'] ?? 0)
> ($custom_data['item.count.TriforcePiece'] ?? 0) + ($placed_item_count['TriforcePiece'] ?? 0)
> ($custom_data['item.count.TriforcePiece'] ?? 0) + ($placed_item_count['TriforcePiece:1'] ?? 0)
) {
throw new Exception("Not enough Triforce Pieces for the hunt");
}
Expand All @@ -124,6 +142,9 @@ protected function prepSeed(Request $request, bool $save = false)
$spoiler_meta['notes'] = $purifier->purify($markdowned);
}

// Fix for hints option not working in Customizer. We overwrite any potential stale
// spoil.Hints value in custom data because it's not hooked up to the Hints dropdown.
$custom_data['spoil.Hints'] = $request->input('hints', 'on');
$custom_data['item.require.Lamp'] = $custom_data['item.require.Lamp'] ? 0 : 1;
if ($custom_data['rom.freeItemMenu']) {
$custom_data['rom.freeItemMenu'] = 0x00
Expand All @@ -144,9 +165,7 @@ protected function prepSeed(Request $request, bool $save = false)
'entrances' => $request->input('entrances', 'none'),
'mode.weapons' => $request->input('weapons', 'randomized'),
'tournament' => $request->input('tournament', true),
'spoilers' => $request->input('spoilers', false),
'spoilers_ongen' => $request->input('spoilers_ongen', false),
'spoil.Hints' => $request->input('hints', 'on'),
'spoilers' => $spoilers,
'logic' => $logic,
'item.pool' => $request->input('item.pool', 'normal'),
'item.functionality' => $request->input('item.functionality', 'normal'),
Expand Down Expand Up @@ -222,9 +241,16 @@ protected function prepSeed(Request $request, bool $save = false)
'difficulty' => 'custom',
]));


if ($request->input('tournament', false)) {
$rom->setTournamentType('standard');
$rom->rummageTable();
}
$patch = $rom->getWriteLog();
$rom->setTournamentType('standard');
$rom->rummageTable();

if ($save) {
$world->updateSeedRecordPatch($patch);
}

return [
'logic' => $world->config('logic'),
Expand Down
71 changes: 51 additions & 20 deletions app/Http/Controllers/RandomizerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,33 @@ public function generateSeed(CreateRandomizedGame $request)
]);

if ($payload['spoiler']['meta']['tournament'] ?? false) {
if ($payload['spoiler']['meta']['spoilers'] ?? false) {
$return_payload = array_except($return_payload, [
'spoiler.playthrough'
]);
} elseif ($payload['spoiler']['meta']['spoilers_ongen'] ?? false) {
$return_payload = array_except($return_payload, [
'spoiler.playthrough',
]);
} else {
$return_payload['spoiler'] = array_except(array_only($return_payload['spoiler'], [
'meta',
]), ['meta.seed']);
switch ($payload['spoiler']['meta']['spoilers']) {
case "on":
case "generate":
$return_payload = array_except($return_payload, [
'spoiler.playthrough',
]);
break;
case "mystery":
$return_payload['spoiler'] = array_only($return_payload['spoiler'], ['meta']);
$return_payload['spoiler']['meta'] = array_only($return_payload['spoiler']['meta'], [
'logic',
'build',
'tournament',
'spoilers',
'size'
]);
break;
case "off":
default:
$return_payload['spoiler'] = array_except(array_only($return_payload['spoiler'], [
'meta',
]), ['meta.seed']);
}
}

$cached_payload = $return_payload;
if ($payload['spoiler']['meta']['spoilers_ongen'] ?? false) {
if ($payload['spoiler']['meta']['spoilers'] === 'generate') {
// ensure that the cache doesn't have the spoiler, but the original return_payload still does
$cached_payload['spoiler'] = array_except(array_only($return_payload['spoiler'], [
'meta',
Expand All @@ -69,7 +79,20 @@ public function generateSeed(CreateRandomizedGame $request)
}
}

protected function prepSeed(CreateRandomizedGame $request)
public function testGenerateSeed(CreateRandomizedGame $request)
{
try {
return json_encode(array_except($this->prepSeed($request, false), ['patch', 'seed', 'hash']));
} catch (Exception $exception) {
if (app()->bound('sentry')) {
app('sentry')->captureException($exception);
}

return response($exception->getMessage(), 409);
}
}

protected function prepSeed(CreateRandomizedGame $request, bool $save = true)
{
$crystals_ganon = $request->input('crystals.ganon', '7');
$crystals_ganon = $crystals_ganon === 'random' ? get_random_int(0, 7) : $crystals_ganon;
Expand All @@ -82,6 +105,13 @@ protected function prepSeed(CreateRandomizedGame $request)
'no_logic' => 'None',
][$request->input('glitches', 'none')];

$spoilers = $request->input('spoilers', 'off');
if (!$request->input('tournament', true)) {
$spoilers = "on";
} else if (!in_array($request->input('spoilers', 'off'), ["on", "off", "generate", "mystery"])) {
$spoilers = "off";
}

// quick fix for CC and Basic
if ($request->input('item.pool', 'normal') === 'crowd_control') {
$request->merge(['item_placement' => 'advanced']);
Expand All @@ -97,8 +127,7 @@ protected function prepSeed(CreateRandomizedGame $request)
'entrances' => $request->input('entrances', 'none'),
'mode.weapons' => $request->input('weapons', 'randomized'),
'tournament' => $request->input('tournament', false),
'spoilers' => $request->input('spoilers', false),
'spoilers_ongen' => $request->input('spoilers_ongen', false),
'spoilers' => $spoilers,
'spoil.Hints' => $request->input('hints', 'on'),
'logic' => $logic,
'item.pool' => $request->input('item.pool', 'normal'),
Expand All @@ -119,7 +148,7 @@ protected function prepSeed(CreateRandomizedGame $request)
}

$rand->randomize();
$world->writeToRom($rom, true);
$world->writeToRom($rom, $save);

// E.R. is responsible for verifying winnability of itself
if ($world->config('entrances') === 'none') {
Expand All @@ -143,11 +172,13 @@ protected function prepSeed(CreateRandomizedGame $request)
$en->writeToRom($rom);
}

$rom->setTournamentType($request->input('spoilers', false) ? 'none' : 'standard');
$rom->rummageTable();
if ($request->input('tournament', false)) {
$rom->setTournamentType('standard');
$rom->rummageTable();
}
$patch = $rom->getWriteLog();

if ($world->isEnemized()) {
if ($save) {
$world->updateSeedRecordPatch($patch);
}

Expand Down
23 changes: 19 additions & 4 deletions app/Jobs/SendPatchToDisk.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,25 @@ public function handle()
]);

if ($spoiler['meta']['tournament'] ?? false) {
if ($spoiler['meta']['spoilers'] ?? false) {
$return_spoiler = array_except($spoiler, ['playthrough']);
} else {
$return_spoiler = array_except(array_only($spoiler, ['meta']), ['meta.seed']);
switch ($spoiler['meta']['spoilers']) {
case "on":
$return_spoiler = array_except($spoiler, ['playthrough']);
break;
case "mystery":
$return_spoiler = array_only($spoiler, ['meta']);
$return_spoiler['meta'] = array_only($spoiler['meta'], [
'logic',
'build',
'tournament',
'spoilers',
'size'
]);
break;
case "generate":
case "off":
default:
$return_spoiler = array_except(array_only($spoiler, ['meta']), ['meta.seed']);
break;
}
} else {
$return_spoiler = $spoiler;
Expand Down
1 change: 1 addition & 0 deletions app/Location/Npc/Uncle.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ private function getItemCreditsText()
case 'Bow':
case 'BowAndArrows':
case 'BowAndSilverArrows':
case 'ProgressiveBow':
return "your uncle, robin hood";
case 'Boomerang':
case 'RedBoomerang':
Expand Down
52 changes: 27 additions & 25 deletions app/Randomizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,15 @@ public function prepareWorld(World $world): void
$uncle_sword = Item::get('UncleSword', $world)->setTarget(array_pop($nice_items_swords));
$world->getLocation("Link's Uncle")->setItem($uncle_sword);

foreach (["Pyramid Fairy - Left", "Blacksmith", "Master Sword Pedestal"] as $location) {
foreach (["Pyramid Fairy - Left", "Blacksmith"] as $location) {
$world->getLocation($location)->setItem(array_pop($nice_items_swords));
}
if (!$world->getLocation("Master Sword Pedestal")->hasItem(Item::get('Triforce', $world))) {
$world->getLocation($location)->setItem(array_pop($nice_items_swords));
} else {
array_pop($nice_items_swords);
array_push($trash_items, Item::get('TwentyRupees', $world));
}
} else {
// put uncle sword back
if (count($nice_items_swords)) {
Expand Down Expand Up @@ -711,7 +717,7 @@ protected function setShops(World $world): void

$old_man->setActive(true);
$old_man->setShopkeeper('old_man');
$old_man->addInventory(0, ($world->config('mode.weapons') == 'swordless') ? Item::get('ThreeHundredRupees', $world)
$old_man->addInventory(0, (in_array($world->config('mode.weapons'), ['swordless', 'vanilla'])) ? Item::get('ThreeHundredRupees', $world)
: Item::get('ProgressiveSword', $world), 0);
}

Expand Down Expand Up @@ -829,6 +835,18 @@ public function randomizeCredits(World $world)
return $this;
}

function getTextArray(string $file)
{
return array_filter(explode(
"\n-\n",
(string) preg_replace(
'/^-\n/',
'',
(string) preg_replace('/\r\n/', "\n", (string) file_get_contents(base_path($file)))
)
));
}

/**
* Set all texts for this randomization
*
Expand All @@ -840,26 +858,11 @@ public function setTexts(World $world)
{
$strings = cache()->rememberForever('strings', function () {
return [
'uncle' => array_filter(explode(
"\n-\n",
(string) preg_replace('/^-\n/', '', (string) file_get_contents(base_path('strings/uncle.txt')))
)),
'tavern_man' => array_filter(explode(
"\n-\n",
(string) preg_replace('/^-\n/', '', (string) file_get_contents(base_path('strings/tavern_man.txt')))
)),
'blind' => array_filter(explode(
"\n-\n",
(string) preg_replace('/^-\n/', '', (string) file_get_contents(base_path('strings/blind.txt')))
)),
'ganon_1' => array_filter(explode(
"\n-\n",
(string) preg_replace('/^-\n/', '', (string) file_get_contents(base_path('strings/ganon_1.txt')))
)),
'triforce' => array_filter(explode(
"\n-\n",
(string) preg_replace('/^-\n/', '', (string) file_get_contents(base_path('strings/triforce.txt')))
)),
'uncle' => $this->getTextArray('strings/uncle.txt'),
'tavern_man' => $this->getTextArray('strings/tavern_man.txt'),
'blind' => $this->getTextArray('strings/blind.txt'),
'ganon_1' => $this->getTextArray('strings/ganon_1.txt'),
'triforce' => $this->getTextArray('strings/triforce.txt'),
];
});

Expand Down Expand Up @@ -928,13 +931,12 @@ public function setTexts(World $world)
if ($progressive_bow_locations->count() > 0) {
$first_location = $progressive_bow_locations->pop();
$world->setText('ganon_phase_3_no_silvers', "Did you find\nthe arrows in\n" . $first_location->getRegion()->getName());
// Progressive Bow Alternate
$first_location->setItem(new Item\Bow('ProgressiveBow', [0x65], $world));

if ($progressive_bow_locations->count() > 0) {
$second_location = $progressive_bow_locations->pop();
$world->setText('ganon_phase_3_no_silvers_alt', "Did you find\nthe arrows in\n" . $second_location->getRegion()->getName());

// Progressive Bow Alternate
$second_location->setItem(new Item\Bow('ProgressiveBow', [0x65], $world));
}
}

Expand Down
Loading

0 comments on commit b04fa07

Please sign in to comment.