siggame / Viseur

Visualizer for the Cadre AI game framework
http://vis.siggame.io
MIT License
5 stars 9 forks source link

Checkers made with Vis team #29

Closed JacobFischer closed 6 years ago

JacobFischer commented 6 years ago

I want to merge this to v2, before merging v2 to master.

However there are many errors. Though every single one would have been caught by the linter it appears.

So @MatthewQualls please make sure your install of tslint is working and fix what it tells you to, then make another commit fixing them, then we can merge this.

Also, while not an error, the second player's color should probably be a dark grey for black's side.

JacobFischer commented 6 years ago

Oh the linter isn't picking up these errors:

you have a line like this:

        this.checker = (this.game.resources[`checker`] as RendererResource)
            .newSprite(this.container);

However there is no need, it can be rewritten as this:

        this.checker = this.game.resources.checker.newSprite(this.container);

This has a few advantages:

  1. shorter, 1 line
  2. using the index to lookup a string is pointless, you can just use dot notation (the linter would yell at you for this)
  3. No need to cast. When you cast you lose some of the power of TypeScript's type checking. However the way I wrote it TS knows it is a RendererResource, and can typecheck your code normally
  4. No need to import RendererResource to cast
MatthewQualls commented 6 years ago

I think i originally had blue and red for the actual checker pieces; Ill fix that error once I get the chance, I think I'm too used to python atm