-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature/ATC-114 #179
feature/ATC-114 #179
Conversation
…. Adds CommandParser inside console.log to InputController
* Modifies how CommandModel objects are built * Updates tests
…ds (excluding transmit) * Adds InputController.processCOmmand() method and simplifies branching logic by using switch
* Adds new getter to CommandModel * Adds additional test cases
…sers * COMMAND_DEFINITION objects the define a validator and a parser to validated and parse each command * Simplifies some of the run functions within AircraftInstanceModel
* Adds ERROR_MESSAGE enum for argumentValidators error messaging * Adds convertToThousands() and convertStringToNumber() to unitConverters
* Abstracts errors to ERROR_MESSAGE * Adds more doc blocks
…s failing test for holdParser.
…l. Adds encapsulated boolean method for Parser
export const altitudeParser = (args) => { | ||
const altitude = convertToThousands(args[0]); | ||
// the validator will have already caught an invalid value here. if one exists, it is assumed to be valid and | ||
// thus we return true. other wise its false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling other wise
-> otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* @type {Object} | ||
* @final | ||
*/ | ||
const ERROR_MESSAGE = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to different file
…TC-114 Conflicts: - src/assets/scripts/constants/globalConstants.js
* @method _buildSystemCommandModel | ||
* @private | ||
*/ | ||
_buildSystemCommandModel(commandArgSegments) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
system commands should still be validated and parsed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* @param args {array} | ||
* @return {array<string, number, boolean>} | ||
*/ | ||
export const headingParser = (args) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be able to handle two or three digit radials:
030 -> { heading: 30, incremental: false }
30 -> { heading: currentHeading + 30, incremental: true }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
- Abstracts ERROR_MESSAGES to new file - Adds _parseUserCommand() method to InputController to encapsulate actual parsing/errors of the CommandParser - Adds validators and parsers to System commands
…forces a single argument for airport command
@erikquinn ready for your eyes again. feel free to use the review app, too ;-) Let me know if you find more stuff. I definitely don't want to rush this one out the door. Lets get this right the first time! @Dabea feel free to add feedback or ask questions on this stuff. I'd like to get you in on some of these PRs just to get used to the process an see more of the codebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dug in pretty deep with this one... found a lot of good unrelated issues actually (as your newsfeed likely indicates 😉)...
Things are definitely better, there are just a few things I called out that should be addressed. But I believe I was quite thorough, so it should pretty much be that what you see here is what you get; there should be no other issues lurking around beyond what is called out here or recorded in another issue. So hopefully there will be nothing broken when it is to be merged! 👍
'\\u2B61': 'altitude', | ||
'\\u2B63': 'altitude', | ||
'\\u2BA2': 'heading', | ||
'\\u2BA3': 'heading' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@n8rzz It theoretically wouldn't break my heart to have these out of commission for a short while, but the left/right functionality of the arrows is crucial; without it, they really don't provide nearly as much of a benefit.
I think we talked about this briefly before... is there any way to easily get it to recognize that one should pass the direction during the call of runHeading
? And again, even if pressing the keys inserts t l
instead of the unicode arrows, that would be an acceptable resolution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add '\\u2B50': 'land'
to this list to re-activate the asterisk shortcut for approach clearances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks fair. to be honest, I think inserting t l
or t r
on keypress will be the cleanest/easiest solution. I thought of one other way to do it, but it's gross and very brittle. If we programmatically add t l
or t r
, once the user presses enter it will get validated and parsed just like it would if the user typed it in. I think this is going to be the best solution here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I totally missed the land command, thanks for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh, I didn't miss the land command. I just included it as: '*': 'land'
in the commandMap
file. I'll move that up to the unicodes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -436,7 +440,14 @@ export default class InputController { | |||
onCommandInputKeydownHandler(e) { | |||
const currentCommandInputValue = this.$commandInput.val(); | |||
|
|||
// TODO: this swtich can be simplified, there is a lot of repetition here | |||
switch (e.which) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's not actually part of this PR, but since you're here, could you take care of the following small change?
The following need to have spaces at the end of that which is appended to the currentCommandInputValue
:
-
case KEY_CODES.MULTIPLY
-
case KEY_CODES.ADD
-
case KEY_CODES.EQUALS
-
case KEY_CODES.SUBTRACT
-
case KEY_CODES.DASH
-
case KEY_CODES.DIVIDE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be in there anyway. this is a simple change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* @method _validateCommandArguments | ||
* @private | ||
*/ | ||
_validateCommandArguments() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the hold
command throws an error when I try to feed it only two arguments, as it explains it expected either one or three. The command of hold coinz 2min
would ideally be considered sufficient. The user can provide the constraints they want, and if not specified, the default behaviors of [1min legs] and [right turns] will be assumed.
So really, the expected number of arguments should be zero, one, two, or three.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this section of the Command Reference within the wiki for the intended functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally missed that part as well. I remember reading through it, I just didn't implement it. It'll add a little more logic to the validator and parser, but shouldn't be too bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
- Adds asterisk unicode to unicode commands
if (window.gameController.game.option.get('controlMethod') === 'arrows') { | ||
this.$commandInput.val(`${currentCommandInputValue} \u2BA2`); | ||
if (this._isArrowControlMethod()) { | ||
this.$commandInput.val(`${currentCommandInputValue}t l `); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@n8rzz Not to be high maintenance, but could you add back the spaces before the command as well? The idea is to make them chainable, eg [right arrow] [3] [5] [0] [down arrow] [5] [0] [numpad -] [1] [7] [0]
, and get AAL 123 > 350 v 50 - 170
, so you never have to press space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not high maintenance at all, I'm glad you called that out. We were actually getting two spaces between callsign and first command, so I just fixed the glitch here. Wrong idea.
I just looked through it and found where the callsign is added to the command line and removed the space there. these commands will have the space on the left in my next commit.
Good eye! never be shy about these kinds of things!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just looked through it and found where the callsign is added to the command line and removed the space there.
As long as you can still click to select an aircraft and type [C] [A] [F] [enter]
without needing to add a leading space, that'll do, but it sounds like you're making it so selecting the aircraft inserts AAL123
instead of AAL123[space]
in the currentCommandInputValue
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we really need a way to make this consistent, and you're exactly right. I'm glad you're keeping an eye on things!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll get it right one of these times 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…that be received in any order - Adjusts spacing in InputController
@erikquinn ready for review. Check those spaces and let me know if you find anything else. |
e.preventDefault(); | ||
this.onCommandInputChangeHandler(); | ||
|
||
break; | ||
|
||
case KEY_CODES.SUBTRACT: | ||
this.$commandInput.val(`${currentCommandInputValue} -`); | ||
this.$commandInput.val(`${currentCommandInputValue}- `); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.$commandInput.val(`${currentCommandInputValue} - `);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* @method _validateCommandArguments | ||
* @private | ||
*/ | ||
_validateCommandArguments() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one thing not working with the hold
command still: the command alone with no arguments. This would be a standard holding pattern at the aircraft's present position (unrelated to a fix). All other combinations work properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops 🤕
done
* Adds more documentation
@erikquinn ready for review we're making this right the first time, so be brutal! |
@n8rzz My "brutal" conclusion is that everything works exactly as it should! I'm practically jumping for joy about this one!!! 🎉 |
completes #114 and #183
Custom command parser. This represents a complete re-write of the command parser.