Fix: winner calc in tic-tac-toe mode (closes #349)
This commit is contained in:
1 parent
f9e71693ea
commit
675edce193
1 file changed
+24
-3
@@ -20,6 +20,7 @@ using System.Collections.Generic;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using VocaluxeLib.Game;
|
||||||
using VocaluxeLib.Menu;
|
using VocaluxeLib.Menu;
|
||||||
using VocaluxeLib.Songs;
|
using VocaluxeLib.Songs;
|
||||||
|
|
||||||
@@ -530,13 +531,33 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
|||||||
if (!GameData.Rounds[GameData.FieldNr].Finished)
|
if (!GameData.Rounds[GameData.FieldNr].Finished)
|
||||||
GameData.CurrentRoundNr++;
|
GameData.CurrentRoundNr++;
|
||||||
|
|
||||||
|
CPoints points = CBase.Game.GetPoints();
|
||||||
SPlayer[] results = CBase.Game.GetPlayers();
|
SPlayer[] results = CBase.Game.GetPlayers();
|
||||||
if (results == null)
|
|
||||||
|
if (results == null || results.Length < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (results.Length < 2)
|
//Sum up all points
|
||||||
return;
|
for (int r = 0; r < points.NumRounds; r++)
|
||||||
|
{
|
||||||
|
SPlayer[] player = points.GetPlayer(r, 2);
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
results[i].Points += player[i].Points;
|
||||||
|
results[i].PointsGoldenNotes += player[i].PointsGoldenNotes;
|
||||||
|
results[i].PointsLineBonus += player[i].PointsLineBonus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Calc average of points
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
results[i].Points /= points.NumRounds;
|
||||||
|
results[i].PointsGoldenNotes /= points.NumRounds;
|
||||||
|
results[i].PointsLineBonus /= points.NumRounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Decide who has won
|
||||||
GameData.Rounds[GameData.FieldNr].PointsTeam1 = (int)Math.Round(results[0].Points);
|
GameData.Rounds[GameData.FieldNr].PointsTeam1 = (int)Math.Round(results[0].Points);
|
||||||
GameData.Rounds[GameData.FieldNr].PointsTeam2 = (int)Math.Round(results[1].Points);
|
GameData.Rounds[GameData.FieldNr].PointsTeam2 = (int)Math.Round(results[1].Points);
|
||||||
GameData.Rounds[GameData.FieldNr].Finished = true;
|
GameData.Rounds[GameData.FieldNr].Finished = true;
|
||||||
|
|||||||
Reference in new issue
Block a user