Skip to content
Permalink
Browse files
Default individual fight commands to starting the game
  • Loading branch information
RussellLVP committed Aug 1, 2020
1 parent 7cd97cb commit 302c24ba57429a6310b317964d7ec7701a3e69ea
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
@@ -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
@@ -107,6 +110,10 @@ export class FightRegistry {
case 'watch':
params.type = GameCommandParams.kTypeWatch;
break;

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

params.registrationId = registrationId;
@@ -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'),
@@ -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;
@@ -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);

0 comments on commit 302c24b

Please sign in to comment.