Skip to content

Commit

Permalink
Merge pull request #118 from Ido-Barnea/114-create-a-gold-coin-item
Browse files Browse the repository at this point in the history
Created gold coin item
  • Loading branch information
Ido-Barnea authored Dec 29, 2023
2 parents 05b434b + 38e4be1 commit 0e66c3a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 14 deletions.
19 changes: 19 additions & 0 deletions development/src/logic/items/gold.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Item } from './items';
import { Player } from '../players';
import { Piece, Position } from '../pieces';
import { Logger } from '../../ui/logger';
import { trapResource } from '../../ui/resources';


export class Gold extends Item {
constructor(player: Player, position: Position) {
super('gold coin', trapResource, player, position);
}

apply(piece: Piece) {
Logger.logGeneral(`${this.player.color} ${piece.name}
found a ${this.name} on ${piece.position.coordinates}.`);

this.player.gold++;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Logger } from '../ui/logger';
import { Piece, Position } from './pieces';
import { Player } from './players';
import { Logger } from '../../ui/logger';
import { Piece, Position } from '../pieces';
import { Player } from '../players';

export class Inventory {
items: Array<Item> = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Item } from './items';
import { Player } from './players';
import { Piece, Position } from './pieces';
import { items } from './logic';
import { Logger } from '../ui/logger';
import { spawnItemOnBoard } from '../ui/boards';
import { trapResource } from '../ui/resources';
import { Player } from '../players';
import { Piece, Position } from '../pieces';
import { items } from '../logic';
import { Logger } from '../../ui/logger';
import { spawnItemOnBoard } from '../../ui/boards';
import { trapResource } from '../../ui/resources';


export class Trap extends Item {
Expand Down
2 changes: 1 addition & 1 deletion development/src/logic/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '../ui/boards';
import { activeRules } from './rules';
import { updatePlayersInformation } from '../game';
import { Item } from './items';
import { Item } from './items/items';
import { HEAVEN_BOARD_ID, HELL_BOARD_ID, OVERWORLD_BOARD_ID } from './constants';

const whitePlayer = new Player(PlayerColors.WHITE);
Expand Down
2 changes: 1 addition & 1 deletion development/src/logic/pieces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
items,
comparePositions,
} from './logic';
import { Item } from './items';
import { Item } from './items/items';
import { OVERWORLD_BOARD_ID } from './constants';

export type Position = {
Expand Down
2 changes: 1 addition & 1 deletion development/src/logic/players.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Inventory } from './items';
import { Inventory } from './items/items';

type PlayerType = {
color: string;
Expand Down
2 changes: 1 addition & 1 deletion development/src/ui/board.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BOARD_WIDTH } from '../logic/constants';
import { Item } from '../logic/items';
import { Item } from '../logic/items/items';
import { pieces } from '../logic/logic';
import { Piece, Square } from '../logic/pieces';

Expand Down
2 changes: 1 addition & 1 deletion development/src/ui/boards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
OVERWORLD_BOARD_BUTTON_ID,
OVERWORLD_BOARD_ID,
} from '../logic/constants';
import { Item } from '../logic/items';
import { Item } from '../logic/items/items';
import { Piece, Square } from '../logic/pieces';

let overworld: ChessBoard;
Expand Down

0 comments on commit 0e66c3a

Please sign in to comment.