Skip to content

Instantly share code, notes, and snippets.

@jalvarado91
Created January 10, 2019 16:00
Show Gist options
  • Save jalvarado91/4417b379dff58884a97b68688e6ed2a7 to your computer and use it in GitHub Desktop.
Save jalvarado91/4417b379dff58884a97b68688e6ed2a7 to your computer and use it in GitHub Desktop.
type Player = "Boot" | "Battleship" | "Iron";
type Color = "Brown" | "Magenta" | "LightBlue";
type Houses = { count: number };
type Development = "Empty" | Houses | "Hotel";
// type TileTypes = "Street" | "Utility" | "Tax" | "Station";
type Tile = {
// type: TileTypes;
name: string;
cost: number;
};
type OwnableTile = Tile & { owner?: Player };
type Street = OwnableTile & {
type: "Street";
color: Color;
development: Development;
rentals: number[];
};
type Utility = OwnableTile & { type: "Utility" };
type Station = OwnableTile & { type: "Station" };
type Tax = Tile & { type: "Tax"; amount: number };
// type Street = {
// tag: "Street";
// name: string;
// cost: number;
// color: Color;
// development: Development;
// rentals: number[];
// owner?: Player;
// };
// type Utility = {
// tag: "Utility";
// name: string;
// cost: number;
// owner?: Player;
// };
// type Station = {
// tag: "Station";
// name: string;
// cost: number;
// owner?: Player;
// };
// type Tax = {
// tag: "Tax";
// name: string;
// amount: number;
// owner?: Player;
// };
type TileLocation = Street | Utility | Station | Tax;
type Board = TileLocation[];
const ownsLocation = (player: Player, location: Tile): boolean => {
return false;
};
const streetsOfColor = (color: Color, board: Board) => {
return board
.filter((tile): tile is Street => tile.type === "Street")
.map(tile => tile.color === color);
};
const ownsStreetSet = (player: Player, color: Color, board: Board): boolean => {
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment