Fix: Winner in challenge mode wasn't calculated properly
This commit is contained in:
1 parent
e99f1adfae
commit
f9e71693ea
2 files changed
+77
-48
No files matched your search
@@ -18,6 +18,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using VocaluxeLib.Game;
|
||||||
using VocaluxeLib.Menu;
|
using VocaluxeLib.Menu;
|
||||||
|
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
@@ -430,39 +431,62 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
|
|
||||||
private void _UpdateScores()
|
private void _UpdateScores()
|
||||||
{
|
{
|
||||||
|
//Prepare results table
|
||||||
if (GameData.ResultTable.Count == 0)
|
if (GameData.ResultTable.Count == 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < GameData.NumPlayer; i++)
|
for (int i = 0; i < GameData.NumPlayer; i++)
|
||||||
{
|
{
|
||||||
var row = new CResultTableRow {PlayerID = GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0};
|
var row = new CResultTableRow { PlayerID = GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0 };
|
||||||
GameData.ResultTable.Add(row);
|
GameData.ResultTable.Add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameData.Results = new int[GameData.NumRounds,GameData.NumPlayerAtOnce];
|
GameData.Results = new int[GameData.NumRounds, GameData.NumPlayerAtOnce];
|
||||||
for (int i = 0; i < GameData.NumRounds; i++)
|
for (int i = 0; i < GameData.NumRounds; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
||||||
GameData.Results[i, j] = 0;
|
GameData.Results[i, j] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SPlayer[] results = CBase.Game.GetPlayers();
|
|
||||||
if (results == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (results.Length < GameData.NumPlayerAtOnce)
|
//Get points from game
|
||||||
return;
|
CPoints points = CBase.Game.GetPoints();
|
||||||
|
SPlayer[] players = CBase.Game.GetPlayers();
|
||||||
|
|
||||||
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
//Go over all rounds and sum up points
|
||||||
GameData.Results[GameData.CurrentRoundNr - 2, j] = (int)Math.Round(results[j].Points);
|
for (int round = 0; round < points.NumRounds; round++)
|
||||||
|
{
|
||||||
|
SPlayer[] res = points.GetPlayer(round, GameData.NumPlayerAtOnce);
|
||||||
|
|
||||||
List<SStats> points = _GetPointsForPlayer(results);
|
if (res == null || res.Length < GameData.NumPlayerAtOnce)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int p = 0; p < GameData.NumPlayerAtOnce; p++)
|
||||||
|
{
|
||||||
|
players[p].Points += res[p].Points;
|
||||||
|
players[p].PointsGoldenNotes += res[p].PointsGoldenNotes;
|
||||||
|
players[p].PointsLineBonus += res[p].PointsLineBonus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Calculate average points
|
||||||
|
for (int p = 0; p < GameData.NumPlayerAtOnce; p++)
|
||||||
|
{
|
||||||
|
players[p].Points /= points.NumRounds;
|
||||||
|
players[p].PointsGoldenNotes /= points.NumRounds;
|
||||||
|
players[p].PointsLineBonus /= points.NumRounds;
|
||||||
|
|
||||||
|
//Save points in GameData
|
||||||
|
GameData.Results[GameData.CurrentRoundNr - 2, p] = (int)Math.Round(players[p].Points);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<SStats> stats = _GetPointsForPlayer(players);
|
||||||
|
|
||||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||||
{
|
{
|
||||||
|
//Find matching row in results table
|
||||||
int index = -1;
|
int index = -1;
|
||||||
for (int j = 0; j < GameData.ResultTable.Count; j++)
|
for (int j = 0; j < GameData.ResultTable.Count; j++)
|
||||||
{
|
{
|
||||||
if (points[i].ProfileID == GameData.ResultTable[j].PlayerID)
|
if (stats[i].ProfileID == GameData.ResultTable[j].PlayerID)
|
||||||
{
|
{
|
||||||
index = j;
|
index = j;
|
||||||
break;
|
break;
|
||||||
@@ -473,15 +497,15 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
continue;
|
continue;
|
||||||
CResultTableRow row = GameData.ResultTable[index];
|
CResultTableRow row = GameData.ResultTable[index];
|
||||||
|
|
||||||
|
//Update results entry
|
||||||
row.NumPlayed++;
|
row.NumPlayed++;
|
||||||
row.NumWon += points[i].Won;
|
row.NumWon += stats[i].Won;
|
||||||
row.NumSingPoints += points[i].SingPoints;
|
row.NumSingPoints += stats[i].SingPoints;
|
||||||
row.NumGamePoints += points[i].GamePoints;
|
row.NumGamePoints += stats[i].GamePoints;
|
||||||
|
|
||||||
GameData.ResultTable[index] = row;
|
GameData.ResultTable[index] = row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GameData.ResultTable.Sort();
|
GameData.ResultTable.Sort();
|
||||||
|
|
||||||
//Update position-number
|
//Update position-number
|
||||||
|
|||||||
@@ -411,15 +411,16 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
|||||||
|
|
||||||
private void _UpdateScores()
|
private void _UpdateScores()
|
||||||
{
|
{
|
||||||
|
//Prepare results table
|
||||||
if (GameData.ResultTable.Count == 0)
|
if (GameData.ResultTable.Count == 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < GameData.NumPlayer; i++)
|
for (int i = 0; i < GameData.NumPlayer; i++)
|
||||||
{
|
{
|
||||||
CResultTableRow row = new CResultTableRow {PlayerID = GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0};
|
var row = new CResultTableRow { PlayerID = GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0 };
|
||||||
GameData.ResultTable.Add(row);
|
GameData.ResultTable.Add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameData.Results = new int[GameData.NumRounds,GameData.NumPlayerAtOnce];
|
GameData.Results = new int[GameData.NumRounds, GameData.NumPlayerAtOnce];
|
||||||
for (int i = 0; i < GameData.NumRounds; i++)
|
for (int i = 0; i < GameData.NumRounds; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
||||||
@@ -427,58 +428,62 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CPoints gamePoints = CBase.Game.GetPoints();
|
//Get points from game
|
||||||
if (gamePoints == null || gamePoints.NumPlayer < GameData.NumPlayerAtOnce)
|
CPoints points = CBase.Game.GetPoints();
|
||||||
return;
|
SPlayer[] players = CBase.Game.GetPlayers();
|
||||||
|
|
||||||
SPlayer[] results = gamePoints.GetPlayer(0, GameData.NumPlayerAtOnce);
|
//Go over all rounds and sum up points
|
||||||
if (results == null)
|
for (int round = 0; round < points.NumRounds; round++)
|
||||||
return;
|
|
||||||
|
|
||||||
if (results.Length < GameData.NumPlayerAtOnce)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (gamePoints.NumRounds == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (int i = 1; i < gamePoints.NumRounds; i++)
|
|
||||||
{
|
{
|
||||||
SPlayer[] temp = gamePoints.GetPlayer(i, GameData.NumPlayerAtOnce);
|
SPlayer[] res = points.GetPlayer(round, GameData.NumPlayerAtOnce);
|
||||||
|
|
||||||
|
if (res == null || res.Length < GameData.NumPlayerAtOnce)
|
||||||
|
return;
|
||||||
|
|
||||||
for (int p = 0; p < GameData.NumPlayerAtOnce; p++)
|
for (int p = 0; p < GameData.NumPlayerAtOnce; p++)
|
||||||
results[p].Points += temp[p].Points;
|
{
|
||||||
|
players[p].Points += res[p].Points;
|
||||||
|
players[p].PointsGoldenNotes += res[p].PointsGoldenNotes;
|
||||||
|
players[p].PointsLineBonus += res[p].PointsLineBonus;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//Calculate average points
|
||||||
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
for (int p = 0; p < GameData.NumPlayerAtOnce; p++)
|
||||||
{
|
{
|
||||||
results[j].Points = results[j].Points / gamePoints.NumRounds;
|
players[p].Points /= points.NumRounds;
|
||||||
GameData.Results[GameData.CurrentRoundNr - 2, j] = (int)Math.Round(results[j].Points);
|
players[p].PointsGoldenNotes /= points.NumRounds;
|
||||||
|
players[p].PointsLineBonus /= points.NumRounds;
|
||||||
|
|
||||||
|
//Save points in GameData
|
||||||
|
GameData.Results[GameData.CurrentRoundNr - 2, p] = (int)Math.Round(players[p].Points);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SStats> points = _GetPointsForPlayer(results);
|
List<SStats> stats = _GetPointsForPlayer(players);
|
||||||
|
|
||||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||||
{
|
{
|
||||||
|
//Find matching row in results table
|
||||||
int index = -1;
|
int index = -1;
|
||||||
for (int j = 0; j < GameData.ResultTable.Count; j++)
|
for (int j = 0; j < GameData.ResultTable.Count; j++)
|
||||||
{
|
{
|
||||||
if (points[i].ProfileID == GameData.ResultTable[j].PlayerID)
|
if (stats[i].ProfileID == GameData.ResultTable[j].PlayerID)
|
||||||
{
|
{
|
||||||
index = j;
|
index = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index != -1)
|
if (index == -1)
|
||||||
{
|
continue;
|
||||||
CResultTableRow row = GameData.ResultTable[index];
|
CResultTableRow row = GameData.ResultTable[index];
|
||||||
|
|
||||||
row.NumPlayed++;
|
//Update results entry
|
||||||
row.NumWon += points[i].Won;
|
row.NumPlayed++;
|
||||||
row.NumSingPoints += points[i].SingPoints;
|
row.NumWon += stats[i].Won;
|
||||||
row.NumGamePoints += points[i].GamePoints;
|
row.NumSingPoints += stats[i].SingPoints;
|
||||||
|
row.NumGamePoints += stats[i].GamePoints;
|
||||||
|
|
||||||
GameData.ResultTable[index] = row;
|
GameData.ResultTable[index] = row;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameData.ResultTable.Sort();
|
GameData.ResultTable.Sort();
|
||||||
|
|||||||
Reference in new issue
Block a user