From 082a11b0cd7cfc27afa713def9df5f9fef2a5a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 3 Jun 2020 23:17:52 +0200 Subject: [PATCH] Allowing ill defined initializers (because of the way Phaser 3 is designed) --- front/src/Phaser/Game/GameScene.ts | 18 +++++++++--------- front/tsconfig.json | 13 +++++++++++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 5cf89c16..126e2369 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -30,15 +30,15 @@ export class GameScene extends Phaser.Scene { CurrentPlayer: CurrentGamerInterface; MapPlayers : Phaser.Physics.Arcade.Group; MapPlayersByKey : Map = new Map(); - Map: Phaser.Tilemaps.Tilemap; + Map: Phaser.Tilemaps.Tilemap|null = null; Layers : Array; Objects : Array; - map: ITiledMap; + mapFile: ITiledMap|null; groups: Map; startX = 704;// 22 case startY = 32; // 1 case circleTexture: CanvasTexture; - initPosition: PositionInterface; + initPosition: PositionInterface|null = null; private playersPositionInterpolator = new PlayersPositionInterpolator(); MapKey: string; @@ -107,9 +107,9 @@ export class GameScene extends Phaser.Scene { private onMapLoad(data: any): void { // Triggered when the map is loaded // Load tiles attached to the map recursively - this.map = data.data; + this.mapFile = data.data; let url = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/')); - this.map.tilesets.forEach((tileset) => { + this.mapFile.tilesets.forEach((tileset) => { if (typeof tileset.name === 'undefined' || typeof tileset.image === 'undefined') { console.warn("Don't know how to handle tileset ", tileset) return; @@ -128,7 +128,7 @@ export class GameScene extends Phaser.Scene { create(): void { //initalise map this.Map = this.add.tilemap(this.MapKey); - this.map.tilesets.forEach((tileset: ITiledTileSet) => { + this.mapFile.tilesets.forEach((tileset: ITiledTileSet) => { this.Terrains.push(this.Map.addTilesetImage(tileset.name, tileset.name)); }); @@ -138,12 +138,12 @@ export class GameScene extends Phaser.Scene { //add layer on map this.Layers = new Array(); let depth = -2; - this.map.layers.forEach((layer : ITiledMapLayer) => { + this.mapFile.layers.forEach((layer : ITiledMapLayer) => { if (layer.type === 'tilelayer') { this.addLayer(this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(depth)); } if (layer.type === 'tilelayer' && this.getExitSceneUrl(layer) !== undefined) { - this.loadNextGame(layer, this.map.width, this.map.tilewidth, this.map.tileheight); + this.loadNextGame(layer, this.mapFile.width, this.mapFile.tilewidth, this.mapFile.tileheight); } if (layer.type === 'tilelayer' && layer.name === "start") { let startPosition = this.startUser(layer); @@ -265,7 +265,7 @@ export class GameScene extends Phaser.Scene { * @param layer */ private startUser(layer: ITiledMapLayer): PositionInterface { - if (this.initPosition !== undefined) { + if (this.initPosition !== null) { this.startX = this.initPosition.x; this.startY = this.initPosition.y; return { diff --git a/front/tsconfig.json b/front/tsconfig.json index 3d91f3d1..84882e74 100644 --- a/front/tsconfig.json +++ b/front/tsconfig.json @@ -8,8 +8,17 @@ "target": "es5", "jsx": "react", "allowJs": true, - "strict": true, /* Enable all strict type-checking options. */ + + "strict": false, /* Enable all strict type-checking options. */ + "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + "strictNullChecks": true, /* Enable strict null checks. */ + "strictFunctionTypes": true, /* Enable strict checking of function types. */ + "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + "strictPropertyInitialization": false, /* Enable strict checking of property initialization in classes. */ + "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */ + "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */ } }