- Joined
- Mar 24, 2013
- Messages
- 1,105
I am sure this must be solved although I cannot seem to find anything useful through searching.
I am trying to check each players score at the end of the game to determine the winner. My first trigger here, I had it set it up where if two people ended with the same score both were declared the winner. I did not like that however and want to be able to detect a tie to allow me to force another round. However, I am stuck at the moment.
In the WIP I was trying to make it so if i3 exceeds 1 then it must mean that there was a tie because two scores equaled each other, that fails though because it could such that a = b but a < c and I wont catch that.
Any guidance would be awesome.
I am trying to check each players score at the end of the game to determine the winner. My first trigger here, I had it set it up where if two people ended with the same score both were declared the winner. I did not like that however and want to be able to detect a tie to allow me to force another round. However, I am stuck at the moment.
JASS:
function GameWinnerFFAPlayer takes nothing returns nothing
local player p = GetEnumPlayer()
local integer pId = GetPlayerId(p)
call Message(GetRealColoredName(p) + " won the game!")
call SetPlayerOnScoreScreen(p, true)
set p = null
endfunction
function GameWinnerFFA takes nothing returns nothing
local integer i = 0
local integer i2 = 0
local force f = WINNERS
local player p
loop
exitwhen i >= 12
set p = Player(i)
if roundWins[i2] == roundWins[i] and IsPlaying(p) then
call ForceAddPlayer(f, p)
elseif roundWins[i2] < roundWins[i] then
call ForceClear(f)
set i2 = i
call ForceAddPlayer(f, p)
endif
set i = i + 1
endloop
call ForForce(f, function GameWinnerFFAPlayer)
call ForceClear(f)
set p = null
set f = null
endfunction
JASS:
function GameWinnerFFA takes nothing returns boolean
local integer i = 0
local integer i2 = 0
local force f = WINNERS
local player p
local integer i3 = 0
loop
exitwhen i >= 12
set p = Player(i)
if roundWins[i2] == roundWins[i] and IsPlaying(p) then
call ForceAddPlayer(f, p)
set i3 = i3 + 1
if i3 > 1 then
set totalRounds = 2
call Message(colorNames[13] + "Tie Detected, playing another round!")
call ForceClear(f)
set f = null
set p = null
return false
endif
elseif roundWins[i2] < roundWins[i] then
set i3 = 0
call ForceClear(f)
set i2 = i
call ForceAddPlayer(f, p)
endif
set i = i + 1
endloop
call ForForce(f, function GameWinnerFFAPlayer)
call ForceClear(f)
set f = null
set p = null
return true
endfunction
In the WIP I was trying to make it so if i3 exceeds 1 then it must mean that there was a tie because two scores equaled each other, that fails though because it could such that a = b but a < c and I wont catch that.
Any guidance would be awesome.