Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

Commit

Permalink
Fixed Ranker Timer Values
Browse files Browse the repository at this point in the history
  • Loading branch information
shreystechtips committed Feb 8, 2019
1 parent 790ebc7 commit d1f02ee
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions NRGScoutingApp/Helper Classes/Ranker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,46 +45,46 @@ public String[] returnTeamTimes(string team)
String[] retValues = new String[ConstantVars.numRankTypes];
if (cargoData.ContainsKey(team))
{
retValues[1] = NewMatchStart.timeToString((int)cargoData[team] * (int)ConstantVars.TIME_NERF);
retValues[1] = timeAdaptiveString((int)cargoData[team]);
}
else
{
retValues[1] = ConstantVars.noVal;
}
if (hatchData.ContainsKey(team))
{
retValues[2] = NewMatchStart.timeToString((int)(hatchData[team] * ConstantVars.TIME_NERF));
retValues[2] = timeAdaptiveString((int)hatchData[team]);
}
else {
retValues[2] = ConstantVars.noVal;
}
if (climbData.ContainsKey(team))
{
retValues[3] = ((int)climbData[team]*ConstantVars.TIME_NERF).ToString();
retValues[3] = climbData[team].ToString();
}
else
{
retValues[3] = ConstantVars.noVal;
}
if (drop1Data.ContainsKey(team))
{
retValues[4] = NewMatchStart.timeToString((int)drop1Data[team] * (int)ConstantVars.TIME_NERF);
retValues[4] = timeAdaptiveString((int)drop1Data[team]); //timeAdaptiveString
}
else
{
retValues[4] = ConstantVars.noVal;
}
if (drop2Data.ContainsKey(team))
{
retValues[5] = NewMatchStart.timeToString((int)drop2Data[team] * (int)ConstantVars.TIME_NERF);
retValues[5] = timeAdaptiveString((int)drop2Data[team]);
}
else
{
retValues[5] = ConstantVars.noVal;
}
if (drop3Data.ContainsKey(team))
{
retValues[6] = NewMatchStart.timeToString((int)drop3Data[team] * (int)ConstantVars.TIME_NERF);
retValues[6] = timeAdaptiveString((int)drop3Data[team]);
}
else
{
Expand All @@ -94,6 +94,25 @@ public String[] returnTeamTimes(string team)
return retValues;
}


public static string timeAdaptiveString(int timeValue)
{
int minutes = 0;
int seconds = 0;
int milliseconds = 0;
minutes = timeValue / (int)ConstantVars.MIN_MS;
timeValue %= (int)ConstantVars.MIN_MS;
seconds = timeValue / (int)ConstantVars.SEC_MS;
timeValue %= (int)ConstantVars.SEC_MS;
milliseconds = timeValue;
if(minutes == 0) {
return seconds.ToString("D2") + "." + (milliseconds / 10).ToString("D2");
}
else {
return minutes + ":" + seconds.ToString("D2") + "." + (milliseconds / 10).ToString("D2");
}
}

/*
* Switchboard operator for getting match Ranks
* PRE: Rank type is provided
Expand All @@ -102,7 +121,7 @@ public String[] returnTeamTimes(string team)
*/
public Dictionary<String, double> getRank(MatchFormat.CHOOSE_RANK_TYPE x)
{
Console.WriteLine(x);
refresh();
switch (x)
{
case MatchFormat.CHOOSE_RANK_TYPE.pick1:
Expand Down Expand Up @@ -130,7 +149,7 @@ public Dictionary<string, string> returnDataAsTime(Dictionary<string, double> in
Dictionary<string, string> result = new Dictionary<string, string>();
foreach (var x in input)
{
result.Add(x.Key, NewMatchStart.timeToString((int)x.Value * (int)ConstantVars.TIME_NERF));
result.Add(x.Key, timeAdaptiveString((int)x.Value * (int)ConstantVars.TIME_NERF));
}
return result;
}
Expand Down

0 comments on commit d1f02ee

Please sign in to comment.