Skip to content

Commit

Permalink
Default individual fight commands to starting the game
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellLVP committed Aug 1, 2020
1 parent 7cd97cb commit 302c24b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions javascript/features/fights/fight_registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export class FightRegistry {
// Gets a particular location by the given |name|. Returns NULL when it's invalid.
getLocation(name) { return this.#locations_.get(name) ?? null; }

// Gets the known locations that are defined to be visible for the "/match" command.
getVisibleLocations() { return this.#locations_.keys(); }

// ---------------------------------------------------------------------------------------------

// Initializes the full fight system from the files the data is defined in. Will be called by
Expand Down Expand Up @@ -107,6 +110,10 @@ export class FightRegistry {
case 'watch':
params.type = GameCommandParams.kTypeWatch;
break;

default:
params.type = GameCommandParams.kTypeStart;
break;
}

params.registrationId = registrationId;
Expand Down
4 changes: 2 additions & 2 deletions javascript/features/fights/fights.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export default class Fights extends Feature {

// Option: Location (string)
new Setting(
'fights', 'location', [ ...this.registry_.locations.keys() ], defaultLocation,
'Location'),
'fights', 'location', [ ...this.registry_.getVisibleLocations() ],
defaultLocation, 'Location'),

// Option: Pickups (boolean)
new Setting('fights', 'pickups', Setting.TYPE_BOOLEAN, true, 'Pickups'),
Expand Down
3 changes: 2 additions & 1 deletion javascript/features/games/game_command_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export class GameCommandParams {
// Types of commands that can be encapsulated by this object.
static kTypeDefault = 0;
static kTypeCustomise = 1;
static kTypeWatch = 2;
static kTypeStart = 2;
static kTypeWatch = 3;

// The type of command that is being executed. Must be one of the above constants.
type = GameCommandParams.kTypeDefault;
Expand Down
3 changes: 3 additions & 0 deletions javascript/features/games/game_commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ export class GameCommands {
// If the customise flag has not been set, return the |settings| immediately as we're done
// unless the game prefers customisable versions.
if (params.type !== GameCommandParams.kTypeCustomise) {
if (params.type === GameCommandParams.kTypeStart)
return settings; // force-start when the params tell us to

const registrations = this.manager_.getPendingGameRegistrations(description);
const publicRegistrations = registrations.filter(registration =>
registration.type === GameRegistration.kTypePublic);
Expand Down

0 comments on commit 302c24b

Please sign in to comment.