import { List } from "../../../Data/List"
import { Maybe, Nothing } from "../../../Data/Maybe"
import { fromDefault, makeLenses, Record } from "../../../Data/Record"
import { Category } from "../../Constants/Categories"
import { SocialStatusId } from "../../Constants/Ids"
import { CommonProfession } from "./sub/CommonProfession"
import { Erratum } from "./sub/Errata"
import { IncreaseSkill } from "./sub/IncreaseSkill"
import { SourceLink } from "./sub/SourceLink"
import { EntryWithCategory } from "./wikiTypeHelpers"

export interface Culture {
  "@@name": "Culture"
  id: string
  name: string
  culturalPackageAdventurePoints: number
  languages: List<number>
  scripts: List<number>
  socialStatus: List<SocialStatusId>
  areaKnowledge: string
  areaKnowledgeShort: string
  commonProfessions: List<boolean | Record<CommonProfession>>
  commonMundaneProfessions: Maybe<string>
  commonMagicProfessions: Maybe<string>
  commonBlessedProfessions: Maybe<string>
  commonAdvantages: List<string>
  commonAdvantagesText: Maybe<string>
  commonDisadvantages: List<string>
  commonDisadvantagesText: Maybe<string>
  uncommonAdvantages: List<string>
  uncommonAdvantagesText: Maybe<string>
  uncommonDisadvantages: List<string>
  uncommonDisadvantagesText: Maybe<string>
  commonSkills: List<string>
  uncommonSkills: List<string>
  commonNames: string
  culturalPackageSkills: List<Record<IncreaseSkill>>
  src: List<Record<SourceLink>>
  errata: List<Record<Erratum>>
  category: Category
}

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const Culture =
  fromDefault ("Culture")
              <Culture> ({
                id: "",
                name: "",
                culturalPackageAdventurePoints: 0,
                languages: List.empty,
                scripts: List.empty,
                socialStatus: List.empty,
                areaKnowledge: "",
                areaKnowledgeShort: "",
                commonProfessions: List.empty,
                commonMundaneProfessions: Nothing,
                commonMagicProfessions: Nothing,
                commonBlessedProfessions: Nothing,
                commonAdvantages: List.empty,
                commonAdvantagesText: Nothing,
                commonDisadvantages: List.empty,
                commonDisadvantagesText: Nothing,
                uncommonAdvantages: List.empty,
                uncommonAdvantagesText: Nothing,
                uncommonDisadvantages: List.empty,
                uncommonDisadvantagesText: Nothing,
                commonSkills: List.empty,
                uncommonSkills: List.empty,
                commonNames: "",
                culturalPackageSkills: List.empty,
                category: Category.CULTURES,
                src: List.empty,
                errata: List (),
              })

export const CultureL = makeLenses (Culture)

export const isCulture =
  (r: EntryWithCategory) => Culture.AL.category (r) === Category.CULTURES
