Skip to content

Commit

Permalink
Update non-state-changing commands to ReadOnlyGameState
Browse files Browse the repository at this point in the history
  • Loading branch information
dshaneg committed Mar 1, 2018
1 parent c2f92c4 commit 9d333e6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/commands/conjure-item-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Command } from './command';
import { EventPublisher } from '../domain/event-publisher';
import { Voice } from '../domain/voice';
import { GameState } from '../state/game-state';
import { ReadOnlyGameState } from '../state/game-state';
import { CommandFactory } from './command-factory';

import { ItemRepository } from '../item-repository';
Expand All @@ -20,7 +20,7 @@ export class ConjureItemCommand implements Command {
private count: number = 1) {
}

execute(gameState: GameState, publisher: EventPublisher): void {
execute(gameState: ReadOnlyGameState, publisher: EventPublisher): void {
const item = this.itemRepository.get(this.itemId);
const count = this.count;

Expand Down
4 changes: 2 additions & 2 deletions src/commands/help-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Command } from './command';
import { EventPublisher } from '../domain/event-publisher';
import { Voice } from '../domain/voice';
import { GameState } from '../state/game-state';
import { ReadOnlyGameState } from '../state/game-state';
import { GameDefinitionRepository, GameDefinition } from '../game-definition-repository';

/**
Expand All @@ -16,7 +16,7 @@ export class HelpCommand implements Command {
constructor(private gameDefinitionRepository: GameDefinitionRepository) {
}

execute(gameState: GameState, publisher: EventPublisher): void {
execute(gameState: ReadOnlyGameState, publisher: EventPublisher): void {
publisher.publish({
topic: 'game.help-requested',
message: this.gameDefinitionRepository.getGameDefinition().help,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/list-inventory-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import { Command } from './command';
import { EventPublisher } from '../domain/event-publisher';
import { Voice } from '../domain/voice';
import { GameState } from '../state/game-state';
import { ReadOnlyGameState } from '../state/game-state';
import { ItemFormatter } from './item-formatter';

/**
* Class representing a command instructing the game to provide the contents of the player's inventory.
*/
export class ListInventoryCommand implements Command {

execute(gameState: GameState, publisher: EventPublisher): void {
execute(gameState: ReadOnlyGameState, publisher: EventPublisher): void {
const items = gameState.queryInventory();

let message: string;
Expand Down

0 comments on commit 9d333e6

Please sign in to comment.