Skip to content

Commit

Permalink
feat(game): Extract game modes to dedicated classes
Browse files Browse the repository at this point in the history
  • Loading branch information
donatorsky committed Apr 27, 2020
1 parent 4050789 commit 0b7c9ab
Show file tree
Hide file tree
Showing 14 changed files with 882 additions and 385 deletions.
2 changes: 1 addition & 1 deletion bin/compile.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function root_path(string $path, string ...$paths): string {
'--js_module_root', root_path('src'),
'--js', root_path('src', 'configuration.js'),
'--js', root_path('src', 'server.js'),
'--js', root_path('src', '*', '*.js'),
'--js', root_path('src', '*', '**.js'),
"--js='!**.test.js'",

'--strict_mode_input',
Expand Down
6 changes: 3 additions & 3 deletions bin/doc-downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -1008,15 +1008,15 @@ public function offsetUnset($offset): void {
/**
* @constructor
*
* @param {RoomConfigObject} roomConfig
* @param {!RoomConfigObject} roomConfig
*
* @return {RoomObject}
* @return {!RoomObject}
*
* @link https://github.com/haxball/haxball-issues/wiki/Headless-Host Documentation
* @link https://html5.haxball.com/headless Headless server host
*/
function HBInit(roomConfig) {
};
}
CONSTRUCTOR;

file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'stubs-' . date('Y-m-d_H_i_s') . '.js', implode("\n\n", $classes));
Expand Down
20 changes: 5 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions src/Commands/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,33 @@ export class Command {

return !!this._handler.call(null, player, arg, message);
}

/**
* @param command
*
* @return {{arguments: !Array.<string>, options: !Object.<string, string>}}
*/
static getArgsAndOptions(command) {
const regex = /\b(\w+)(?:\s*=\s*([^\s]+))?/g,
args = {
arguments: [],
options: {},
};
let m;

while (null !== (m = regex.exec(command))) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}

if (undefined === m[2]) {
args.arguments.push(m[1]);
} else {
args.options[m[1].toLowerCase()] = m[2];
}
}

return args;
}
}
Loading

0 comments on commit 0b7c9ab

Please sign in to comment.