import { MAX_ROADS, MAX_CITIES, MAX_SETTLEMENTS } from "./constants";
import { PLAYER_COLORS, type Player, type PlayerColor } from "./types";

export const newPlayer = (color: PlayerColor): Player => {
  const tmp = {} as any;
  PLAYER_COLORS.forEach((c) => { tmp[c] = false; });
  const offerRejected = { ...tmp };
  return {
    roads: MAX_ROADS,
    cities: MAX_CITIES,
    settlements: MAX_SETTLEMENTS,
    points: 0,
    status: "Not active",
    lastActive: 0,
    resources: 0,
    order: 0,
    stone: 0,
    wheat: 0,
    sheep: 0,
    wood: 0,
    brick: 0,
    desert: 0, /* Not used -- for Typescript compliance */
    bank: 0, /* Not used -- for Typescript compliance */
    army: 0,
    development: [],
    color: color,
    name: "",
    totalTime: 0,
    turnStart: 0,
    ports: 0,
    developmentCards: 0,
    orderRoll: 0,
    position: "",
    orderStatus: "none",
    tied: false,
    mustDiscard: 0,
    live: true,
    turnNotice: "",
    longestRoad: 0,
    banks: [],
    gives: [],
    gets: [],
    offerRejected,
  };
};

export default newPlayer;
