Skip to content
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

Merged
merged 40 commits into from
Dec 16, 2016
Merged

feature/ATC-114 #179

merged 40 commits into from
Dec 16, 2016

Conversation

n8rzz
Copy link
Owner

@n8rzz n8rzz commented Dec 6, 2016

completes #114 and #183

Custom command parser. This represents a complete re-write of the command parser.

…. 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
@n8rzz n8rzz added the feature label Dec 6, 2016
@n8rzz n8rzz added this to the v3.2.0 milestone Dec 6, 2016
@n8rzz n8rzz self-assigned this Dec 6, 2016
@n8rzz n8rzz changed the title feature/ATC-114 [WIP] feature/ATC-114 Dec 6, 2016
@n8rzz n8rzz added the WIP label Dec 6, 2016
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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling other wise -> otherwise

Copy link
Owner Author

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 = {
Copy link
Owner Author

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
@n8rzz n8rzz requested a review from erikquinn December 9, 2016 19:57
* @method _buildSystemCommandModel
* @private
*/
_buildSystemCommandModel(commandArgSegments) {
Copy link
Owner Author

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

Copy link
Owner Author

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) => {
Copy link
Owner Author

@n8rzz n8rzz Dec 10, 2016

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 }

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@n8rzz n8rzz temporarily deployed to atc-dev-pr-179 December 10, 2016 02:41 Inactive
- 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
@n8rzz n8rzz temporarily deployed to atc-dev-pr-179 December 10, 2016 04:54 Inactive
@n8rzz n8rzz temporarily deployed to atc-dev-pr-179 December 13, 2016 23:18 Inactive
…forces a single argument for airport command
@n8rzz n8rzz temporarily deployed to atc-dev-pr-179 December 14, 2016 23:27 Inactive
@n8rzz n8rzz temporarily deployed to atc-dev-pr-179 December 15, 2016 04:39 Inactive
@n8rzz n8rzz removed the WIP label Dec 15, 2016
@n8rzz n8rzz requested a review from Dabea December 15, 2016 04:39
@n8rzz
Copy link
Owner Author

n8rzz commented Dec 15, 2016

@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.

Copy link
Collaborator

@erikquinn erikquinn left a 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'
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Owner Author

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.

Copy link
Owner Author

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.

Copy link
Owner Author

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.

Copy link
Owner Author

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) {
Copy link
Collaborator

@erikquinn erikquinn Dec 15, 2016

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

Copy link
Owner Author

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.

Copy link
Owner Author

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() {
Copy link
Collaborator

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.

Copy link
Collaborator

@erikquinn erikquinn Dec 15, 2016

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.

Copy link
Owner Author

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.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@n8rzz n8rzz temporarily deployed to atc-dev-pr-179 December 16, 2016 02:17 Inactive
if (window.gameController.game.option.get('controlMethod') === 'arrows') {
this.$commandInput.val(`${currentCommandInputValue} \u2BA2`);
if (this._isArrowControlMethod()) {
this.$commandInput.val(`${currentCommandInputValue}t l `);
Copy link
Collaborator

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.

Copy link
Owner Author

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!!

Copy link
Collaborator

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.

Copy link
Owner Author

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!

Copy link
Owner Author

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 😉

Copy link
Owner Author

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
@n8rzz n8rzz temporarily deployed to atc-dev-pr-179 December 16, 2016 04:55 Inactive
@n8rzz
Copy link
Owner Author

n8rzz commented Dec 16, 2016

@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}- `);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.$commandInput.val(`${currentCommandInputValue} - `);

Copy link
Owner Author

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() {
Copy link
Collaborator

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.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops 🤕

done

@n8rzz n8rzz temporarily deployed to atc-dev-pr-179 December 16, 2016 13:44 Inactive
@n8rzz n8rzz temporarily deployed to atc-dev-pr-179 December 16, 2016 13:47 Inactive
@n8rzz
Copy link
Owner Author

n8rzz commented Dec 16, 2016

@erikquinn ready for review

we're making this right the first time, so be brutal!

@erikquinn
Copy link
Collaborator

@n8rzz My "brutal" conclusion is that everything works exactly as it should! I'm practically jumping for joy about this one!!! 🎉

@n8rzz n8rzz merged commit 607d840 into develop Dec 16, 2016
@n8rzz n8rzz deleted the feature/ATC-114 branch December 16, 2016 23:36
@n8rzz
Copy link
Owner Author

n8rzz commented Dec 16, 2016

ship-it-squirrel-armour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants