<commit_before>module TheWizardsCastle
class Runner

  module PlayerState
    NEW_ROOM = :new_room
    ACTION = :action
    DIED = :died
    QUIT = :quit
    EXITED = :exited
  end

  def self.run
    n=0
    loop do
      runner = Runner.new
      runner.setup
      runner.intro if n==0
      runner.character_creation
      break unless runner.play
      n+=1
    end
  end


  attr_accessor :prompter, :castle, :player, :printer


  def initialize
    @prompter = nil
    @castle = nil
    @player = nil
    @printer = nil
  end

  def intro
    @printer.intro
  end

  def setup(h={})
    @prompter = h[:prompter] || Prompter.new
    @castle = h[:castle] || Castle.new
    @player = h[:player] || Player.new
    @printer = h[:printer] || StetsonPrinter.new(@player,@castle)
  end

  def character_creation
    @printer.character_creation_header
    ask_race
    ask_gender
    ask_attributes
    @printer.gold_report1
    ask_armor
    @printer.gold_report2
    ask_weapon
    ask_lamp
    if @player.gp > 0
      @printer.gold_report3
      ask_flares
    end
  end

  def play
    # returns true if user wants to play again

    @player.set_location(1,4,1) #entrance
    @printer.entering_the_castle

    # TODO probably can deduce NEW_ROOM vs ACTION
    #      instead of explicitly returning from within each action

    status = PlayerState::NEW_ROOM
    loop do
      case status
      when PlayerState::NEW_ROOM
        status = enter_room
      when PlayerState::ACTION
        status = player_action
      end

      break if [PlayerState::QUIT, PlayerState::EXITED, PlayerState::DIED].include? status
    end

    case status
    when PlayerState::DIED
      @printer.death
    when PlayerState::QUIT<commit_msg>remove TODO that's not important<commit_after>module TheWizardsCastle
class Runner

  module PlayerState
    NEW_ROOM = :new_room
    ACTION = :action
    DIED = :died
    QUIT = :quit
    EXITED = :exited
  end

  def self.run
    n=0
    loop do
      runner = Runner.new
      runner.setup
      runner.intro if n==0
      runner.character_creation
      break unless runner.play
      n+=1
    end
  end


  attr_accessor :prompter, :castle, :player, :printer


  def initialize
    @prompter = nil
    @castle = nil
    @player = nil
    @printer = nil
  end

  def intro
    @printer.intro
  end

  def setup(h={})
    @prompter = h[:prompter] || Prompter.new
    @castle = h[:castle] || Castle.new
    @player = h[:player] || Player.new
    @printer = h[:printer] || StetsonPrinter.new(@player,@castle)
  end

  def character_creation
    @printer.character_creation_header
    ask_race
    ask_gender
    ask_attributes
    @printer.gold_report1
    ask_armor
    @printer.gold_report2
    ask_weapon
    ask_lamp
    if @player.gp > 0
      @printer.gold_report3
      ask_flares
    end
  end

  def play
    # returns true if user wants to play again

    @player.set_location(1,4,1) #entrance
    @printer.entering_the_castle

    status = PlayerState::NEW_ROOM
    loop do
      case status
      when PlayerState::NEW_ROOM
        status = enter_room
      when PlayerState::ACTION
        status = player_action
      end

      break if [PlayerState::QUIT, PlayerState::EXITED, PlayerState::DIED].include? status
    end

    case status
    when PlayerState::DIED
      @printer.death
    when PlayerState::QUIT
{'fraction_non_alphanumeric': 0.07958271236959762, 'fraction_numerical': 0.005961251862891207, 'mean_word_length': 2.495833333333333, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4206254', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1092, 'n_words': 278}