Skip to content

Instantly share code, notes, and snippets.

@GregSutcliffe
Created September 17, 2014 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GregSutcliffe/627ea0de156b979b8581 to your computer and use it in GitHub Desktop.
Save GregSutcliffe/627ea0de156b979b8581 to your computer and use it in GitHub Desktop.
#!/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