Skip to content

Commit

Permalink
Merge pull request #943 from sporchia/v31.0.9
Browse files Browse the repository at this point in the history
V31.0.9
  • Loading branch information
tcprescott authored Jun 16, 2021
2 parents 095a745 + 9354556 commit 42ff5f6
Show file tree
Hide file tree
Showing 81 changed files with 2,576 additions and 4,544 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/public/images/vendor
/storage/*.key
/resources/assets/js/*.generated.js
/resources/js/*.generated.js
/vendor
/coverage
/docs
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Distribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function handle()
'none' => 'NoGlitches',
'overworld_glitches' => 'OverworldGlitches',
'major_glitches' => 'MajorGlitches',
'no_logic' => 'None',
'no_logic' => 'NoLogic',
][$this->option('glitches')];

$this->state = $this->option('state');
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/MakeTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class MakeTranslation extends Command
* @var string
*/
protected $signature = 'alttp:i18n'
. ' {output_file : where to write translated rom}'
. ' {--i|input_file= : rom to translate}';
. ' {output_file : where to write translated ROM}'
. ' {--i|input_file= : ROM to translate}';

/**
* The console command description.
Expand Down
39 changes: 27 additions & 12 deletions app/Console/Commands/Randomize.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ class Randomize extends Command
*
* @var string
*/
protected $signature = 'alttp:randomize {input_file : base rom to randomize}'
. ' {output_directory : where to place randomized rom}'
. ' {--unrandomized : do not apply randomization to the rom}'
protected $signature = 'alttp:randomize {input_file : base ROM to randomize}'
. ' {output_directory : where to place randomized ROM}'
. ' {--unrandomized : do not apply randomization to the ROM}'
. ' {--spoiler : generate a spoiler file}'
. ' {--heartbeep=half : set heart beep speed}'
. ' {--skip-md5 : do not validate md5 of base rom}'
. ' {--heartcolor=red : set heart color}'
. ' {--skip-md5 : do not validate md5 of base ROM}'
. ' {--tournament : enable tournament mode}'
. ' {--bulk=1 : generate multiple roms}'
. ' {--bulk=1 : generate multiple ROMs}'
. ' {--sprite= : sprite file to change links graphics [zspr format]}'
. ' {--no-rom : do not generate output rom}'
. ' {--no-rom : do not generate output ROM}'
. ' {--no-music : mute all music}'
. ' {--menu-speed=normal : menu speed}'
. ' {--goal=ganon : set game goal}'
Expand All @@ -44,14 +45,15 @@ class Randomize extends Command
. ' {--accessibility=item : set item/location accessibility}'
. ' {--hints=on : set hints on or off}'
. ' {--item_pool=normal : set item pool}'
. ' {--item_functionality=normal : set item functionality}';
. ' {--item_functionality=normal : set item functionality}'
. ' {--quickswap=false : set quickswap}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate a randomized rom.';
protected $description = 'Generate a randomized ROM.';

/** @var array */
protected $reset_patch;
Expand Down Expand Up @@ -124,15 +126,28 @@ public function handle()
return 3;
}

if (is_string($this->option('heartcolor'))) {
$heartColorToUse = $this->option('heartcolor');
if ($heartColorToUse === 'random') {
$colorOptions = ['blue', 'green', 'yellow', 'red'];
$heartColorToUse = $colorOptions[get_random_int(0, 3)];
}
$rom->setHeartColors($heartColorToUse);
}

if (is_string($this->option('heartbeep'))) {
$rom->setHeartBeepSpeed($this->option('heartbeep'));
}

if(is_string($this->option('quickswap'))) {
$rom->setQuickSwap(strtolower($this->option('quickswap')) === 'true');
}

// break out for unrandomized base game
if ($this->option('unrandomized')) {
$output_file = sprintf('%s/alttp-%s.sfc', $this->argument('output_directory'), Rom::BUILD);
$rom->save($output_file);
$this->info(sprintf('Rom Saved: %s', $output_file));
$this->info(sprintf('ROM Saved: %s', $output_file));

return 0;
}
Expand All @@ -145,7 +160,7 @@ public function handle()
'none' => 'NoGlitches',
'overworld_glitches' => 'OverworldGlitches',
'major_glitches' => 'MajorGlitches',
'no_logic' => 'None',
'no_logic' => 'NoLogic',
][$this->option('glitches')];

$world = World::factory($this->option('state'), [
Expand Down Expand Up @@ -202,7 +217,7 @@ public function handle()
$rom->updateChecksum();
$rom->save($output_file);

$this->info(sprintf('Rom Saved: %s', $output_file));
$this->info(sprintf('ROM Saved: %s', $output_file));
}

if ($this->option('spoiler')) {
Expand All @@ -215,7 +230,7 @@ public function handle()
}

/**
* Apply base patch to rom file.
* Apply base patch to ROM file.
*
* @throws \Exception when base patch has no content.
*
Expand Down
8 changes: 4 additions & 4 deletions app/Console/Commands/UpdateBuildRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class UpdateBuildRecord extends Command
*
* @var string
*/
protected $description = 'build bps, json patch, and upate the rom build in DB';
protected $description = 'build bps, json patch, and upate the ROM build in DB';

/**
* Execute the console command.
Expand Down Expand Up @@ -125,7 +125,7 @@ public function handle()
}

/**
* Update the constants in Rom class.
* Update the constants in ROM class.
*
* @param \ALttP\Build $build Build to update to
*
Expand All @@ -144,7 +144,7 @@ private function updateRomClassFile(Build $build): void
* Create a json patch for internal services.
*
* @param string $hash hash to save file with
* @param string $rom patched rom to make patch from
* @param string $rom patched ROM to make patch from
*
* @throws \Exception if any filesystem issues arrise
*
Expand All @@ -170,7 +170,7 @@ private function makeJsonPatch(string $hash, string $rom): void
$updated_rom = fopen($rom, "r");

if ($updated_rom === false) {
throw new Exception('Could not open updated rom');
throw new Exception('Could not open updated ROM');
}

$i = 0;
Expand Down
6 changes: 3 additions & 3 deletions app/Enemizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Enemizer
* Create a new Enemizer
*
* @param \ALttP\World $world world to enemize
* @param array $rom_patch the current rom patch
* @param array $rom_patch the current ROM patch
*
* @return void
*/
Expand Down Expand Up @@ -251,9 +251,9 @@ public function writeOptionsFile()
}

/**
* write the current generated data to the Rom
* write the current generated data to the ROM
*
* @param Rom $rom Rom to write data to
* @param Rom $rom ROM to write data to
*
* @return Rom
*/
Expand Down
13 changes: 9 additions & 4 deletions app/Http/Controllers/CustomizerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function generateSeed(Request $request)
]));
Cache::put('hash.' . $payload['hash'], $save_data, now()->addDays(7));

return json_encode($return_payload);
return response()->json($return_payload);
} catch (Exception $exception) {
if (app()->bound('sentry')) {
app('sentry')->captureException($exception);
Expand All @@ -93,7 +93,7 @@ public function generateSeed(Request $request)
public function testGenerateSeed(Request $request)
{
try {
return json_encode(Arr::except($this->prepSeed($request), ['patch', 'seed', 'hash']));
return response()->json(Arr::except($this->prepSeed($request), ['patch', 'seed', 'hash']));
} catch (Exception $exception) {
if (app()->bound('sentry')) {
app('sentry')->captureException($exception);
Expand All @@ -113,7 +113,7 @@ protected function prepSeed(Request $request, bool $save = false)
'none' => 'NoGlitches',
'overworld_glitches' => 'OverworldGlitches',
'major_glitches' => 'MajorGlitches',
'no_logic' => 'None',
'no_logic' => 'NoLogic',
][$request->input('glitches', 'none')];

$spoilers = $request->input('spoilers', 'off');
Expand Down Expand Up @@ -180,7 +180,7 @@ protected function prepSeed(Request $request, bool $save = false)
'mode.weapons' => $request->input('weapons', 'randomized'),
'tournament' => $request->input('tournament', true),
'spoilers' => $spoilers,
'allow_quickswap' => $request->input('allow_quickswap', false),
'allow_quickswap' => $request->input('allow_quickswap', true),
'override_start_screen' => $request->input('override_start_screen', false),
'logic' => $logic,
'item.pool' => $request->input('item.pool', 'normal'),
Expand Down Expand Up @@ -250,6 +250,11 @@ protected function prepSeed(Request $request, bool $save = false)
$rand = new Randomizer([$world]);

$rand->randomize();

foreach ($request->input('texts', []) as $key => $value) {
$world->setText($key, $value);
}

$world->writeToRom($rom, $save);

$worlds = new WorldCollection($rand->getWorlds());
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/MultiworldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ protected function prepSeed(Request $request)
'none' => 'NoGlitches',
'overworld_glitches' => 'OverworldGlitches',
'major_glitches' => 'MajorGlitches',
'no_logic' => 'None',
'no_logic' => 'NoLogic',
][$config['glitches'] ?? 'none'];

// quick fix for CC and Basic
// quick fix for CC and Basic/Entrance
if (($config['item.pool'] ?? 'normal') === 'crowd_control') {
$request->merge(['item_placement' => 'advanced']);
$request->merge(['entrances' => 'none']);
}

$worlds[] = World::factory($config['mode'] ?? 'standard', [
Expand Down
29 changes: 23 additions & 6 deletions app/Http/Controllers/RandomizerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use ALttP\Support\WorldCollection;
use ALttP\World;
use Exception;
use GrahamCampbell\Markdown\Facades\Markdown;
use HTMLPurifier_Config;
use HTMLPurifier;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Cache;

Expand Down Expand Up @@ -75,7 +78,7 @@ public function generateSeed(CreateRandomizedGame $request)
]));
Cache::put('hash.' . $payload['hash'], $save_data, now()->addDays(7));

return json_encode($return_payload);
return response()->json($return_payload);
} catch (Exception $exception) {
if (app()->bound('sentry')) {
app('sentry')->captureException($exception);
Expand All @@ -88,7 +91,7 @@ public function generateSeed(CreateRandomizedGame $request)
public function testGenerateSeed(CreateRandomizedGame $request)
{
try {
return json_encode(Arr::except($this->prepSeed($request, false), ['patch', 'seed', 'hash']));
return response()->json(Arr::except($this->prepSeed($request, false), ['patch', 'seed', 'hash']));
} catch (Exception $exception) {
if (app()->bound('sentry')) {
app('sentry')->captureException($exception);
Expand All @@ -108,7 +111,7 @@ protected function prepSeed(CreateRandomizedGame $request, bool $save = true)
'none' => 'NoGlitches',
'overworld_glitches' => 'OverworldGlitches',
'major_glitches' => 'MajorGlitches',
'no_logic' => 'None',
'no_logic' => 'NoLogic',
][$request->input('glitches', 'none')];

$spoilers = $request->input('spoilers', 'off');
Expand All @@ -123,6 +126,20 @@ protected function prepSeed(CreateRandomizedGame $request, bool $save = true)
$request->merge(['item_placement' => 'advanced']);
}

$spoiler_meta = [];

$purifier_settings = HTMLPurifier_Config::create(config("purifier.default"));
$purifier_settings->loadArray(config("purifier.default"));
$purifier = new HTMLPurifier($purifier_settings);
if ($request->filled('name')) {
$markdowned = Markdown::convertToHtml(substr($request->input('name'), 0, 100));
$spoiler_meta['name'] = strip_tags($purifier->purify($markdowned));
}
if ($request->filled('notes')) {
$markdowned = Markdown::convertToHtml(substr($request->input('notes'), 0, 300));
$spoiler_meta['notes'] = $purifier->purify($markdowned);
}

$world = World::factory($request->input('mode', 'standard'), [
'itemPlacement' => $request->input('item_placement', 'basic'),
'dungeonItems' => $request->input('dungeon_items', 'standard'),
Expand All @@ -134,7 +151,7 @@ protected function prepSeed(CreateRandomizedGame $request, bool $save = true)
'mode.weapons' => $request->input('weapons', 'randomized'),
'tournament' => $request->input('tournament', false),
'spoilers' => $spoilers,
'allow_quickswap' => $request->input('allow_quickswap', false),
'allow_quickswap' => $request->input('allow_quickswap', true),
'override_start_screen' => $request->input('override_start_screen', false),
'spoil.Hints' => $request->input('hints', 'on'),
'logic' => $logic,
Expand Down Expand Up @@ -168,11 +185,11 @@ protected function prepSeed(CreateRandomizedGame $request, bool $save = true)
}
}

$spoiler = $world->getSpoiler([
$spoiler = $world->getSpoiler(array_merge($spoiler_meta, [
'entry_crystals_ganon' => $request->input('crystals.ganon', '7'),
'entry_crystals_tower' => $request->input('crystals.tower', '7'),
'worlds' => 1,
]);
]));

if ($world->isEnemized()) {
$patch = $rom->getWriteLog();
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function customizer(): array
}

/**
* Get information on the current rom patch.
* Get information on the current ROM patch.
*
* @return array
*/
Expand All @@ -216,6 +216,7 @@ public function sprites(): array
'author' => $info['author'],
'version' => $info['version'],
'file' => 'https://alttpr.s3.us-east-2.amazonaws.com/' . $file,
'preview' => 'https://alttpr.s3.us-east-2.amazonaws.com/' . $file . '.png',
'tags' => $info['tags'] ?? [],
'usage' => $info['usage'] ?? []
];
Expand Down
4 changes: 2 additions & 2 deletions app/Location/Dig/HauntedGrove.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
class HauntedGrove extends Dig
{
/**
* Write item to rom.
* Write item to ROM.
*
* @param \ALttP\Rom $rom rom to write to
* @param \ALttP\Rom $rom ROM to write to
* @param \ALttP\Item $item item to write
*
* @return \ALttP\Location
Expand Down
4 changes: 2 additions & 2 deletions app/Location/Drop/Bombos.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
class Bombos extends Location
{
/**
* Write item to rom.
* Write item to ROM.
*
* @param \ALttP\Rom $rom rom to write to
* @param \ALttP\Rom $rom ROM to write to
* @param \ALttP\Item $item item to write
*
* @return \ALttP\Location
Expand Down
4 changes: 2 additions & 2 deletions app/Location/Drop/Ether.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
class Ether extends Location
{
/**
* Write item to rom.
* Write item to ROM.
*
* @param \ALttP\Rom $rom rom to write to
* @param \ALttP\Rom $rom ROM to write to
* @param \ALttP\Item $item item to write
*
* @return \ALttP\Location
Expand Down
4 changes: 2 additions & 2 deletions app/Location/Npc/BugCatchingKid.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
class BugCatchingKid extends Npc
{
/**
* Write item to rom.
* Write item to ROM.
*
* @param \ALttP\Rom $rom rom to write to
* @param \ALttP\Rom $rom ROM to write to
* @param \ALttP\Item $item item to write
*
* @return \ALttP\Location
Expand Down
Loading

0 comments on commit 42ff5f6

Please sign in to comment.