<commit_before>module Domain where

import Random exposing (initialSeed)
import Random.Array exposing (..)
import Array exposing (..)
import Dict exposing (..)
import Util exposing (..)

type alias Model = {
    players: Array Player,
    deck: Deck,
    discard: Deck }

type CardType = Coffee | Wax | Blue | Chili | Stink | Green | Soy | BlackEyed | Red | Garden | Cocoa

type alias Card = {
  name: String,
  cardType: CardType
}

type alias Index = Int

type alias Deck = Array Card

type alias Money = Int

type alias Player = {
  nick: String,
  hand: Array Card,
  trade: Array Card,
  side: Array Card,
  fields: Array Field,
  money: Money
}

-- Field means planted cards, where List.length cards = amount
type alias Field = {
  amount: Int,
  card: Card
}

type alias PriceMapping = {
  amount: Int,
  money: Money
}

cards = {
  coffee = card "Coffee" Coffee,
  soy = card "Soy" Soy,
  blue = card "Blue" Blue,
  wax = card "Wax" Wax,
  chili = card "Chili" Chili,
  stink = card "Stink" Stink,
  green = card "Green" Green,
  blackEyed = card "Black-eyed" BlackEyed,
  red = card "Red" Red,
  garden = card "Garden" Garden,
  cocoa = card "Cocoa" Cocoa }

allCards : Array Card
allCards =
  createDeck [
    ( 24, cards.coffee ),
    ( 22, cards.wax ),
    ( 20, cards.blue ),
    ( 18, cards.chili ),
    ( 16, cards.stink ),
    ( 14, cards.green ),
    ( 12, cards.soy ),
    ( 10, cards.blackEyed ),
    ( 8, cards.red ),
    ( 6, cards.garden ),
    ( 4, cards.cocoa ) ]

drawToTradeCardsAmount = 2

-- The value of cards given the type of card and amount of cards
-- e.g. if 4 cards of Soy then one gets 2 money
priceMeterList : CardType -> Array PriceMapping
priceMeterList cardType =
  let mappings =
    case cardType of
      Soy -> [(2, 1), (4, 2), (6, 3), (7, 4)]
      Wax -> [(4, 1), (7, 2), (9, 3), (11, 4)]
      Chili -> [(3, 1), (6, 2), (8, 3), (9, 4)]
      Garden -> [(2, 2), (3, 3)]
      Coffee -> [(4, 1), (7, 2), (10, 3), (12, 4)]
      BlackEyed -> [(2, 1), (4, 2), (5, 3), (6, 4)]
      Red -> [(2, 1), (3, 2), (4, 3), (5, 4)]
      Stink -> [(3, 1), (5, 2), (7, 3), (8, 4)]
      Blue -> [(4, 1), (6, 2), (8, 3), (10, 4)]
      Green -> [(3, 1), (5, 2), (6, 3), (7, 4)]
      Cocoa -> [(2, 2), (3, 3), (4, 4)]
    in
      let result = List.map (\mapping -> { amount = fst mapping, money = snd mapping }) mappings
      in  Array.fromList result
<commit_msg>Simplify code.<commit_after>module Domain where

import Random exposing (initialSeed)
import Random.Array exposing (..)
import Array exposing (..)
import Dict exposing (..)
import Util exposing (..)

type alias Model = {
    players: Array Player,
    deck: Deck,
    discard: Deck }

type CardType = Coffee | Wax | Blue | Chili | Stink | Green | Soy | BlackEyed | Red | Garden | Cocoa

type alias Card = {
  name: String,
  cardType: CardType
}

type alias Index = Int

type alias Deck = Array Card

type alias Money = Int

type alias Player = {
  nick: String,
  hand: Array Card,
  trade: Array Card,
  side: Array Card,
  fields: Array Field,
  money: Money
}

-- Field means planted cards, where List.length cards = amount
type alias Field = {
  amount: Int,
  card: Card
}

type alias PriceMapping = {
  amount: Int,
  money: Money
}

cards = {
  coffee = card "Coffee" Coffee,
  soy = card "Soy" Soy,
  blue = card "Blue" Blue,
  wax = card "Wax" Wax,
  chili = card "Chili" Chili,
  stink = card "Stink" Stink,
  green = card "Green" Green,
  blackEyed = card "Black-eyed" BlackEyed,
  red = card "Red" Red,
  garden = card "Garden" Garden,
  cocoa = card "Cocoa" Cocoa }

allCards : Array Card
allCards =
  createDeck [
    ( 24, cards.coffee ),
    ( 22, cards.wax ),
    ( 20, cards.blue ),
    ( 18, cards.chili ),
    ( 16, cards.stink ),
    ( 14, cards.green ),
    ( 12, cards.soy ),
    ( 10, cards.blackEyed ),
    ( 8, cards.red ),
    ( 6, cards.garden ),
    ( 4, cards.cocoa ) ]

drawToTradeCardsAmount = 2

-- The value of cards given the type of card and amount of cards
-- e.g. if 4 cards of Soy then one gets 2 money
priceMeterList : CardType -> Array PriceMapping
priceMeterList cardType =
  let mappings =
    case cardType of
      Soy -> [(2, 1), (4, 2), (6, 3), (7, 4)]
      Wax -> [(4, 1), (7, 2), (9, 3), (11, 4)]
      Chili -> [(3, 1), (6, 2), (8, 3), (9, 4)]
      Garden -> [(2, 2), (3, 3)]
      Coffee -> [(4, 1), (7, 2), (10, 3), (12, 4)]
      BlackEyed -> [(2, 1), (4, 2), (5, 3), (6, 4)]
      Red -> [(2, 1), (3, 2), (4, 3), (5, 4)]
      Stink -> [(3, 1), (5, 2), (7, 3), (8, 4)]
      Blue -> [(4, 1), (6, 2), (8, 3), (10, 4)]
      Green -> [(3, 1), (5, 2), (6, 3), (7, 4)]
      Cocoa -> [(2, 2), (3, 3), (4, 4)]
    in
      Array.map (\(a, m) -> { amount = a, money = m }) (Array.fromList mappings)

{'fraction_non_alphanumeric': 0.1729513376869602, 'fraction_numerical': 0.0455024225826838, 'mean_word_length': 2.5592203898050974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7092541', 'n_tokens_mistral': 1989, 'n_tokens_neox': 1814, 'n_words': 636}