Initialize repository

Added basic info to get in game for like...August 2016 ;-;
It's not much but it's a start
This commit is contained in:
splootybean
2026-02-27 00:58:13 -08:00
parent 05c35b2a18
commit 387ec7ba89
61 changed files with 1722 additions and 0 deletions
@@ -0,0 +1,75 @@
using Microsoft.AspNetCore.Mvc;
using RecRoomArchive.Models.API.Players;
using RecRoomArchive.Services;
using System.ComponentModel.DataAnnotations;
namespace RecRoomArchive.Controllers.API.Players
{
/// <summary>
/// Used in August 2016 RecNet
/// </summary>
[Route(template: "api/[controller]")]
[ApiController]
public class PlayersController(AccountService accountService) : ControllerBase
{
/// <summary>
/// Returns the profile tied to a SteamID (If it exists)
/// </summary>
/// <param name="steamId">The SteamID of the player we are trying to get the profile of</param>
/// <returns>The profile of the player, if it exists</returns>
[HttpGet]
public async Task<ActionResult<AugustProfile>> GetProfile([Required, FromQuery] ulong steamId)
{
var baseProfile = accountService.GetSelfAccount();
if (baseProfile == null)
return NotFound();
var profile = new AugustProfile(baseProfile)
{
SteamID = steamId
};
return profile;
}
/// <summary>
/// Creates a profile and links it to a SteamID if the player does not already exist
/// </summary>
/// <param name="steamId">The SteamID of the player that we are creating a profile for</param>
/// <param name="username">The Steam username of the player that we are creating a profile for</param>
/// <returns>A new AugustProfile</returns>
[HttpPost]
public async Task<ActionResult<AugustProfile>> CreateProfile(
[Required, FromForm(Name = "SteamID")] ulong steamId,
[Required, FromForm(Name = "Name")] string username)
{
if (!accountService.AccountExists())
{
accountService.CreateAccount(username);
}
var baseProfile = accountService.GetSelfAccount();
if (baseProfile == null)
return NotFound();
var profile = new AugustProfile(baseProfile)
{
SteamID = steamId
};
return profile;
}
/// <summary>
/// Stores data related to the player onto the server
/// </summary>
/// <param name="profileId">The Id of the Profile we are storing data for</param>
/// <param name="model">The data the client posts...it happens to be an entire profile but we can take only the data we need :)</param>
/// <returns>A successful response, likely will just return the updated profile</returns>
[HttpPut(template: "{profileId:long}")]
public async Task<ActionResult<AugustProfile>> UpdateProfile([Required] ulong profileId, [FromBody] AugustProfile model)
{
return (AugustProfile)accountService.GetSelfAccount()!;
}
}
}
@@ -0,0 +1,58 @@
using Microsoft.AspNetCore.Mvc;
using RecRoomArchive.Models.API.Config;
using RecRoomArchive.Models.API.Platform;
using RecRoomArchive.Models.API.Players;
using RecRoomArchive.Services;
using System.ComponentModel.DataAnnotations;
namespace RecRoomArchive.Controllers.API.Players.V1
{
/// <summary>
/// Used to get accounts / profiles in 2016-2020 although gets phased out as time goes on...
/// </summary>
[Route(template: "api/[controller]/v1")]
[ApiController]
public class PlayersController(AccountService accountService) : ControllerBase
{
/// <summary>
/// Returns the profile of this ID (If it exists)
/// </summary>
/// <param name="id">The ID of the player we are trying to get the profile of</param>
/// <returns>The profile of the player, if it exists</returns>
[HttpGet(template: "{id:long}")]
public async Task<ActionResult<BaseProfile>> GetProfile([Required] ulong id)
{
return accountService.GetSelfAccount()!;
}
[HttpPost(template: "listByPlatformId")]
public async Task<ActionResult<List<object>>> GetFromServer([FromForm] PlatformType platform, [FromForm] List<ulong> platformIds)
{
return Ok(new List<object>());
}
[HttpGet(template: "search/{query}")]
public async Task<ActionResult<List<BaseProfile>>> SearchForProfiles(string query)
{
return Ok(new List<BaseProfile>());
}
[HttpGet(template: "phoneLastFour")]
public async Task<ActionResult<PhoneNumberDTO>> GetPhoneLastFour()
{
return Ok(new PhoneNumberDTO());
}
[HttpGet(template: "blockDuration")]
public async Task<ActionResult<BlockDurationDTO>> GetBlockDuration()
{
return Ok(new BlockDurationDTO());
}
[HttpPost(template: "objectives")]
public async Task<ActionResult> CompleteObjectives(object objective)
{
return Ok();
}
}
}
@@ -0,0 +1,37 @@
using Microsoft.AspNetCore.Mvc;
using RecRoomArchive.Models.API.Players;
using RecRoomArchive.Models.Common;
using RecRoomArchive.Services;
using System.Text.Json;
namespace RecRoomArchive.Controllers.API.Players.V2
{
/// <summary>
/// Used to modify accounts / profiles in 2017-2019 although gets phased out as time goes on...
/// </summary>
[Route(template: "api/[controller]/v2")]
[ApiController]
public class PlayersController(FileService fileService) : ControllerBase
{
/// <summary>
/// Sets the players displayName
/// </summary>
/// <param name="name">The displayName the player is requesting</param>
/// <returns>OkResponse</returns>
[HttpPost(template: "displayName")]
public async Task<ActionResult<OkResponse>> SetDisplayName([FromForm(Name = "Name")] string name)
{
var profileData = fileService.GetData("profile.json");
if (profileData == null)
return BadRequest("Profile is not populated");
var profile = JsonSerializer.Deserialize<BaseProfile>(profileData)!;
profile.DisplayName = name;
fileService.SetData("profile.json", JsonSerializer.Serialize(profile));
return Ok(OkResponse.Ok());
}
}
}