forked from SoDOff-Project/sodoff
highscore fixes
This commit is contained in:
parent
c5bc21e539
commit
385449c1e7
@ -82,6 +82,7 @@ methods = [
|
||||
'ApplyPayout',
|
||||
'RedeemMysteryBoxItems',
|
||||
'SendRawGameData',
|
||||
'GetGameData',
|
||||
'GetGameDataByGame',
|
||||
'GetGameDataByGameForDateRange',
|
||||
'GetTopAchievementPointUsers',
|
||||
|
@ -949,9 +949,10 @@ public class ContentController : Controller {
|
||||
[HttpPost]
|
||||
[Produces("application/xml")]
|
||||
[Route("V2/ContentWebService.asmx/GetGameData")]
|
||||
public IActionResult GetGameData() {
|
||||
// TODO: This is a placeholder
|
||||
return Ok(new GetGameDataResponse());
|
||||
[VikingSession]
|
||||
public IActionResult GetGameData(Viking viking, [FromForm] string gameDataRequest) {
|
||||
GetGameDataRequest request = XmlUtil.DeserializeXml<GetGameDataRequest>(gameDataRequest);
|
||||
return Ok(gameDataService.GetGameDataForPlayer(viking, request));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
48
src/Schema/GetGameDataRequest.cs
Normal file
48
src/Schema/GetGameDataRequest.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace sodoff.Schema;
|
||||
[XmlRoot(ElementName = "GetGameDataRequest", Namespace = "")]
|
||||
[Serializable]
|
||||
public class GetGameDataRequest {
|
||||
[XmlElement(ElementName = "ProductGroupID")]
|
||||
public int? ProductGroupID { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "UserID")]
|
||||
public Guid? UserID { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "GameID")]
|
||||
public int? GameID { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "GameLevelID")]
|
||||
public int? GameLevelID { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "DifficultlyID")]
|
||||
public int? DifficultlyID { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "IsMultiplayer")]
|
||||
public bool? IsMultiplayer { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "TopScoresOnly")]
|
||||
public bool? TopScoresOnly { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "AllProductGroups")]
|
||||
public bool? AllProductGroups { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "AllUsers")]
|
||||
public bool? AllUsers { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "KEY")]
|
||||
public string Key { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "CNT")]
|
||||
public int? Count { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "SC")]
|
||||
public int? Score { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "AO")]
|
||||
public bool? AscendingOrder { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "FBIDS")]
|
||||
public List<long> FacebookUserIDs { get; set; }
|
||||
}
|
@ -4,6 +4,7 @@ namespace sodoff.Schema;
|
||||
|
||||
[XmlRoot(ElementName = "GetGameDataResponse", Namespace = "")]
|
||||
[Serializable]
|
||||
public class GetGameDataResponse
|
||||
{
|
||||
public class GetGameDataResponse {
|
||||
[XmlElement(ElementName = "GameDataSummaryList")]
|
||||
public List<GameDataSummary> GameDataSummaryList { get; set; } = new List<GameDataSummary>();
|
||||
}
|
||||
|
@ -55,6 +55,37 @@ public class GameDataService {
|
||||
return GetSummaryFromResponse(viking, isMultiplayer, difficulty, gameLevel, key, selectedData);
|
||||
}
|
||||
|
||||
public GetGameDataResponse GetGameDataForPlayer(Viking viking, GetGameDataRequest request) {
|
||||
GetGameDataResponse response = new();
|
||||
if (request.GameID is null)
|
||||
return response;
|
||||
|
||||
var dbData = viking.GameData.Where(x => x.GameId == request.GameID)
|
||||
.SelectMany(e => e.GameDataPairs)
|
||||
.Select(x => new { x.Name, x.Value, x.GameData.DatePlayed, x.GameData.Win, x.GameData.Loss, x.GameData.IsMultiplayer, x.GameData.Difficulty, x.GameData.GameLevel });
|
||||
foreach (var data in dbData) {
|
||||
response.GameDataSummaryList.Add(new GameDataSummary {
|
||||
GameID = (int)request.GameID,
|
||||
IsMultiplayer = data.IsMultiplayer,
|
||||
Difficulty = data.Difficulty,
|
||||
GameLevel = data.GameLevel,
|
||||
Key = data.Name,
|
||||
GameDataList = new Schema.GameData[] {
|
||||
new Schema.GameData {
|
||||
IsMember = true,
|
||||
Value = data.Value,
|
||||
DatePlayed = data.DatePlayed,
|
||||
Win = data.Win ? 1 : 0,
|
||||
Loss = data.Loss ? 1 : 0,
|
||||
UserID = viking.Uid
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private GameDataSummary GetSummaryFromResponse(Viking viking, bool isMultiplayer, int difficulty, int gameLevel, string key, List<GameDataResponse> selectedData) {
|
||||
GameDataSummary gameData = new();
|
||||
gameData.IsMultiplayer = isMultiplayer;
|
||||
@ -87,7 +118,7 @@ public class GameDataService {
|
||||
GameDataPair? dbPair = gameData.GameDataPairs.FirstOrDefault(x => x.Name == pair.Name);
|
||||
if (dbPair == null)
|
||||
gameData.GameDataPairs.Add(pair);
|
||||
else
|
||||
else if (dbPair.Value <= pair.Value)
|
||||
dbPair.Value = pair.Value;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user