Template for a JavaScript/TypeScript Connect 4 Bot#1
Merged
DavidBetteridge merged 12 commits intoYorkCodeDojo:masterfrom Oct 31, 2016
Merged
Template for a JavaScript/TypeScript Connect 4 Bot#1DavidBetteridge merged 12 commits intoYorkCodeDojo:masterfrom
DavidBetteridge merged 12 commits intoYorkCodeDojo:masterfrom
Conversation
terrawheat
reviewed
Oct 29, 2016
|
|
||
| case GameState.RedToPlay: | ||
| if (game.RedPlayerID === playerId) { | ||
| makeMove(game, playerId) |
There was a problem hiding this comment.
Promises should be parameterised with types in TS. That being said since x isnt even used, probably just remove the value altogether.
There was a problem hiding this comment.
Just noticed the typing of the argument comes from the function definition anyway, so ignore this :D
Contributor
Author
There was a problem hiding this comment.
Only used at top in const game = x.body; but seems to pull the types though without doing a x : IResponse<IGame> magic eh?!
| } | ||
|
|
||
| registerTeam(teamName: string, password: string): Promise<IResponse<string>> { | ||
| const qs = querystring.stringify({ teamName: teamName, password: password }); |
There was a problem hiding this comment.
querystring.stringify({ teamName, password })
| } | ||
|
|
||
| makeMove(playerId: string, password: string, columnNumber: number): Promise<IResponse<void>> { | ||
| const qs = querystring.stringify({ playerID: playerId, columnNumber: columnNumber, password: password }); |
| return new Promise((resolve, reject) => { | ||
| let req = http.request(options, (res) => { | ||
| if (res.statusCode < 200 || res.statusCode >= 300) { | ||
| return resolve({ ok: false, statusCode: res.statusCode, body: null }); |
There was a problem hiding this comment.
eeeeeew. Why not just reject the promise? Resolving with OK makes me sad.
Connect4.js/src/test/app.test.ts
Outdated
| @@ -0,0 +1,3 @@ | |||
| import * as assert from 'assert' | |||
|
|
|||
| // I should of really written some test... :-/ No newline at end of file | |||
Contributor
Author
There was a problem hiding this comment.
Knew you'd find a spelling mistake!
jaymoid
pushed a commit
to jaymoid/Connect4
that referenced
this pull request
Dec 10, 2016
Added rust example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thought I'd create us a connect 4 bot template in TypeScript in case we ever run this event again... plus gave me an excuse to write some TypeScript.