Created
October 21, 2017 21:39
-
-
Save brandoncordell/b2b2e4e0ef382a678cfee4ca71dbe873 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#array to check for an actual item location | |
arr = ["a1","b1","c1","a2", "b2", "c2", "a3", "b3", "c3"] | |
var = '' | |
# blank has for locations | |
locations = { | |
a1: {}, | |
a2: {}, | |
a3: {}, | |
b1: {}, | |
b2: {}, | |
b3: {}, | |
c1: {}, | |
c2: {}, | |
c3: {} | |
} | |
#list of items that the locations will take the stats of. | |
itm = { | |
red: { | |
top: 'red', | |
bot: 'red', | |
right: 'red' | |
}, | |
blue: { | |
top: 'blue', | |
left: 'blue', | |
right: 'blue', | |
standalone: { | |
evasion: 2, | |
speed: 3, | |
'red' => 2 | |
} | |
}, | |
clear: {} | |
} | |
$affinity = [] | |
#two arrays for the first and second node and direction for checking for | |
#affinity connections, then converts them into two arrays for the check | |
src = [['a1','right'],['a2','right'],['b1','right'],['b2','right'],['c1','right'],['c2','right'],['a1','bot'],['b1','bot'],['a2','bot'],['b2','bot'],['a3','bot'],['b3','bot']] | |
chk = [["a2","left"],['a3','left'],['b2','left'],['b3','left'],['c2','left'],['c3','left'],['b1','top'],['c1','top'],['b2','top'],['c2','top'],['b3','top'],['c3','top']] | |
srcsy = [] | |
src.each {|i| i.each {|x|srcsy.push(x.to_sym)}} | |
chksy = [] | |
chk.each {|i| i.each {|x|chksy.push(x.to_sym)}} | |
local = [] | |
locations.each {|x,y| local.push(x) } | |
def affin(left = nil,right = nil) | |
if left == right | |
$affinity.push(left) | |
end | |
end | |
#until user inputs quit as their item choice, will ask where to put item, then | |
#what item to put there. | |
until var == 'quit' | |
puts "what location do you want to set a card. If you want to stop, type 'quit'!" | |
var = gets.chomp | |
if arr.include?(var) | |
puts 'Yay' | |
puts "what item from the following list do you want?" | |
itm.each {|key, value| puts key } | |
vari = gets.chomp | |
#makes individual locations take on the Items that were | |
#selected and outputs the list of Locations for review | |
locations[var.to_sym] = itm[vari.to_sym] | |
locations.each {|x| puts x} | |
l = locations | |
$affinity = [] | |
i = 0 | |
#runs through the arrays to check the various connections | |
while i < srcsy.length | |
affin(l[srcsy[i]][srcsy[i+1]],l[chksy[i]][chksy[i+1]]) | |
i += 2 | |
end | |
#resets the totals for stats and affinities | |
counts = Hash.new(0) | |
#clears out any nil values for $affinity to keep it clean | |
$affinity.delete(nil) | |
#searches for standalone values and adds them to the counts | |
#hash for output | |
local.each do |x| | |
if l[x].include?(:standalone) | |
l[x][:standalone].each { |key, val| counts[key] += val } | |
end | |
end | |
#takes each affinity stored in array and adds 1 to the values | |
#or creates a new value if it is the first instance of it. | |
$affinity.each { |aff| counts[aff] += 1 } | |
#outputs the results | |
counts.each {|key, value| puts "#{key.upcase} affinity value is: #{value}"} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment