Created
September 17, 2014 21:57
-
-
Save GregSutcliffe/627ea0de156b979b8581 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'pp' | |
require 'csv' | |
league = ARGV[1] || "Beyond" | |
name = ARGV[2] || "Dracharoth" | |
puts "BB begins here" | |
puts "--------------" | |
puts "IGN is #{name}, PM me in game if you want to make a purchase" | |
# This creates an array of arrays - but we only need the first field | |
data = CSV.read(ARGV[0]).map! {|line| line.first} | |
# Only use buyout tabs - temporary workaround until Looty does specific tab export | |
data = data.reject! {|line| line !~ /^\$/}.compact | |
# Use "$" to mark tabs for inclusion | |
# Parse for buyouts and tab index, line is a string like "$2 chaos s:0 x:1 y:2" | |
prices = {} | |
items = [] | |
data.each do |line| | |
buyout = line.match(/^\$(.*)\s\bs:/)[1] | |
tab = line.match(/\bs:(\d*)\b/)[1] | |
x = line.match(/\bx:(\d*)\b/)[1] | |
y = line.match(/\by:(\d*)\b/)[1] | |
prices[buyout] = [] if prices[buyout].nil? | |
# Looty indexs coords from 1, PoE indexes from 0 | |
prices[buyout] << { :x => x.to_i - 1, :y => y.to_i - 1, :tab => tab.to_i + 1} # Still have the N+1 issue | |
end | |
# Now loop to produce the bbcode | |
prices.each do |price,items| | |
puts "" | |
puts "[spoiler=\"~b/o #{price}\"]" | |
items.each do |item| | |
location = "Stash#{item[:tab]}" | |
coord = "x=\"#{item[:x]}\" y=\"#{item[:y]}\"" | |
print "[linkItem location=\"#{location}\" league=\"#{league}\" #{coord}]" | |
end | |
puts "" | |
puts "[/spoiler]" | |
end | |
puts "" | |
puts "--" | |
puts "Post generated via [url=http://www.pathofexile.com/forum/view-thread/832233]Looty![/url]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment