diff --git a/src/app/board/control-container/control-container.component.ts b/src/app/board/control-container/control-container.component.ts index dcf14ce..4f4481f 100644 --- a/src/app/board/control-container/control-container.component.ts +++ b/src/app/board/control-container/control-container.component.ts @@ -3,7 +3,7 @@ import { Store } from '@ngrx/store'; import { Observable } from 'rxjs/Observable'; import { map } from 'rxjs/operators'; import * as fromStore from '../../store'; -import { ResetScore, StartPlaying, StopPlaying } from '../../store/actions'; +import { ResetScore, StartPlaying, StopPlaying, ResetAttempts } from '../../store/actions'; // import { AddScore } from '../../store/actions/score.actions'; // import { AddAttempt } from '../../store/actions/attempts.actions'; import { Attempt } from './../../store/reducers/attempts.reducer'; @@ -105,6 +105,7 @@ export class ControlContainerComponent implements OnInit { private startGame() { this.store.dispatch(new StartPlaying()); this.store.dispatch(new ResetScore()); + this.store.dispatch(new ResetAttempts()); // TODO #10 dispatch the Action for reset the attempts here this.startGameSound.nativeElement.play(); setTimeout(() => this.generateRandomControl(), this.TIME_TO_START_GAME); diff --git a/src/app/store/actions/attempts.actions.ts b/src/app/store/actions/attempts.actions.ts index 60501a3..d36eefa 100644 --- a/src/app/store/actions/attempts.actions.ts +++ b/src/app/store/actions/attempts.actions.ts @@ -1,3 +1,5 @@ +import { Action } from "@ngrx/store"; + // Action Constants // TODO #1 : Define the ADD_ATTEMPT and RESET_ATTEMPT actions @@ -5,7 +7,8 @@ export const RESET_ATTEMPTS = '[Attempts] Reset Attempts'; // Action Creators // TODO #2 : Define the AddAttempt and ResetAttempts implementing the Action (@ngrx/store) interface -export class ResetAttempts { +export class ResetAttempts implements Action { + readonly type = RESET_ATTEMPTS; } // Action Types diff --git a/src/app/store/actions/score.actions.ts b/src/app/store/actions/score.actions.ts index 8a79ebd..6646e90 100644 --- a/src/app/store/actions/score.actions.ts +++ b/src/app/store/actions/score.actions.ts @@ -1,15 +1,15 @@ // Action Constants -// TODO #4 Add actions here +// TODO #4 Add the action to add score here import { Action } from '@ngrx/store'; export const RESET_SCORE = '[Score] Setting the score to 0'; // Action Creators -// TODO #5 Implement action creators here +// TODO #5 Implement action creators to add the score here export class ResetScore implements Action { readonly type = RESET_SCORE; } // Action Types -// TODO #6 Implement action types here. Do not forget export your things. +// TODO #6 Implement action types remaining here. Do not forget export your things. export type ScoreActions = ResetScore; diff --git a/src/app/store/reducers/index.ts b/src/app/store/reducers/index.ts index 03fbf9e..110e737 100644 --- a/src/app/store/reducers/index.ts +++ b/src/app/store/reducers/index.ts @@ -8,6 +8,8 @@ import { ActionReducerMap } from '@ngrx/store'; */ export interface ApplicationState { ui: fromUi.UiState; + attempts: any; + score: any; } /** @@ -16,4 +18,6 @@ export interface ApplicationState { */ export const reducers: ActionReducerMap = { ui: fromUi.reducer, + attempts: () => {}, + score: () => {} };