export const numAges = 3
export const minPlayers = 3
export const maxPlayers = 7
export const startingGold = 3
export const discardGold = 3
export const victoryPoints = [1, 3, 5]
export const defeatPoints = -1
export const goldPerPoint = 3
export const scienceSetPoints = 7

export type Resource = 'wood' | 'stone' | 'ore' | 'brick' | 'paper' | 'cloth' | 'glass'
export const resources: Resource[] = ['wood', 'stone', 'ore', 'brick', 'paper', 'cloth', 'glass']

export type Science = 'engineering' | 'research' | 'education'
export const sciences: Science[] = ['engineering', 'research', 'education']

export interface TurnPlan {
  action: 'structure' | 'discard' | 'wonder'
  cardIdx: number
  goldLeft: number
  goldRight: number
}

export interface Player {
  name: string
  wonder?: string
  gold: number
  structures: {
    age: number
    structure: string
  }[]

  hand: string[]
  turnPlan?: TurnPlan

  leftBattles: number[]
  rightBattles: number[]
}

export interface State {
  stage: 'starting' | 'play' | 'finished'
  players: Player[]

  age?: number
  turnsRemaining?: number
  discard: string[]
}

export const initial: State = {
  stage: 'starting',
  players: [],
  discard: [],
}
export const sampleState: State = {
  stage: 'play',
  age: 2,
  turnsRemaining: 4,
  discard: [
    'Scriptorium', 'Scriptorium', 'Guard Tower', 'Baths', 'Stone Pit',
    'Caravansery', 'Loom', 'Loom', 'Stables', 'Courthouse',
    'Craftsmens Guild', 'Strategists Guild', 'Pantheon', 'Palace', 'Chamber of Commerce'
  ],
  players: [
    {
      name: 'Player A',
      gold: 2,
      leftBattles: [1, 3],
      rightBattles: [1, 3],
      wonder: 'Mausoleum at Halicarnassus B',
      hand: ['Study', 'Arsenal', 'Haven', 'Haven'],
      structures: [
        { age: 0, structure: 'Stockade' },
        { age: 0, structure: 'Barracks' },
        { age: 0, structure: 'Barracks' },
        { age: 0, structure: 'Glassworks' },
        { age: 0, structure: 'Stone Pit' },
        { age: 0, structure: 'Lumber Yard' },
        { age: 1, structure: 'Walls' },
        { age: 1, structure: 'Bazar' },
        { age: 1, structure: 'Caravansery' },
        { age: 1, structure: 'Forum' },
        { age: 1, structure: 'Aqueduct' },
        { age: 1, structure: 'Quarry' },
        { age: 2, structure: 'Arena' },
        { age: 2, structure: 'Fortifications' },
      ]
    }, {
      name: 'Player B',
      gold: 5,
      leftBattles: [-1, -1],
      rightBattles: [-1, -1],
      wonder: 'Temple of Artemis at Ephesus B',
      hand: ['Town Hall', 'University', 'Arsenal', 'Circus'],
      structures: [
        { age: 0, structure: 'Apothecary' },
        { age: 0, structure: 'Pawnshop' },
        { age: 0, structure: 'Timber Yard' },
        { age: 0, structure: 'Press' },
        { age: 0, structure: 'Ore Vein' },
        { age: 0, structure: 'Clay Pool' },
        { age: 1, structure: 'Courthouse' },
        { age: 1, structure: 'Statue' },
        { age: 1, structure: 'Laboratory' },
        { age: 1, structure: 'Library' },
        { age: 1, structure: 'Sawmill' },
        { age: 1, structure: 'Foundry' },
        { age: 2, structure: 'Lighthouse' },
        { age: 2, structure: 'Builders Guild' },
      ]
    }, {
      name: 'Player C',
      gold: 3,
      leftBattles: [1, 3],
      rightBattles: [1, 3],
      wonder: 'Hanging Gardens of Babylon B',
      hand: ['Town Hall', 'Magistrates Guild', 'Scientists Guild', 'Workers Guild'],
      structures: [
        { age: 0, structure: 'Clay Pool' },
        { age: 0, structure: 'Forest Cave' },
        { age: 0, structure: 'Loom' },
        { age: 0, structure: 'Ore Vein' },
        { age: 0, structure: 'Guard Tower' },
        { age: 0, structure: 'East Trading Post' },
        { age: 1, structure: 'Laboratory' },
        { age: 1, structure: 'Archery Range' },
        { age: 1, structure: 'Dispensary' },
        { age: 1, structure: 'Glassworks' },
        { age: 1, structure: 'Press' },
        { age: 1, structure: 'Glassworks' },
        { age: 2, structure: 'Siege Workshop' },
        { age: 2, structure: 'Philosophers Guild' },
      ]
    }, {
      name: 'Player D',
      gold: 10,
      leftBattles: [-1, -1],
      rightBattles: [],
      wonder: 'Colossus of Rhodes A',
      hand: ['Senate', 'Study', 'Senate', 'Arena'],
      structures: [
        { age: 0, structure: 'Excavation' },
        { age: 0, structure: 'Lumber Yard' },
        { age: 0, structure: 'Clay Pit' },
        { age: 0, structure: 'Workshop' },
        { age: 0, structure: 'Tavern' },
        { age: 0, structure: 'West Trading Post' },
        { age: 1, structure: 'Temple' },
        { age: 1, structure: 'Vineyard' },
        { age: 1, structure: 'Stables' },
        { age: 1, structure: 'Press' },
        { age: 1, structure: 'Quarry' },
        { age: 1, structure: 'Brickyard' },
        { age: 2, structure: 'Gardens' },
        { age: 2, structure: 'Circus' },
      ]
    }, {
      name: 'Player E',
      gold: 0,
      leftBattles: [],
      rightBattles: [-1, -1],
      wonder: 'Great Pyramid of Giza A',
      hand: ['Observatory', 'Academy', 'University', 'Lodge'],
      structures: [
        { age: 0, structure: 'Apothecary' },
        { age: 0, structure: 'Tavern' },
        { age: 0, structure: 'Altar' },
        { age: 0, structure: 'Theater' },
        { age: 0, structure: 'Marketplace' },
        { age: 0, structure: 'Altar' },
        { age: 1, structure: 'Sawmill' },
        { age: 1, structure: 'Foundry' },
        { age: 1, structure: 'Brickyard' },
        { age: 1, structure: 'Dispensary' },
        { age: 1, structure: 'Training Ground' },
        { age: 1, structure: 'School' },
        { age: 2, structure: 'Siege Workshop' },
        { age: 2, structure: 'Gardens' },
      ]
    },
  ],
}
