Skip to content

Commit

Permalink
Merge pull request #305 from Lacyway/implement-voice-change
Browse files Browse the repository at this point in the history
Add voice change route & fix abstract class
  • Loading branch information
seionmoya authored Jan 9, 2025
2 parents a13f00a + ce2c571 commit bf34634
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 14 deletions.
10 changes: 10 additions & 0 deletions Fuyu.Backend.BSG/Models/Requests/GameProfileVoiceChangeRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Runtime.Serialization;

namespace Fuyu.Backend.BSG.Models.Requests;

[DataContract]
public class GameProfileVoiceChangeRequest
{
[DataMember(Name = "voice")]
public string Voice { get; set; }
}
2 changes: 1 addition & 1 deletion Fuyu.Backend.EFT/Controllers/GetNextFreeSlotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class GetNextFreeSlotRequest

// TODO: Delete later
// -- nexus4880, 2024-11-26
public class GetNextFreeSlotController : EftHttpController<GetNextFreeSlotRequest>
public class GetNextFreeSlotController : AbstractEftHttpController<GetNextFreeSlotRequest>
{
private readonly EftOrm _eftOrm;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Fuyu.Backend.EFT.Controllers.Http;

public class ClientInsuranceItemsListCostController : EftHttpController<InsuranceCostRequest>
public class ClientInsuranceItemsListCostController : AbstractEftHttpController<InsuranceCostRequest>
{
private readonly EftOrm _eftOrm;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Fuyu.Backend.EFT.Controllers.Http;

public class FuyuGameLoginController : EftHttpController<FuyuGameLoginRequest>
public class FuyuGameLoginController : AbstractEftHttpController<FuyuGameLoginRequest>
{
private readonly AccountService _accountService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Fuyu.Backend.EFT.Controllers.Http;

public class FuyuGameRegisterController : EftHttpController<FuyuGameRegisterRequest>
public class FuyuGameRegisterController : AbstractEftHttpController<FuyuGameRegisterRequest>
{
private readonly AccountService _accountService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Fuyu.Backend.EFT.Controllers.Http;

public class GameBotGenerateController : EftHttpController<GameBotGenerateRequest>
public class GameBotGenerateController : AbstractEftHttpController<GameBotGenerateRequest>
{
private readonly BotService _botService;

Expand Down
2 changes: 1 addition & 1 deletion Fuyu.Backend.EFT/Controllers/Http/GameModeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Fuyu.Backend.EFT.Controllers.Http;

public class GameModeController : EftHttpController<ClientGameModeRequest>
public class GameModeController : AbstractEftHttpController<ClientGameModeRequest>
{
private readonly EftOrm _eftOrm;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Fuyu.Backend.EFT.Controllers.Http;
// TODO:
// * move code into TemplateTable and ProfileService
// -- seionmoya, 2024/09/02
public class GameProfileCreateController : EftHttpController<GameProfileCreateRequest>
public class GameProfileCreateController : AbstractEftHttpController<GameProfileCreateRequest>
{
private readonly EftOrm _eftOrm;
private readonly ProfileService _profileService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Fuyu.Backend.EFT.Controllers.Http;

public class GameProfileItemsMovingController : EftHttpController<JObject>
public class GameProfileItemsMovingController : AbstractEftHttpController<JObject>
{
public ItemEventRouter ItemEventRouter { get; } = new ItemEventRouter();
private readonly EftOrm _eftOrm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Fuyu.Backend.EFT.Controllers.Http;

public class GameProfileNicknameValidateController : EftHttpController<GameProfileNicknameValidateRequest>
public class GameProfileNicknameValidateController : AbstractEftHttpController<GameProfileNicknameValidateRequest>
{
public GameProfileNicknameValidateController() : base("/client/game/profile/nickname/validate")
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Threading.Tasks;
using Fuyu.Backend.BSG.Models.Requests;
using Fuyu.Backend.BSG.Models.Responses;
using Fuyu.Backend.EFT.Networking;
using Fuyu.Common.Serialization;

namespace Fuyu.Backend.EFT.Controllers.Http;

public class GameProfileVoiceChangeController : AbstractEftHttpController<GameProfileVoiceChangeRequest>
{
private readonly EftOrm _eftOrm;

public GameProfileVoiceChangeController() : base("/client/game/profile/voice/change")
{
_eftOrm = EftOrm.Instance;
}

public override Task RunAsync(EftHttpContext context, GameProfileVoiceChangeRequest body)
{
var profile = _eftOrm.GetActiveProfile(context.GetSessionId());

profile.Pmc.Info.Voice = body.Voice;

// TODO: Save profile

var response = new ResponseBody<object>()
{
data = null
};

var text = Json.Stringify(response);
return context.SendJsonAsync(text, true, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Fuyu.Backend.EFT.Controllers.Http;

public class MatchLocalEndController : EftHttpController<MatchLocalEndRequest>
public class MatchLocalEndController : AbstractEftHttpController<MatchLocalEndRequest>
{
private readonly EftOrm _eftOrm;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Fuyu.Backend.EFT.Controllers.Http;

public class MatchLocalStartController : EftHttpController<MatchLocalStartRequest>
public class MatchLocalStartController : AbstractEftHttpController<MatchLocalStartRequest>
{
public MatchLocalStartController() : base("/client/match/local/start")
{
Expand Down
6 changes: 3 additions & 3 deletions Fuyu.Backend.EFT/Networking/AbstractEftHttpController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public override Task RunAsync(HttpContext context)
public abstract Task RunAsync(EftHttpContext context);
}

public abstract class EftHttpController<TRequest> : AbstractEftHttpController where TRequest : class
public abstract class AbstractEftHttpController<TRequest> : AbstractEftHttpController where TRequest : class
{
protected EftHttpController(Regex pattern) : base(pattern)
protected AbstractEftHttpController(Regex pattern) : base(pattern)
{
// match dynamic paths
}

protected EftHttpController(string path) : base(path)
protected AbstractEftHttpController(string path) : base(path)
{
// match static paths
}
Expand Down

0 comments on commit bf34634

Please sign in to comment.