forked from SoDOff-Project/sodoff
Fixed Mutt Pods + Implemented GetTopAchievementPointBuddiesByType
* Mutt Couch Fixes Removed duplicate mutt from the couch. Mutts on couch in other players' mutt pods will now reflect that player's account. * Buddies list will now appear on the sidebar, making the mutt pod tutorial possible. --------- * Fixed some issues that were pointed out. * ContentController.GetUnselectedPetByTypes now uses regular IF check for setting owner viking. * remove unused apiKey from GetActiveRaisedPet args
This commit is contained in:
parent
a45323b447
commit
a0f7b1ba3e
@ -231,4 +231,16 @@ public class AchievementController : Controller {
|
||||
UserAchievementInfoRequest infoRequest = XmlUtil.DeserializeXml<UserAchievementInfoRequest>(request);
|
||||
return Ok(achievementService.GetTopAchievementUsers(infoRequest));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/xml")]
|
||||
[Route("AchievementWebService.asmx/GetTopAchievementPointBuddiesByType")] // Used by Math Blaster
|
||||
[VikingSession]
|
||||
public IActionResult GetTopAchievementPointBuddiesByType([FromForm] string userId, [FromForm] int pointTypeID) {
|
||||
UserAchievementInfoRequest infoRequest = new UserAchievementInfoRequest {
|
||||
UserID = new Guid(userId),
|
||||
PointTypeID = pointTypeID
|
||||
};
|
||||
return Ok(achievementService.GetTopAchievementBuddies(infoRequest));
|
||||
}
|
||||
}
|
||||
|
@ -777,7 +777,14 @@ public class ContentController : Controller {
|
||||
[Produces("application/xml")]
|
||||
[Route("ContentWebService.asmx/GetUnselectedPetByTypes")] // used by old SoD (e.g. 1.13)
|
||||
[VikingSession(UseLock=false)]
|
||||
public RaisedPetData[]? GetUnselectedPetByTypes(Viking viking, [FromForm] string petTypeIDs, [FromForm] bool active) {
|
||||
public RaisedPetData[]? GetUnselectedPetByTypes(Viking viking, [FromForm] string? userId, [FromForm] string petTypeIDs, [FromForm] bool active) {
|
||||
// Get viking based on userId, or use request player's viking as a fallback.
|
||||
if (userId != null) {
|
||||
Guid userIdGuid = new Guid(userId);
|
||||
Viking? ownerViking = ctx.Vikings.FirstOrDefault(e => e.Uid == userIdGuid);
|
||||
if (ownerViking != null) viking = ownerViking;
|
||||
}
|
||||
|
||||
RaisedPetData[] dragons = viking.Dragons
|
||||
.Where(d => d.RaisedPetData is not null)
|
||||
.Select(d => GetRaisedPetDataFromDragon(d, viking.SelectedDragonId))
|
||||
@ -790,7 +797,10 @@ public class ContentController : Controller {
|
||||
List<RaisedPetData> filteredDragons = new List<RaisedPetData>();
|
||||
int[] petTypeIDsInt = Array.ConvertAll(petTypeIDs.Split(','), s => int.Parse(s));
|
||||
foreach (RaisedPetData dragon in dragons) {
|
||||
if (petTypeIDsInt.Contains(dragon.PetTypeID)) {
|
||||
if (petTypeIDsInt.Contains(dragon.PetTypeID) &&
|
||||
// Don't send the selected dragon.
|
||||
viking.SelectedDragonId != dragon.RaisedPetID
|
||||
) {
|
||||
filteredDragons.Add(dragon);
|
||||
}
|
||||
}
|
||||
@ -809,7 +819,7 @@ public class ContentController : Controller {
|
||||
public RaisedPetData[] GetActiveRaisedPet(Viking viking, [FromForm] string userId, [FromForm] int petTypeID) {
|
||||
if (petTypeID == 2) {
|
||||
// player can have multiple Minisaurs at the same time ... Minisaurs should never have been selected also ... so use GetUnselectedPetByTypes in this case
|
||||
return GetUnselectedPetByTypes(viking, "2", false);
|
||||
return GetUnselectedPetByTypes(viking, userId, "2", false);
|
||||
}
|
||||
|
||||
Dragon? dragon = viking.SelectedDragon;
|
||||
|
@ -200,5 +200,34 @@ namespace sodoff.Services {
|
||||
DateRange = new DateRange()
|
||||
};
|
||||
}
|
||||
public ArrayOfUserAchievementInfo GetTopAchievementBuddies(UserAchievementInfoRequest request) {
|
||||
// TODO: Type and mode are currently ignored
|
||||
List<UserAchievementInfo> achievementInfo = new();
|
||||
var topAchievers = ctx.AchievementPoints.Where(x => x.Type == request.PointTypeID)
|
||||
.Select(e => new { e.Viking.Uid, e.Viking.Name, e.Value })
|
||||
.OrderByDescending(e => e.Value)
|
||||
.Take(10); // Lets not sent 50,000 entries to the client please.
|
||||
|
||||
foreach (var a in topAchievers) {
|
||||
achievementInfo.Add(new UserAchievementInfo {
|
||||
UserID = a.Uid,
|
||||
UserName = a.Name,
|
||||
AchievementPointTotal = a.Value,
|
||||
PointTypeID = (AchievementPointTypes)request.PointTypeID
|
||||
});
|
||||
}
|
||||
if (achievementInfo.Count<=0) { // If there are no points for this (liekly won't be until implemented), just add GC and everything might be fine.
|
||||
achievementInfo.Add(new UserAchievementInfo {
|
||||
UserID = new Guid("ffffffff-0000-0000-0000-000000000001"),
|
||||
UserName = "GC",
|
||||
AchievementPointTotal = 69,
|
||||
PointTypeID = (AchievementPointTypes)request.PointTypeID
|
||||
});
|
||||
}
|
||||
|
||||
return new ArrayOfUserAchievementInfo {
|
||||
UserAchievementInfo = achievementInfo.ToArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user