Switching to definitely assigned parameters
This allows us to go in "full strict mode" (yeah!) See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#strict-class-initialization
This commit is contained in:
parent
c6298b2a89
commit
24fb605f50
@ -7,8 +7,6 @@ import {Character} from "../Entity/Character";
|
|||||||
*/
|
*/
|
||||||
export class RemotePlayer extends Character {
|
export class RemotePlayer extends Character {
|
||||||
userId: string;
|
userId: string;
|
||||||
previousDirection: string;
|
|
||||||
wasMoving: boolean;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
userId: string,
|
userId: string,
|
||||||
|
@ -13,8 +13,8 @@ export interface HasMovedEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class GameManager {
|
export class GameManager {
|
||||||
private playerName: string;
|
private playerName!: string;
|
||||||
private characterLayers: string[];
|
private characterLayers!: string[];
|
||||||
|
|
||||||
public setPlayerName(name: string): void {
|
public setPlayerName(name: string): void {
|
||||||
this.playerName = name;
|
this.playerName = name;
|
||||||
|
@ -73,31 +73,31 @@ interface DeleteGroupEventInterface {
|
|||||||
export class GameScene extends Phaser.Scene {
|
export class GameScene extends Phaser.Scene {
|
||||||
GameManager : GameManager;
|
GameManager : GameManager;
|
||||||
Terrains : Array<Phaser.Tilemaps.Tileset>;
|
Terrains : Array<Phaser.Tilemaps.Tileset>;
|
||||||
CurrentPlayer: CurrentGamerInterface;
|
CurrentPlayer!: CurrentGamerInterface;
|
||||||
MapPlayers : Phaser.Physics.Arcade.Group;
|
MapPlayers!: Phaser.Physics.Arcade.Group;
|
||||||
MapPlayersByKey : Map<string, RemotePlayer> = new Map<string, RemotePlayer>();
|
MapPlayersByKey : Map<string, RemotePlayer> = new Map<string, RemotePlayer>();
|
||||||
Map: Phaser.Tilemaps.Tilemap;
|
Map!: Phaser.Tilemaps.Tilemap;
|
||||||
Layers : Array<Phaser.Tilemaps.StaticTilemapLayer>;
|
Layers!: Array<Phaser.Tilemaps.StaticTilemapLayer>;
|
||||||
Objects : Array<Phaser.Physics.Arcade.Sprite>;
|
Objects!: Array<Phaser.Physics.Arcade.Sprite>;
|
||||||
mapFile: ITiledMap;
|
mapFile!: ITiledMap;
|
||||||
groups: Map<string, Sprite>;
|
groups: Map<string, Sprite>;
|
||||||
startX: number;
|
startX!: number;
|
||||||
startY: number;
|
startY!: number;
|
||||||
circleTexture: CanvasTexture;
|
circleTexture!: CanvasTexture;
|
||||||
pendingEvents: Queue<InitUserPositionEventInterface|AddPlayerEventInterface|RemovePlayerEventInterface|UserMovedEventInterface|GroupCreatedUpdatedEventInterface|DeleteGroupEventInterface> = new Queue<InitUserPositionEventInterface|AddPlayerEventInterface|RemovePlayerEventInterface|UserMovedEventInterface|GroupCreatedUpdatedEventInterface|DeleteGroupEventInterface>();
|
pendingEvents: Queue<InitUserPositionEventInterface|AddPlayerEventInterface|RemovePlayerEventInterface|UserMovedEventInterface|GroupCreatedUpdatedEventInterface|DeleteGroupEventInterface> = new Queue<InitUserPositionEventInterface|AddPlayerEventInterface|RemovePlayerEventInterface|UserMovedEventInterface|GroupCreatedUpdatedEventInterface|DeleteGroupEventInterface>();
|
||||||
private initPosition: PositionInterface|null = null;
|
private initPosition: PositionInterface|null = null;
|
||||||
private playersPositionInterpolator = new PlayersPositionInterpolator();
|
private playersPositionInterpolator = new PlayersPositionInterpolator();
|
||||||
private connection: Connection;
|
private connection!: Connection;
|
||||||
private simplePeer : SimplePeer;
|
private simplePeer!: SimplePeer;
|
||||||
private connectionPromise: Promise<Connection>
|
private connectionPromise!: Promise<Connection>
|
||||||
|
|
||||||
MapKey: string;
|
MapKey: string;
|
||||||
MapUrlFile: string;
|
MapUrlFile: string;
|
||||||
RoomId: string;
|
RoomId: string;
|
||||||
instance: string;
|
instance: string;
|
||||||
|
|
||||||
currentTick: number;
|
currentTick!: number;
|
||||||
lastSentTick: number; // The last tick at which a position was sent.
|
lastSentTick!: number; // The last tick at which a position was sent.
|
||||||
lastMoveEventSent: HasMovedEvent = {
|
lastMoveEventSent: HasMovedEvent = {
|
||||||
direction: '',
|
direction: '',
|
||||||
moving: false,
|
moving: false,
|
||||||
|
@ -18,24 +18,24 @@ enum CustomizeTextures{
|
|||||||
|
|
||||||
export class CustomizeScene extends Phaser.Scene {
|
export class CustomizeScene extends Phaser.Scene {
|
||||||
|
|
||||||
private textField: TextField;
|
private textField!: TextField;
|
||||||
private enterField: TextField;
|
private enterField!: TextField;
|
||||||
|
|
||||||
private arrowRight: Image;
|
private arrowRight!: Image;
|
||||||
private arrowLeft: Image;
|
private arrowLeft!: Image;
|
||||||
|
|
||||||
private arrowDown: Image;
|
private arrowDown!: Image;
|
||||||
private arrowUp: Image;
|
private arrowUp!: Image;
|
||||||
|
|
||||||
private Rectangle: Rectangle;
|
private Rectangle!: Rectangle;
|
||||||
|
|
||||||
private logo: Image;
|
private logo!: Image;
|
||||||
|
|
||||||
private selectedLayers: Array<number> = [0];
|
private selectedLayers: Array<number> = [0];
|
||||||
private containersRow: Array<Array<Container>> = new Array<Array<Container>>();
|
private containersRow: Array<Array<Container>> = new Array<Array<Container>>();
|
||||||
private activeRow = 0;
|
private activeRow = 0;
|
||||||
|
|
||||||
private repositionCallback: (this: Window, ev: UIEvent) => void;
|
private repositionCallback!: (this: Window, ev: UIEvent) => void;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
|
@ -21,22 +21,22 @@ enum LoginTextures {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class EnableCameraScene extends Phaser.Scene {
|
export class EnableCameraScene extends Phaser.Scene {
|
||||||
private textField: TextField;
|
private textField!: TextField;
|
||||||
private pressReturnField: TextField;
|
private pressReturnField!: TextField;
|
||||||
private cameraNameField: TextField;
|
private cameraNameField!: TextField;
|
||||||
private logo: Image;
|
private logo!: Image;
|
||||||
private arrowLeft: Image;
|
private arrowLeft!: Image;
|
||||||
private arrowRight: Image;
|
private arrowRight!: Image;
|
||||||
private arrowDown: Image;
|
private arrowDown!: Image;
|
||||||
private arrowUp: Image;
|
private arrowUp!: Image;
|
||||||
private microphonesList: MediaDeviceInfo[] = new Array<MediaDeviceInfo>();
|
private microphonesList: MediaDeviceInfo[] = new Array<MediaDeviceInfo>();
|
||||||
private camerasList: MediaDeviceInfo[] = new Array<MediaDeviceInfo>();
|
private camerasList: MediaDeviceInfo[] = new Array<MediaDeviceInfo>();
|
||||||
private cameraSelected: number = 0;
|
private cameraSelected: number = 0;
|
||||||
private microphoneSelected: number = 0;
|
private microphoneSelected: number = 0;
|
||||||
private soundMeter: SoundMeter;
|
private soundMeter: SoundMeter;
|
||||||
private soundMeterSprite: SoundMeterSprite;
|
private soundMeterSprite!: SoundMeterSprite;
|
||||||
private microphoneNameField: TextField;
|
private microphoneNameField!: TextField;
|
||||||
private repositionCallback: (this: Window, ev: UIEvent) => void;
|
private repositionCallback!: (this: Window, ev: UIEvent) => void;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
|
@ -21,16 +21,16 @@ enum LoginTextures {
|
|||||||
|
|
||||||
export class SelectCharacterScene extends Phaser.Scene {
|
export class SelectCharacterScene extends Phaser.Scene {
|
||||||
private readonly nbCharactersPerRow = 4;
|
private readonly nbCharactersPerRow = 4;
|
||||||
private textField: TextField;
|
private textField!: TextField;
|
||||||
private pressReturnField: TextField;
|
private pressReturnField!: TextField;
|
||||||
private logo: Image;
|
private logo!: Image;
|
||||||
private customizeButton: Image;
|
private customizeButton!: Image;
|
||||||
private customizeButtonSelected: Image;
|
private customizeButtonSelected!: Image;
|
||||||
|
|
||||||
private selectedRectangle: Rectangle;
|
private selectedRectangle!: Rectangle;
|
||||||
private selectedRectangleXPos = 0; // Number of the character selected in the rows
|
private selectedRectangleXPos = 0; // Number of the character selected in the rows
|
||||||
private selectedRectangleYPos = 0; // Number of the character selected in the columns
|
private selectedRectangleYPos = 0; // Number of the character selected in the columns
|
||||||
private selectedPlayer: Phaser.Physics.Arcade.Sprite|null; // null if we are selecting the "customize" option
|
private selectedPlayer!: Phaser.Physics.Arcade.Sprite|null; // null if we are selecting the "customize" option
|
||||||
private players: Array<Phaser.Physics.Arcade.Sprite> = new Array<Phaser.Physics.Arcade.Sprite>();
|
private players: Array<Phaser.Physics.Arcade.Sprite> = new Array<Phaser.Physics.Arcade.Sprite>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -13,8 +13,8 @@ export interface CurrentGamerInterface extends Character{
|
|||||||
|
|
||||||
export class Player extends Character implements CurrentGamerInterface {
|
export class Player extends Character implements CurrentGamerInterface {
|
||||||
userInputManager: UserInputManager;
|
userInputManager: UserInputManager;
|
||||||
previousDirection: string;
|
previousDirection: string = PlayerAnimationNames.WalkDown;
|
||||||
wasMoving: boolean;
|
wasMoving: boolean = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
Scene: GameScene,
|
Scene: GameScene,
|
||||||
|
@ -10,12 +10,12 @@ enum Textures {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class FourOFourScene extends Phaser.Scene {
|
export class FourOFourScene extends Phaser.Scene {
|
||||||
private mapNotFoundField: TextField;
|
private mapNotFoundField!: TextField;
|
||||||
private couldNotFindField: TextField;
|
private couldNotFindField!: TextField;
|
||||||
private fileNameField: Text;
|
private fileNameField!: Text;
|
||||||
private logo: Image;
|
private logo!: Image;
|
||||||
private cat: Sprite;
|
private cat!: Sprite;
|
||||||
private file: string;
|
private file!: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
|
@ -9,9 +9,8 @@ enum ReconnectingTextures {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ReconnectingScene extends Phaser.Scene {
|
export class ReconnectingScene extends Phaser.Scene {
|
||||||
private reconnectingField: TextField;
|
private reconnectingField!: TextField;
|
||||||
private logo: Image;
|
private logo!: Image;
|
||||||
private cat: Sprite;
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
|
@ -10,12 +10,12 @@
|
|||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
|
|
||||||
"strict": false, /* Enable all strict type-checking options. */
|
"strict": true, /* Enable all strict type-checking options. */
|
||||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
"strictNullChecks": true, /* Enable strict null checks. */
|
"strictNullChecks": true, /* Enable strict null checks. */
|
||||||
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||||
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||||
"strictPropertyInitialization": false, /* Enable strict checking of property initialization in classes. */
|
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||||
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
"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. */
|
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user