1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Switched back to original way I swapped wrestlers

This commit is contained in:
2016-01-25 12:59:38 +00:00
parent 75efa73777
commit 01b9476ba7

View File

@@ -140,24 +140,47 @@ class Tournament < ActiveRecord::Base
w1 = Wrestler.find(wrestler1_id)
w2 = Wrestler.find(wrestler2_id)
w1Matches = w1.allMatches
w1Seed = w1.seed
w2Matches = w2.allMatches
w2Seed = w2.seed
w1Matches.each do |m|
m.swapWrestlers(wrestler1_id,wrestler2_id)
#placeholder guy
w3 = Wrestler.new
w3.name = w1.name
w3.school_id = w1.school_id
w3.weight_id = w1.weight_id
w3.season_win = w1.season_win
w3.season_loss = w1.season_loss
w3.criteria = w1.criteria
w3.original_seed = w1.original_seed
w3.seed = w1.seed
#Swap wrestler 1 and wrestler 2
w1.name = w2.name
w1.school_id = w2.school_id
w1.weight_id = w2.weight_id
w1.season_win = w2.season_win
w1.season_loss = w2.season_loss
w1.criteria = w2.criteria
w1.original_seed = w2.original_seed
w1.seed = w2.seed
w2.name = w3.name
w2.school_id = w3.school_id
w2.weight_id = w3.weight_id
w2.season_win = w3.season_win
w2.season_loss = w3.season_loss
w2.criteria = w3.criteria
w2.original_seed = w3.original_seed
w2.seed = w3.seed
w1.save
w2.save
end
def swapWrestlerMatches(matchesToSwap,w1_id,w2_id)
matchesToSwap.each do |m|
m.swapWrestlers(w1_id,w2_id)
end
w2Matches.each do |m|
m.swapWrestlers(wrestler2_id,wrestler1_id)
end
w1.seed = w2Seed
w1.save
w2.seed = w1Seed
w2.save
end
end