mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-06 22:44:14 +00:00
Fixed win percentage
This commit is contained in:
@@ -30,12 +30,17 @@ class Wrestler < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def seasonWinPercentage
|
def seasonWinPercentage
|
||||||
if self.season_win > 0 and self.season_loss > 0
|
@win = self.season_win.to_f
|
||||||
@percentage = self.season_win / (self.season_win + self.season_loss)
|
@loss = self.season_loss.to_f
|
||||||
return @percentage
|
if @win > 0 and @loss != nil
|
||||||
|
@matchTotal = @win + @loss
|
||||||
|
@percentageDec = @win / @matchTotal
|
||||||
|
@percentage = @percentageDec * 100
|
||||||
|
return @percentage.to_i
|
||||||
elsif self.season_win == 0
|
elsif self.season_win == 0
|
||||||
return 0
|
return 0
|
||||||
|
elsif self.season_win == nil or self.season_loss == nil
|
||||||
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user