<commit_before># RouletteBet
#
# AUTHOR::  <NAME>

class RouletteBet
  attr_accessor :wager

  def self.create(bet_str)
    bet = bets.find { |b| b.matches?(bet_str) } || InvalidBet
    bet.new(bet_str)
  end

  def self.bets
    @bets ||= []
  end

  def self.inherited(subclass)
    bets << subclass
  end

  def self.paytable_str
    format("%s = x%.3g", description, payout)
  end

  def initialize(bet_str)
    @bet = bet_str.downcase
  end

  def description
    self.class.description
  end

  def payout
    self.class.payout
  end

  def valid?
    true
  end

  def with_wager(wager)
    @wager = wager
    self
  end

  def winnings
    (@wager * payout).to_i
  end

  def to_s
    return "$#{@wager} on #{@bet.capitalize}" unless wager.nil?

    @bet.capitalize
  end

  # Redis serialization

  def to_str
    "#{@bet}|#{@wager}"
  end

  def self.from_str(bet_str)
    bet_str, wager = *bet_str.split('|')
    RouletteBet.create(bet_str).with_wager(wager.to_i)
  end
end

class SingleBet < RouletteBet
  def self.matches?(bet_str)
    %w(0 00).include?(bet_str) || (1..36).include?(bet_str.to_i)
  end

  def self.description
    'Any single number, 0-36 or 00: Wins if the ball lands on the given number.'
  end

  def self.payout
    38
  end

  def win?(pocket)
    pocket.number == @bet
  end
end

class BasketBet < RouletteBet
  def self.matches?(bet_str)
    bet_str.casecmp('basket').zero?
  end

  def self.description<commit_msg>Correcting Single bet payouts; the 0 pockets aren't counted because reasons<commit_after># RouletteBet
#
# AUTHOR::  <NAME>

class RouletteBet
  attr_accessor :wager

  def self.create(bet_str)
    bet = bets.find { |b| b.matches?(bet_str) } || InvalidBet
    bet.new(bet_str)
  end

  def self.bets
    @bets ||= []
  end

  def self.inherited(subclass)
    bets << subclass
  end

  def self.paytable_str
    format("%s = x%.3g", description, payout)
  end

  def initialize(bet_str)
    @bet = bet_str.downcase
  end

  def description
    self.class.description
  end

  def payout
    self.class.payout
  end

  def valid?
    true
  end

  def with_wager(wager)
    @wager = wager
    self
  end

  def winnings
    (@wager * payout).to_i
  end

  def to_s
    return "$#{@wager} on #{@bet.capitalize}" unless wager.nil?

    @bet.capitalize
  end

  # Redis serialization

  def to_str
    "#{@bet}|#{@wager}"
  end

  def self.from_str(bet_str)
    bet_str, wager = *bet_str.split('|')
    RouletteBet.create(bet_str).with_wager(wager.to_i)
  end
end

class SingleBet < RouletteBet
  def self.matches?(bet_str)
    %w(0 00).include?(bet_str) || (1..36).include?(bet_str.to_i)
  end

  def self.description
    'Any single number, 0-36 or 00: Wins if the ball lands on the given number.'
  end

  def self.payout
    36
  end

  def win?(pocket)
    pocket.number == @bet
  end
end

class BasketBet < RouletteBet
  def self.matches?(bet_str)
    bet_str.casecmp('basket').zero?
  end

  def self.description
{'fraction_non_alphanumeric': 0.11463250168577209, 'fraction_numerical': 0.009777478084962913, 'mean_word_length': 2.8988173455978976, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, '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': '4207533', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1130, 'n_words': 271}