mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
WoJS: Use DisplayName in GamesData
- Use DisplayName instead of Viking Name Co-authored-by: Robert Paciorek <robert@opcode.eu.org>
This commit is contained in:
parent
cadf9dd977
commit
1600938902
@ -2123,17 +2123,17 @@ public class ContentController : Controller {
|
||||
[Produces("application/xml")]
|
||||
[Route("ContentWebService.asmx/GetGameDataByGame")]
|
||||
[VikingSession(UseLock = true)]
|
||||
public IActionResult GetGameDataByGame(Viking viking, [FromForm] int gameId, bool isMultiplayer, int difficulty, int gameLevel, string key, int count, bool AscendingOrder, int score, bool buddyFilter) {
|
||||
return Ok(gameDataService.GetGameData(viking, gameId, isMultiplayer, difficulty, gameLevel, key, count, AscendingOrder, buddyFilter));
|
||||
public IActionResult GetGameDataByGame(Viking viking, [FromForm] int gameId, bool isMultiplayer, int difficulty, int gameLevel, string key, int count, bool AscendingOrder, int score, bool buddyFilter, string apiKey) {
|
||||
return Ok(gameDataService.GetGameData(viking, gameId, isMultiplayer, difficulty, gameLevel, key, count, AscendingOrder, buddyFilter, apiKey));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/xml")]
|
||||
[Route("V2/ContentWebService.asmx/GetGameDataByGameForDateRange")]
|
||||
[VikingSession(UseLock = true)]
|
||||
public IActionResult GetGameDataByGameForDateRange(Viking viking, [FromForm] int gameId, bool isMultiplayer, int difficulty, int gameLevel, string key, int count, bool AscendingOrder, int score, string startDate, string endDate, bool buddyFilter) {
|
||||
public IActionResult GetGameDataByGameForDateRange(Viking viking, [FromForm] int gameId, bool isMultiplayer, int difficulty, int gameLevel, string key, int count, bool AscendingOrder, int score, string startDate, string endDate, bool buddyFilter, string apiKey) {
|
||||
CultureInfo usCulture = new CultureInfo("en-US", false);
|
||||
return Ok(gameDataService.GetGameData(viking, gameId, isMultiplayer, difficulty, gameLevel, key, count, AscendingOrder, buddyFilter, DateTime.Parse(startDate, usCulture), DateTime.Parse(endDate, usCulture)));
|
||||
return Ok(gameDataService.GetGameData(viking, gameId, isMultiplayer, difficulty, gameLevel, key, count, AscendingOrder, buddyFilter, apiKey, DateTime.Parse(startDate, usCulture), DateTime.Parse(endDate, usCulture)));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
@ -2,6 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using sodoff.Model;
|
||||
using sodoff.Schema;
|
||||
using sodoff.Util;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace sodoff.Services;
|
||||
@ -33,7 +34,7 @@ public class GameDataService {
|
||||
return true;
|
||||
}
|
||||
|
||||
public GameDataSummary GetGameData(Viking viking, [FromForm] int gameId, bool isMultiplayer, int difficulty, int gameLevel, string key, int count, bool AscendingOrder, bool buddyFilter, DateTime? startDate = null, DateTime? endDate = null) {
|
||||
public GameDataSummary GetGameData(Viking viking, int gameId, bool isMultiplayer, int difficulty, int gameLevel, string key, int count, bool AscendingOrder, bool buddyFilter, string apiKey, DateTime? startDate = null, DateTime? endDate = null) {
|
||||
// TODO: Buddy filter
|
||||
List<GameDataResponse> selectedData;
|
||||
IQueryable<Model.GameData> query = ctx.GameData.Where(x => x.GameId == gameId && x.IsMultiplayer == false && x.Difficulty == difficulty && x.GameLevel == gameLevel);
|
||||
@ -44,10 +45,26 @@ public class GameDataService {
|
||||
var query2 = query.SelectMany(e => e.GameDataPairs)
|
||||
.Where(x => x.Name == key);
|
||||
|
||||
if (AscendingOrder)
|
||||
selectedData = query2.OrderBy(e => e.Value).Select(e => new GameDataResponse(e.GameData.Viking.Name, e.GameData.Viking.Uid, e.GameData.DatePlayed, e.GameData.Win, e.GameData.Loss, e.Value)).Take(count).ToList();
|
||||
else
|
||||
selectedData = query2.OrderByDescending(e => e.Value).Select(e => new GameDataResponse(e.GameData.Viking.Name, e.GameData.Viking.Uid, e.GameData.DatePlayed, e.GameData.Win, e.GameData.Loss, e.Value)).Take(count).ToList();
|
||||
if (ClientVersion.GetVersion(apiKey) == ClientVersion.WoJS) {
|
||||
// use DisplayName instead of Name
|
||||
if (AscendingOrder)
|
||||
selectedData = query2.OrderBy(e => e.Value).Select(e => new GameDataResponse(
|
||||
XmlUtil.DeserializeXml<AvatarData>(e.GameData.Viking.AvatarSerialized).DisplayName, e.GameData.Viking.Uid, e.GameData.DatePlayed, e.GameData.Win, e.GameData.Loss, e.Value)
|
||||
).Take(count).ToList();
|
||||
else
|
||||
selectedData = query2.OrderByDescending(e => e.Value).Select(e => new GameDataResponse(
|
||||
XmlUtil.DeserializeXml<AvatarData>(e.GameData.Viking.AvatarSerialized).DisplayName, e.GameData.Viking.Uid, e.GameData.DatePlayed, e.GameData.Win, e.GameData.Loss, e.Value)
|
||||
).Take(count).ToList();
|
||||
} else {
|
||||
if (AscendingOrder)
|
||||
selectedData = query2.OrderBy(e => e.Value).Select(e => new GameDataResponse(
|
||||
e.GameData.Viking.Name, e.GameData.Viking.Uid, e.GameData.DatePlayed, e.GameData.Win, e.GameData.Loss, e.Value)
|
||||
).Take(count).ToList();
|
||||
else
|
||||
selectedData = query2.OrderByDescending(e => e.Value).Select(e => new GameDataResponse(
|
||||
e.GameData.Viking.Name, e.GameData.Viking.Uid, e.GameData.DatePlayed, e.GameData.Win, e.GameData.Loss, e.Value)
|
||||
).Take(count).ToList();
|
||||
}
|
||||
|
||||
return GetSummaryFromResponse(viking, isMultiplayer, difficulty, gameLevel, key, selectedData);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user