Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion Refresh.Database/Models/Pins/ServerPins.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
namespace Refresh.Database.Models.Pins;

/// <summary>
/// The progress types of pins which have to be awarded manually by the server.
/// The progress types of pins which have to either be awarded manually by the server,
/// or be returned/used elsewhere (e.g. LBP3 challenges)
/// </summary>
public enum ServerPins : long
{
Expand All @@ -15,4 +16,47 @@ public enum ServerPins : long
SignIntoWebsite = 2691148325,
HeartPlayerOnWebsite = 1965011384,
QueueLevelOnWebsite = 2833810997,

// LBP3 challenges
OverLineLbp3ChallengeMedal = 3003874881,
OverLineLbp3ChallengeRanking = 2922567456,

PixelPaceLbp3ChallengeMedal = 282407472,
PixelPaceLbp3ChallengeRanking = 3340696069,

RabbitBoxingLbp3ChallengeMedal = 2529088759,
RabbitBoxingLbp3ChallengeRanking = 958144818,

FloatyFluidLbp3ChallengeMedal = 183892581,
FloatyFluidLbp3ChallengeRanking = 3442917932,

ToggleIslandLbp3ChallengeMedal = 315245769,
ToggleIslandLbp3ChallengeRanking = 443310584,

SpaceDodgeballLbp3ChallengeMedal = 144212050,
SpaceDodgeballLbp3ChallengeRanking = 2123417147,

InvisibleMazeLbp3ChallengeMedal = 249569175,
InvisibleMazeLbp3ChallengeRanking = 1943114258,

HoverboardLbp3ChallengeMedal = 3478661003,
HoverboardLbp3ChallengeRanking = 592022798,

WhoopTowerLbp3ChallengeMedal = 216730878,
WhoopTowerLbp3ChallengeRanking = 545532447,

SwoopPanelsLbp3ChallengeMedal = 2054302637,
SwoopPanelsLbp3ChallengeRanking = 3288689476,

PinballLbp3ChallengeMedal = 618998172,
PinballLbp3ChallengeRanking = 4087839785,

TieSkipLbp3ChallengeMedal = 3953447125,
TieSkipLbp3ChallengeRanking = 2556445436,

JokerLbp3ChallengeMedal = 1093784294,
JokerLbp3ChallengeRanking = 1757295127,

CherryShooterLbp3ChallengeMedal = 1568570416,
CherryShooterLbp3ChallengeRanking = 3721717765,
}
51 changes: 39 additions & 12 deletions Refresh.Interfaces.Game/Endpoints/Handshake/MetadataEndpoints.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Xml.Serialization;
using Bunkum.Core;
using Bunkum.Core.Endpoints;
using Bunkum.Core.Endpoints.Debugging;
using Bunkum.Core.Responses;
using Bunkum.Core.Responses.Serialization;
using Bunkum.Listener.Protocol;
using Bunkum.Protocols.Http;
using Refresh.Common.Time;
Expand Down Expand Up @@ -191,23 +193,48 @@ private static readonly Lazy<string?> DeveloperVideosFile
// {"currentLevel": ["developer_adventure_planet", 349],"inStore": true,"participants": ["turecross321","","",""]}
// {"highlightedSearchResult": ["level",811],"currentLevel": ["pod", 0],"inStore": true,"participants": ["turecross321","","",""]}
public string GameState(RequestContext context) => "VALID";

private static readonly Lazy<string?> ChallengeConfigFile
= new(() =>
{
string path = Path.Combine(Environment.CurrentDirectory, "ChallengeConfig.xml");

return File.Exists(path) ? File.ReadAllText(path) : null;
});

[GameEndpoint("ChallengeConfig.xml", ContentType.Xml)]
[MinimumRole(GameUserRole.Restricted)]
public SerializedLbp3ChallengeList ChallengeConfig(RequestContext context, IDateTimeProvider timeProvider)
public string ChallengeConfig(RequestContext context)
{
//TODO: allow this to be controlled by the server owner, right now lets just send the game 0 challenges,
// so nothing appears in the challenges menu
return new SerializedLbp3ChallengeList
bool created = ChallengeConfigFile.IsValueCreated;
string? challengeConfig = ChallengeConfigFile.Value;

// If file was read, return its contents. Else serialize and return a hard-coded default list of challenges.
if (challengeConfig != null)
{
TotalChallenges = 0,
EndTime = (ulong)(timeProvider.Now.ToUnixTimeMilliseconds() * 1000),
BronzeRankPercentage = 0,
SilverRankPercentage = 0,
GoldRankPercentage = 0,
CycleTime = 0,
Challenges = [],
};
return challengeConfig;
}
else
{
// Only log this warning once
if (!created) context.Logger.LogWarning(BunkumCategory.Request,
"ChallengeConfig.xml file is missing! We've defaulted to one which is loosely based off of the official server's config, "+
"but it might be relevant to you if you are an advanced user.");

using MemoryStream ms = new();
using BunkumXmlTextWriter bunkumXmlTextWriter = new(ms);

XmlSerializerNamespaces namespaces = new();
namespaces.Add("", "");

XmlSerializer serializer = new(typeof(SerializedLbp3ChallengeList));
serializer.Serialize(bunkumXmlTextWriter, SerializedLbp3ChallengeList.Default, namespaces);

ms.Seek(0, SeekOrigin.Begin);
using StreamReader reader = new(ms);

return reader.ReadToEnd();
}
}

[GameEndpoint("tags")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,20 @@ public class SerializedLbp3Challenge
public string LamsTitleId { get; set; }

/// <summary>
/// The ID of the pin you receive for completing this challenge
/// The progress type of the pin indicating whether the user's highscore is bronze, silver or gold (progress value is 1-3 accordingly)
/// </summary>
[XmlAttribute("Challenge_PinId")]
public ulong PinId { get; set; }
public ulong ScoreMedalPinProgressType { get; set; }

/// <summary>
/// The progress type of the Pin indicating whether the user is in the top 50%, 25% or 10% of the leaderboard
/// </summary>
// TODO: As soon as score submission for adventures/LBP3 challenges is implemented,
// find out whether these need to be awarded by the server, and also find out
// whether these pins have a descending progress and special case them
// in the progress update method if they do.
[XmlAttribute("Challenge_RankPin")]
public ulong RankPin { get; set; }
public ulong ScoreRankingPinProgressType { get; set; }

/// <summary>
/// A PSN DLC id for the DLC associated with this challenge
Expand Down
Loading