export const BLOCK_SIZE = 64 // each block is 64̨̣̌̇x64 pixel in size and equals 1m
export const RECIPROCAL = 1 / BLOCK_SIZE

export const STAGE_WIDTH = 20 // 20*64 = 1280 pixel wide stage
// export const STAGE_HEIGHT = ~~(STAGE_WIDTH * 0.5625) // 16:9 😎
export const STAGE_HEIGHT = 12 // 12*64 = 768 pixel high stage

export const GRAVITY = 10 // blocks per second

export type Block = {
  type: string,
  hp: number,
  walkable: boolean,
  climbable?: boolean,
}

export const blockTypes: Record<string, Block> = {
  air: { type: 'air', hp: Infinity, walkable: true },
  grass: { type: 'grass', hp: 1, walkable: false },

  treeTopLeft: { type: 'treeTopLeft', hp: 5, walkable: true },
  treeTopMiddle: { type: 'treeTopMiddle', hp: 5, walkable: true },
  treeTopRight: { type: 'treeTopRight', hp: 5, walkable: true },

  treeCrownLeft: { type: 'treeCrownLeft', hp: 5, walkable: true },
  treeCrownMiddle: { type: 'treeCrownMiddle', hp: 5, walkable: true, climbable: true },
  treeCrownRight: { type: 'treeCrownRight', hp: 5, walkable: true },

  treeTrunkLeft: { type: 'treeTrunkLeft', hp: 5, walkable: true },
  treeTrunkMiddle: { type: 'treeTrunkMiddle', hp: 5, walkable: true, climbable: true },
  treeTrunkRight: { type: 'treeTrunkRight', hp: 5, walkable: true },

  treeRootLeft: { type: 'treeRootLeft', hp: 5, walkable: true },
  treeRootMiddle: { type: 'treeRootMiddle', hp: 5, walkable: true, climbable: true },
  treeRootRight: { type: 'treeRootRight', hp: 5, walkable: true },

  treeTopLeftMixed: { type: 'treeTopLeftMixed', hp: 5, walkable: true },
  treeCrownLeftMixed: { type: 'treeCrownLeftMixed', hp: 5, walkable: true },
  treeTrunkLeftMixed: { type: 'treeTrunkLeftMixed', hp: 5, walkable: true },
  treeRootLeftMixed: { type: 'treeRootLeftMixed', hp: 5, walkable: true },

  treeTopRightMixed: { type: 'treeTopRightMixed', hp: 5, walkable: true },
  treeCrownRightMixed: { type: 'treeCrownRightMixed', hp: 5, walkable: true },
  treeTrunkRightMixed: { type: 'treeTrunkRightMixed', hp: 5, walkable: true },
  treeRootRightMixed: { type: 'treeRootRightMixed', hp: 5, walkable: true },

  soil: { type: 'soil', hp: 2, walkable: false },
  soilGravel: { type: 'soilGravel', hp: 5, walkable: false },
  stoneGravel: { type: 'stoneGravel', hp: 5, walkable: false },
  stone: { type: 'stone', hp: 10, walkable: false },
  bedrock: { type: 'bedrock', hp: 25, walkable: false },
  cave: { type: 'cave', hp: Infinity, walkable: true },
}

export const level = {
  treeTop: 10,
  ground: 14,
  rock: 16,
  underground: 24,
  caveMax: 250,
}

export const probability = {
  tree: 0.2,
  soilHole: 0.3,
  soilGravel: 0.2,
  stoneGravel: 0.1,
  cave: 0.5,
  fray: 0.4,
}
