Skip to content

Commit

Permalink
format all files with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
RonaldoSetzer committed Nov 27, 2017
1 parent 6676fa1 commit 5126431
Show file tree
Hide file tree
Showing 64 changed files with 396 additions and 682 deletions.
17 changes: 17 additions & 0 deletions typescript-tetris/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"printWidth": 120,
"tabWidth": 2,
"overrides": [
{
"files": "*.ts",
"options": {
"tabWidth": 4
}
}
],
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "none",
"bracketSpacing": true
}
8 changes: 5 additions & 3 deletions typescript-tetris/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
"name": "typescript-tetris",
"version": "1.0.0",
"description": "OpenSource Game",
"main": "index.js",
"main": "src/index.ts",
"author": "Ronaldo Santiago",
"license": "MIT",
"dependencies": {
"@robotlegsjs/core": "^0.1.1",
"@robotlegsjs/pixi": "^0.1.2",
"@robotlegsjs/pixi-palidor": "^0.1.1",
"pixi.js": "^4.6.1",
"prettier": "^1.8.2",
"reflect-metadata": "^0.1.10"
},
"devDependencies": {
Expand All @@ -21,14 +20,17 @@
"html-webpack-plugin": "^2.30.1",
"http-server": "^0.10.0",
"mocha": "^4.0.1",
"prettier": "^1.8.2",
"ts-loader": "^3.1.1",
"ts-node": "^3.3.0",
"tslint": "^5.8.0",
"tslint-config-prettier": "^1.6.0",
"typescript": "^2.6.1",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.4"
},
"scripts": {
"autoformat": "prettier --config .prettierrc --write '{src,test}/**/*.ts'",
"start": "webpack-dev-server --config ./webpack.setzer.config.js",
"test": "mocha test/**/*.test.ts --require ts-node/register"
},
Expand All @@ -40,4 +42,4 @@
"PixiJs",
"Game"
]
}
}
25 changes: 7 additions & 18 deletions typescript-tetris/src/commands/CreateLevelCommand.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import { FlowService } from "./../services/FlowService";
import { GameService } from "./../services/GameService";
import { ICommand, inject, injectable } from "@robotlegsjs/core";

import { GameModel } from "./../models/GameModel";
import { GameStatus } from "./../models/GameStatus";
import { FlowService } from "./../services/FlowService";
import { GameService } from "./../services/GameService";
import { TileGroupFactory } from "./../utils/TileGroupFactory";

import { ICommand, injectable, inject } from "@robotlegsjs/core";

@injectable()
export class CreateLevelCommand implements ICommand {

@inject(GameModel)
private model: GameModel;

@inject(GameService)
private gameService: GameService;

@inject(FlowService)
private flowService: FlowService;

/*@inject(SharedObjectManager)
public sharedObjectManager: SharedObjectManager;*/
@inject(GameModel) private model: GameModel;
@inject(GameService) private gameService: GameService;
@inject(FlowService) private flowService: FlowService;

public execute(): void {
// sharedObjectManager.getExternalData();

this.model.clear();
this.model.currentPiece = TileGroupFactory.getRandomTileGroup();
this.model.nextPiece = TileGroupFactory.getRandomTileGroup();
Expand Down
20 changes: 5 additions & 15 deletions typescript-tetris/src/commands/GameOverCommand.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import { FlowService } from "./../services/FlowService";
import { ICommand, inject, injectable } from "@robotlegsjs/core";

import { GameModel } from "./../models/GameModel";
import { GameStatus } from "./../models/GameStatus";

import { inject, injectable, ICommand } from "@robotlegsjs/core";
import { FlowService } from "./../services/FlowService";

@injectable()
export class GameOverCommand implements ICommand {

@inject(GameModel)
private model: GameModel;

@inject(FlowService)
private flowService: FlowService;

/*@inject(SharedObjectManager)
public sharedObjectManager:SharedObjectManager;*/
@inject(GameModel) private model: GameModel;
@inject(FlowService) private flowService: FlowService;

public execute(): void {
this.model.status = GameStatus.GAMEOVER;

/*this.sharedObjectManager.updateHighScore();*/

this.flowService.showGameOverPopup();
}
}
14 changes: 5 additions & 9 deletions typescript-tetris/src/commands/GetNextPieceCommand.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { GameService } from "./../services/GameService";
import { ICommand, inject, injectable } from "@robotlegsjs/core";

import { GameModel } from "./../models/GameModel";
import { GameService } from "./../services/GameService";
import { TileGroupFactory } from "./../utils/TileGroupFactory";

import { inject, injectable, ICommand } from "@robotlegsjs/core";

@injectable()
export class GetNextPieceCommand implements ICommand {

@inject(GameModel)
private model: GameModel;

@inject(GameService)
private gameService: GameService;
@inject(GameModel) private model: GameModel;
@inject(GameService) private gameService: GameService;

public execute(): void {
this.model.currentPiece = this.model.nextPiece;
Expand Down
16 changes: 5 additions & 11 deletions typescript-tetris/src/commands/IncreasePointsCommand.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import { ICommand, inject, injectable } from "@robotlegsjs/core";

import { GameEvent } from "./../events/GameEvent";
import { GameModel } from "./../models/GameModel";
import { GameService } from "./../services/GameService";
import { GameUtils } from "./../utils/GameUtils";

import { inject, injectable, ICommand } from "@robotlegsjs/core";

@injectable()
export class IncreasePointsCommand implements ICommand {

@inject(GameModel)
private model: GameModel;

@inject(GameEvent)
private event: GameEvent;

@inject(GameService)
private gameService: GameService;
@inject(GameModel) private model: GameModel;
@inject(GameEvent) private event: GameEvent;
@inject(GameService) private gameService: GameService;

public execute(): void {
this.model.score += GameUtils.getPointsByLines(this.event.lines);
Expand Down
33 changes: 17 additions & 16 deletions typescript-tetris/src/configs/GameConfig.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import { IConfig, IContext, IEventCommandMap, inject, injectable } from "@robotlegsjs/core";

import { CreateLevelCommand } from "./../commands/CreateLevelCommand";
import { GameOverCommand } from "./../commands/GameOverCommand";
import { GetNextPieceCommand } from "./../commands/GetNextPieceCommand";
import { IncreasePointsCommand } from "./../commands/IncreasePointsCommand";
import { TilePool } from "./../utils/TilePool";

import { GameEvent } from "./../events/GameEvent";
import { GameManager } from "./../managers/GameManager";
import { GameModel } from "./../models/GameModel";
import { GameService } from "./../services/GameService";

import { IConfig, injectable, inject, IEventCommandMap, IContext } from "@robotlegsjs/core";
import { TilePool } from "./../utils/TilePool";

@injectable()
export class GameConfig implements IConfig {

@inject(IContext)
private context: IContext;

@inject(IEventCommandMap)
private commandMap: IEventCommandMap;
@inject(IContext) private context: IContext;
@inject(IEventCommandMap) private commandMap: IEventCommandMap;

public configure(): void {
TilePool.init();
Expand All @@ -27,21 +22,27 @@ export class GameConfig implements IConfig {
this.mapManager();
this.mapModels();
}

private mapCommands(): void {
this.commandMap.map(GameEvent.CREATE_LEVEL).toCommand(CreateLevelCommand);
this.commandMap.map(GameEvent.GAME_OVER).toCommand(GameOverCommand);
this.commandMap.map(GameEvent.GET_NEXT_PIECE).toCommand(GetNextPieceCommand);
this.commandMap.map(GameEvent.INCREASE_POINTS).toCommand(IncreasePointsCommand);
}

private mapManager(): void {
this.context.injector.bind(GameService).to(GameService).inSingletonScope();
this.context.injector.bind(GameManager).to(GameManager).inSingletonScope();
this.context.injector
.bind(GameService)
.to(GameService)
.inSingletonScope();
this.context.injector
.bind(GameManager)
.to(GameManager)
.inSingletonScope();
// this.context.injector.bind( SharedObjectManager ).to(SharedObjectManager).inSingletonScope();*
}

private mapModels(): void {
this.context.injector.bind(GameModel).to(GameModel).inSingletonScope();
this.context.injector
.bind(GameModel)
.to(GameModel)
.inSingletonScope();
}
}
25 changes: 10 additions & 15 deletions typescript-tetris/src/configs/PalidorConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { IConfig, IContext, IEventDispatcher, inject, injectable } from "@robotlegsjs/core";
import { IFlowManager } from "@robotlegsjs/pixi-palidor";

import { FlowEvent } from "./../events/FlowEvent";
import { FlowService } from "./../services/FlowService";

import { GameOverPopup } from "./../views/GameOverPopup";
import { GameView } from "./../views/GameView";
import { HomeView } from "./../views/HomeView";
Expand All @@ -11,28 +13,21 @@ import { PausePopup } from "./../views/PausePopup";
import { ResetConfirmPopup } from "./../views/ResetConfirmPopup";
import { StartingPopup } from "./../views/StartingPopup";

import { IFlowManager } from "@robotlegsjs/pixi-palidor";
import { injectable, IConfig, inject, IContext, IEventDispatcher } from "@robotlegsjs/core";

@injectable()
export class PalidorConfig implements IConfig {

@inject(IContext)
private context: IContext;

@inject(IFlowManager)
private flowManager: IFlowManager;

@inject(IEventDispatcher)
private eventDispatcher: IEventDispatcher;
@inject(IContext) private context: IContext;
@inject(IFlowManager) private flowManager: IFlowManager;
@inject(IEventDispatcher) private eventDispatcher: IEventDispatcher;

public configure(): void {
this.mapPalidor();
this.eventDispatcher.dispatchEvent(new FlowEvent(FlowEvent.SHOW_INTRO_VIEW));
}

private mapPalidor(): void {
this.context.injector.bind(FlowService).to(FlowService).inSingletonScope();
this.context.injector
.bind(FlowService)
.to(FlowService)
.inSingletonScope();

this.flowManager.map(FlowEvent.SHOW_GAME_VIEW).toView(GameView);
this.flowManager.map(FlowEvent.SHOW_HOME_VIEW).toView(HomeView);
Expand Down
15 changes: 5 additions & 10 deletions typescript-tetris/src/configs/ViewsConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { IConfig, inject, injectable } from "@robotlegsjs/core";
import { IMediatorMap } from "@robotlegsjs/pixi";

import { GameOverPopupMediator } from "./../mediators/GameOverPopupMediator";
import { GameViewMediator } from "./../mediators/GameViewMediator";
import { GridComponentMediator } from "./../mediators/GridComponentMediator";
Expand All @@ -10,11 +13,9 @@ import { OptionsViewMediator } from "./../mediators/OptionsViewMediator";
import { PausePopupMediator } from "./../mediators/PausePopupMediator";
import { ResetConfirmPopupMediator } from "./../mediators/ResetConfirmPopupMediator";
import { StartingPopupMediator } from "./../mediators/StartingPopupMediator";

import { GridComponent } from "./../views/components/GridComponent";
import { NextPieceComponent } from "./../views/components/NextPieceComponent";
import { HUDGameComponent } from "./../views/components/HUDGameComponent";

import { NextPieceComponent } from "./../views/components/NextPieceComponent";
import { GameOverPopup } from "./../views/GameOverPopup";
import { GameView } from "./../views/GameView";
import { HomeView } from "./../views/HomeView";
Expand All @@ -25,19 +26,13 @@ import { PausePopup } from "./../views/PausePopup";
import { ResetConfirmPopup } from "./../views/ResetConfirmPopup";
import { StartingPopup } from "./../views/StartingPopup";

import { IMediatorMap } from "@robotlegsjs/pixi";
import { injectable, IConfig, inject } from "@robotlegsjs/core";

@injectable()
export class ViewsConfig implements IConfig {

@inject(IMediatorMap)
private mediatorMap: IMediatorMap;
@inject(IMediatorMap) private mediatorMap: IMediatorMap;

public configure(): void {
this.mapMediators();
}

private mapMediators(): void {
this.mediatorMap.map(GameView).toMediator(GameViewMediator);
this.mediatorMap.map(HomeView).toMediator(HomeViewMediator);
Expand Down
1 change: 0 additions & 1 deletion typescript-tetris/src/events/FlowEvent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Event } from "@robotlegsjs/core";

export class FlowEvent extends Event {

public static SHOW_GAME_VIEW = "showGameView";
public static SHOW_HOME_VIEW = "showHomeView";
public static SHOW_INTRO_VIEW = "showIntroView";
Expand Down
1 change: 0 additions & 1 deletion typescript-tetris/src/events/GameEvent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Event } from "@robotlegsjs/core";

export class GameEvent extends Event {

public static CREATE_LEVEL = "createLevel";
public static CLEAR_GRID = "clearGrid";
public static GAME_OVER = "gameOver";
Expand Down
19 changes: 9 additions & 10 deletions typescript-tetris/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// tslint:disable-next-line:no-reference
/// <reference path="../node_modules/@robotlegsjs/pixi/definitions/pixi.d.ts" />

import "reflect-metadata";

import { Context, MVCSBundle } from "@robotlegsjs/core";
import { ContextView, PixiBundle } from "@robotlegsjs/pixi";
import { PalidorPixiExtension } from "@robotlegsjs/pixi-palidor";
import PIXI = require("pixi.js");

import { GameConfig } from "./configs/GameConfig";
import { PalidorConfig } from "./configs/PalidorConfig";
import { ViewsConfig } from "./configs/ViewsConfig";

import { Context, MVCSBundle, LogLevel } from "@robotlegsjs/core";
import { PixiBundle, ContextView } from "@robotlegsjs/pixi";
import { PalidorPixiExtension } from "@robotlegsjs/pixi-palidor";

class Main {
private stage: PIXI.Container;
private renderer: PIXI.CanvasRenderer | PIXI.WebGLRenderer;
Expand All @@ -21,20 +21,19 @@ class Main {
this.stage = new PIXI.Container();
this.context = new Context();
// this.context.logLevel = LogLevel.DEBUG;
this.context.install(MVCSBundle, PixiBundle)
this.context
.install(MVCSBundle, PixiBundle)
.install(PalidorPixiExtension)
.configure(new ContextView(this.stage))
.configure(ViewsConfig, GameConfig, PalidorConfig)
.initialize();

document.body.appendChild(this.renderer.view);
}

public render = () => {
this.renderer.render(this.stage);
window.requestAnimationFrame(this.render);
}
};
}

let main = new Main();
const main = new Main();
main.render();
Loading

0 comments on commit 5126431

Please sign in to comment.