<commit_before>import { Card, Deck, Grills, Hand, Pile, Rank, Suit, Table } from '../../types/Cards'

export const theBlackCatCard: Card = { suit: 'Spades', rank: 'Queen' }

export const cardEqual = (a: Card) => (b: Card): boolean => {
  return a.suit === b.suit && a.rank === b.rank
}

export const cardNotEqual = (a: Card) => (b: Card): boolean => {
  return !cardEqual(a)(b)
}

export const cardIsIn = (container: Card[]) => (card: Card): boolean => {
  return !!container
    .find(({ suit, rank }) => card.suit === suit && card.rank === rank)
}

export const cardIsNotIn = (container: Card[]) => (card: Card): boolean => {
  return !cardIsIn(container)(card)
}

export const cardIsOfSuit = (suit: Suit) => (card: Card): boolean => {
  return card.suit === suit
}

export const getRankAsNumber = (rank: Rank): number => {
  switch (rank) {
    case 'Seven': return 0
    case 'Eight': return 1
    case 'Nine': return 2
    case 'Ten': return 3
    case 'Jack': return 4
    case 'Queen': return 5
    case 'King': return 6
    case 'Ace': return 7
  }
}

export const getSuitAsNumber = (suit: Suit): number => {
  switch (suit) {
    case 'Clubs': return 0
    case 'Diamonds': return 1
    case 'Spades': return 2
    case 'Hearts': return 3
  }
}

export const compareByRank = (a: Card, b: Card): -1 | 0 | 1 => {
  const rankA = getRankAsNumber(a.rank)
  const rankB = getRankAsNumber(b.rank)
  if (rankA > rankB) return 1
  if (rankA < rankB) return -1
  return 0
}

export const compareBySuit = (a: Card, b: Card): -1 | 0 | 1 => {
  const suitA = getSuitAsNumber(a.suit)
  const suitB = getSuitAsNumber(b.suit)
  if (suitA > suitB) return 1
  if (suitA < suitB) return -1
  return 0
}

export const sortCardsByGreatestValue = (cards: Card[]): Card[] => {
  return cards
    .sort(compareBySuit)
    .sort(compareByRank)
    .reverse()
}

export const sortCardsByLowestValue = (cards: Card[]): Card[] => {
  return sortCardsByGreatestValue(cards).reverse()
}

export const getCardPoints = (heartsGrillCoeficient: number, blackCatGrilled: boolean) => (card: Card): number => {
  switch (card.suit) {
    case 'Hearts': {<commit_msg>Added todo<commit_after>import { Card, Deck, Grills, Hand, Pile, Rank, Suit, Table } from '../../types/Cards'

export const theBlackCatCard: Card = { suit: 'Spades', rank: 'Queen' }

export const cardEqual = (a: Card) => (b: Card): boolean => {
  return a.suit === b.suit && a.rank === b.rank
}

export const cardNotEqual = (a: Card) => (b: Card): boolean => {
  return !cardEqual(a)(b)
}

export const cardIsIn = (container: Card[]) => (card: Card): boolean => {
  return !!container
    .find(({ suit, rank }) => card.suit === suit && card.rank === rank)
}

export const cardIsNotIn = (container: Card[]) => (card: Card): boolean => {
  return !cardIsIn(container)(card)
}

export const cardIsOfSuit = (suit: Suit) => (card: Card): boolean => {
  return card.suit === suit
}

export const getRankAsNumber = (rank: Rank): number => {
  switch (rank) {
    case 'Seven': return 0
    case 'Eight': return 1
    case 'Nine': return 2
    case 'Ten': return 3
    case 'Jack': return 4
    case 'Queen': return 5
    case 'King': return 6
    case 'Ace': return 7
  }
}

export const getSuitAsNumber = (suit: Suit): number => {
  switch (suit) {
    case 'Clubs': return 0
    case 'Diamonds': return 1
    case 'Spades': return 2
    case 'Hearts': return 3
  }
}

export const compareByRank = (a: Card, b: Card): -1 | 0 | 1 => {
  const rankA = getRankAsNumber(a.rank)
  const rankB = getRankAsNumber(b.rank)
  if (rankA > rankB) return 1
  if (rankA < rankB) return -1
  return 0
}

export const compareBySuit = (a: Card, b: Card): -1 | 0 | 1 => {
  const suitA = getSuitAsNumber(a.suit)
  const suitB = getSuitAsNumber(b.suit)
  if (suitA > suitB) return 1
  if (suitA < suitB) return -1
  return 0
}

export const sortCardsByGreatestValue = (cards: Card[]): Card[] => {
  return cards
    .sort(compareBySuit)
    .sort(compareByRank)
    .reverse()
}
// TODO: Optimize this -> swap the functions -> better readability + performance
export const sortCardsByLowestValue = (cards: Card[]): Card[] => {
  return sortCardsByGreatestValue(cards).reverse()
}

export const getCardPoints = (heartsGrillCoeficient: number, blackCatGrilled: boolean) => (card: Card): number => {
  switch (card.suit) {
    case 'Hearts': {
{'fraction_non_alphanumeric': 0.156601607347876, 'fraction_numerical': 0.011021814006888633, 'mean_word_length': 3.546972860125261, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2858268', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1497, 'n_words': 476}