Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Made SidedBoard a map instead of [][]
Browse files Browse the repository at this point in the history
  • Loading branch information
Tikidoodlep1 committed Mar 14, 2024
1 parent ecab625 commit eb8afde
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,27 @@ class BoardPos {
}

class SidedBoard {
lanes: BoardPos[][];

constructor(sideOnePlayerId: number, sideTwoPlayerId: number) {
this.lanes = [
[new BoardPos(sideOnePlayerId), new BoardPos(sideTwoPlayerId)],
[new BoardPos(sideOnePlayerId), new BoardPos(sideTwoPlayerId)],
[new BoardPos(sideOnePlayerId), new BoardPos(sideTwoPlayerId)],
[new BoardPos(sideOnePlayerId), new BoardPos(sideTwoPlayerId)]
];
lanes: Map<number, BoardPos[]>;

constructor() {
this.lanes = new Map();
}

addPlayer(playerId: number) {
this.lanes.set(playerId, [new BoardPos(playerId), new BoardPos(playerId), new BoardPos(playerId), new BoardPos(playerId)]);
}

getLaneByOwnerId(ownerId: number): BoardPos[] | undefined {
return this.lanes.get(ownerId);
}

getBoardPosByOwnerId(ownerId: number, boardPos: number): BoardPos | undefined {
var lane = this.getLaneByOwnerId(ownerId);
if(typeof(lane) != "undefined") {
return lane[boardPos];
}else {
return lane;
}
}
}

Expand Down

0 comments on commit eb8afde

Please sign in to comment.