xiv_stats.rb
# Main function. Creates the database, cycles through character profiles and 
# records the information
Main function. Creates the database, cycles through character profiles and
records the information
Main function . Creates the database cycles through character profiles and records the information
def main
    @db = SQLite3::Database.new(@db_path)
    @db.busy_timeout=10000
    @db.execute("CREATE TABLE IF NOT EXISTS 'players' (id INTEGER PRIMARY KEY,name TEXT,realm TEXT,race TEXT,gender TEXT,grand_company TEXT
      ,level_gladiator INTEGER,level_pugilist INTEGER,level_marauder INTEGER,level_lancer INTEGER,level_archer INTEGER
      ,level_rogue INTEGER,level_conjurer INTEGER,level_thaumaturge INTEGER,level_arcanist INTEGER,level_darkknight INTEGER, level_machinist INTEGER
      ,level_astrologian INTEGER,level_carpenter INTEGER,level_blacksmith INTEGER,level_armorer INTEGER,level_goldsmith INTEGER
      ,level_leatherworker INTEGER,level_weaver INTEGER,level_alchemist INTEGER,level_culinarian INTEGER,level_miner INTEGER
      ,level_botanist INTEGER,level_fisher INTEGER,p30days INTEGER, p60days INTEGER, p90days INTEGER, p180days INTEGER, p270days INTEGER
      ,p360days INTEGER,p450days INTEGER,p630days INTEGER,arr_25_complete INTEGER, dideternalbond INTEGER);")    
    for i in @lowest_id..@highest_id
      if page = get_player_page(i)
        player = Player.new
        player.id = i
        player.player_name = get_name(page)
        player.realm = get_realm(page)
        player.race = get_race(page)
        player.gender = get_gender(page)
        player.grand_company = get_grand_company(page) 
        player.p30days = get_minion(page, "Wind-up Cursor")
        player.p60days = get_minion(page, "Black Chocobo Chick")
        player.p90days = get_minion(page, "Beady Eye")
        player.p180days = get_minion(page, "Minion Of Light")
        player.p270days = get_minion(page, "Wind-up Leader")
        player.p360days = get_minion(page, "Wind-up Odin")
        player.p450days = get_minion(page, "Wind-up Goblin")
        player.p630days = get_minion(page, "Wind-up Nanamo")
        player.arr_25_complete = get_minion(page, "Midgardsormr")
        player.dideternalbond = get_mount(page, "Ceremony Chocobo")
        levels = get_levels(page)
        player.level_gladiator = levels[0]
        player.level_pugilist = levels[1]
        player.level_marauder = levels[2]
        player.level_lancer = levels[3]
        player.level_archer = levels[4]
        player.level_rogue = levels[5]
        player.level_conjurer = levels[6]
        player.level_thaumaturge = levels[7]
        player.level_arcanist = levels[8]
        player.level_darkknight = levels[9]
        player.level_machinist = levels[10]
        player.level_astrologian = levels[11]
        player.level_carpenter = levels[12]
        player.level_blacksmith = levels[13]
        player.level_armorer = levels[14]
        player.level_goldsmith = levels[15]
        player.level_leatherworker = levels[16]
        player.level_weaver = levels[17]
        player.level_alchemist = levels[18]
        player.level_culinarian = levels[19]
        player.level_miner = levels[20]
        player.level_botanist = levels[21]
        player.level_fisher = levels[22]
	write_to_db(player)
      end
    end
  end
def main @db = SQLite3 :: Database . new ( @db_path ) @db . busy_timeout = 10000 @db . execute ( "CREATE TABLE IF NOT EXISTS 'players' (id INTEGER PRIMARY KEY,name TEXT,realm TEXT,race TEXT,gender TEXT,grand_company TEXT
      ,level_gladiator INTEGER,level_pugilist INTEGER,level_marauder INTEGER,level_lancer INTEGER,level_archer INTEGER
      ,level_rogue INTEGER,level_conjurer INTEGER,level_thaumaturge INTEGER,level_arcanist INTEGER,level_darkknight INTEGER, level_machinist INTEGER
      ,level_astrologian INTEGER,level_carpenter INTEGER,level_blacksmith INTEGER,level_armorer INTEGER,level_goldsmith INTEGER
      ,level_leatherworker INTEGER,level_weaver INTEGER,level_alchemist INTEGER,level_culinarian INTEGER,level_miner INTEGER
      ,level_botanist INTEGER,level_fisher INTEGER,p30days INTEGER, p60days INTEGER, p90days INTEGER, p180days INTEGER, p270days INTEGER
      ,p360days INTEGER,p450days INTEGER,p630days INTEGER,arr_25_complete INTEGER, dideternalbond INTEGER);" ) for i in @lowest_id .. @highest_id if page = get_player_page ( i ) player = Player . new player . id = i player . player_name = get_name ( page ) player . realm = get_realm ( page ) player . race = get_race ( page ) player . gender = get_gender ( page ) player . grand_company = get_grand_company ( page ) player . p30days = get_minion ( page , "Wind-up Cursor" ) player . p60days = get_minion ( page , "Black Chocobo Chick" ) player . p90days = get_minion ( page , "Beady Eye" ) player . p180days = get_minion ( page , "Minion Of Light" ) player . p270days = get_minion ( page , "Wind-up Leader" ) player . p360days = get_minion ( page , "Wind-up Odin" ) player . p450days = get_minion ( page , "Wind-up Goblin" ) player . p630days = get_minion ( page , "Wind-up Nanamo" ) player . arr_25_complete = get_minion ( page , "Midgardsormr" ) player . dideternalbond = get_mount ( page , "Ceremony Chocobo" ) levels = get_levels ( page ) player . level_gladiator = levels [ 0 ] player . level_pugilist = levels [ 1 ] player . level_marauder = levels [ 2 ] player . level_lancer = levels [ 3 ] player . level_archer = levels [ 4 ] player . level_rogue = levels [ 5 ] player . level_conjurer = levels [ 6 ] player . level_thaumaturge = levels [ 7 ] player . level_arcanist = levels [ 8 ] player . level_darkknight = levels [ 9 ] player . level_machinist = levels [ 10 ] player . level_astrologian = levels [ 11 ] player . level_carpenter = levels [ 12 ] player . level_blacksmith = levels [ 13 ] player . level_armorer = levels [ 14 ] player . level_goldsmith = levels [ 15 ] player . level_leatherworker = levels [ 16 ] player . level_weaver = levels [ 17 ] player . level_alchemist = levels [ 18 ] player . level_culinarian = levels [ 19 ] player . level_miner = levels [ 20 ] player . level_botanist = levels [ 21 ] player . level_fisher = levels [ 22 ] write_to_db ( player ) end end end
Main function.
Main function .
# Allows the program to wait up to 10 seconds for writing # So that the database can be read while this program is executing # Do the player IDs in the range specified at the command-line # taking sub data because, with two data sets, sufficiently far apart, we may be able to determine active subscriptions, with some margin of error #        puts "ID: #{i} | Name: #{player.player_name} | Realm: #{player.realm} | Race: #{player.race} | Gender: #{player.gender} | GC: #{player.grand_company}" #  puts "ID: #{i} | Name: #{player.player_name} | Realm: #{player.realm} | Race: #{player.race} | Gender: #{player.gender} | 30Days: #{player.p30days}" # DEBUG # page.each { |x| puts x }