Sha256: 2c99b7f972bf97b4dc58cf16e87b04fc4000eb6127ec11821546542f4d23f97f

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

require 'selenium-webdriver'
require 'chronic'

Dir.glob(File.join(File.dirname(__FILE__), '/application/*.rb')).sort.each { |lib| load lib }


class TravianBot
  class Application
    class << self
      include Connection
      include Queue
      include Display
      include Buildings
      
      # Is executed by the travinbot shell script.      
      def run!(*arguments)
        h1('Welcome to your TravianBot')
        @game = login
        
        current_building_queue
        current_troop_movements
        current_avaible_buildings
        
        @game.quit
      
        return 1
      end
      
      private
      def current_avaible_buildings
        h2 'Avaible buildings'
        buildings = avaible_buildings(@game)
        
        buildings.each do |building|
          puts building.to_s
        end  
        new_line
      end
       
      def current_building_queue
        h2('Current building queue')
        buildings = building_queue(@game)
        
        if buildings.empty?
          text 'nothing building'
        else
          buildings.each do |building|
            puts building.to_s
          end
          new_line
        end
      end
      
      def current_troop_movements
        h2('Current troop movement')
        troops = troop_movement(@game)
        
        if troops.empty?
          text 'No troops movement'
        else
          troops.each do |troop|
            puts troop.to_s
          end
          new_line
        end
      end
      
      # Get the ending time of a string
      def wait_till(input)
        time = input.to_s.match(/(\d*):(\d*)$/)

        Chronic.parse("today #{time[0]}:#{time[1]}")      
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
travian_bot-0.2.0 lib/travian_bot/application.rb