generated from Game-as-a-Service/Gaas-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor * Clean namespace
- Loading branch information
Showing
121 changed files
with
545 additions
and
893 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Wsa.Gaas.Werewolf.Application.Dtos; | ||
|
||
public class PlayerDto | ||
{ | ||
public ulong UserId { get; set; } | ||
public int PlayerNumber { get; set; } | ||
public string Role { get; set; } = null!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
global using Wsa.Gaas.Werewolf.Application.Common; | ||
global using Wsa.Gaas.Werewolf.Domain.Events; | ||
global using Wsa.Gaas.Werewolf.Domain.Exceptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
src/BackEnd/src/Application/Policies/PlayerRoleConfirmationStartedPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 15 additions & 19 deletions
34
src/BackEnd/src/Application/Policies/SeerRoundStartedEventPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
using Microsoft.Extensions.Options; | ||
using Wsa.Gaas.Werewolf.Application.Common; | ||
using Wsa.Gaas.Werewolf.Application.Options; | ||
using Wsa.Gaas.Werewolf.Domain.Events; | ||
using Wsa.Gaas.Werewolf.Domain.Exceptions; | ||
|
||
namespace Wsa.Gaas.Werewolf.Application.Policies | ||
namespace Wsa.Gaas.Werewolf.Application.Policies; | ||
internal class SeerRoundStartedEventPolicy : Policy<SeerRoundStartedEvent> | ||
{ | ||
internal class SeerRoundStartedEventPolicy : Policy<SeerRoundStartedEvent> | ||
public SeerRoundStartedEventPolicy(IOptions<GameSettingOptions> options, IRepository repository, GameEventBus gameEventBus) : base(options, repository, gameEventBus) | ||
{ | ||
public SeerRoundStartedEventPolicy(IOptions<GameSettingOptions> options, IRepository repository, GameEventBus gameEventBus) : base(options, repository, gameEventBus) | ||
{ | ||
} | ||
} | ||
|
||
public override async Task Handle(SeerRoundStartedEvent gameEvent, CancellationToken cancellationToken = default) | ||
{ | ||
// 30 seconds | ||
await Task.Delay(Options.SeerRoundTimer, cancellationToken); | ||
public override async Task Handle(SeerRoundStartedEvent gameEvent, CancellationToken cancellationToken = default) | ||
{ | ||
// 30 seconds | ||
await Task.Delay(Options.SeerRoundTimer, cancellationToken); | ||
|
||
// 時間到 raise PlayerRoleConfirmationEndedEvent | ||
var game = Repository.FindByDiscordChannelId(gameEvent.Data.DiscordVoiceChannelId) | ||
?? throw new GameNotFoundException(gameEvent.Data.DiscordVoiceChannelId) | ||
; | ||
// 時間到 raise PlayerRoleConfirmationEndedEvent | ||
var game = Repository.FindByDiscordChannelId(gameEvent.Data.DiscordVoiceChannelId) | ||
?? throw new GameNotFoundException(gameEvent.Data.DiscordVoiceChannelId) | ||
; | ||
|
||
var @event = game.StartWitchAntidoteRound(); | ||
var @event = game.StartWitchAntidoteRound(); | ||
|
||
await GameEventBus.BroadcastAsync(@event, cancellationToken); | ||
} | ||
await GameEventBus.BroadcastAsync(@event, cancellationToken); | ||
} | ||
} | ||
|
40 changes: 18 additions & 22 deletions
40
src/BackEnd/src/Application/Policies/WerewolfRoundStartedEventPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
using Microsoft.Extensions.Options; | ||
using Wsa.Gaas.Werewolf.Application.Common; | ||
using Wsa.Gaas.Werewolf.Application.Options; | ||
using Wsa.Gaas.Werewolf.Domain.Events; | ||
using Wsa.Gaas.Werewolf.Domain.Exceptions; | ||
|
||
namespace Wsa.Gaas.Werewolf.Application.Policies | ||
namespace Wsa.Gaas.Werewolf.Application.Policies; | ||
internal class WerewolfRoundStartedEventPolicy : Policy<WerewolfRoundStartedEvent> | ||
{ | ||
internal class WerewolfRoundStartedEventPolicy : Policy<WerewolfRoundStartedEvent> | ||
public WerewolfRoundStartedEventPolicy( | ||
IOptions<GameSettingOptions> options, | ||
IRepository repository, | ||
GameEventBus gameEventBus | ||
) : base(options, repository, gameEventBus) | ||
{ | ||
public WerewolfRoundStartedEventPolicy( | ||
IOptions<GameSettingOptions> options, | ||
IRepository repository, | ||
GameEventBus gameEventBus | ||
) : base(options, repository, gameEventBus) | ||
{ | ||
} | ||
} | ||
|
||
public override async Task Handle(WerewolfRoundStartedEvent gameEvent, CancellationToken cancellationToken = default) | ||
{ | ||
await Task.Delay(Options.WerewolfRoundTimer, cancellationToken); | ||
public override async Task Handle(WerewolfRoundStartedEvent gameEvent, CancellationToken cancellationToken = default) | ||
{ | ||
await Task.Delay(Options.WerewolfRoundTimer, cancellationToken); | ||
|
||
// 時間到 raise WerewolfRoundEndedEvent | ||
var game = Repository.FindByDiscordChannelId(gameEvent.Data.DiscordVoiceChannelId) | ||
?? throw new GameNotFoundException(gameEvent.Data.DiscordVoiceChannelId) | ||
; | ||
// 時間到 raise WerewolfRoundEndedEvent | ||
var game = Repository.FindByDiscordChannelId(gameEvent.Data.DiscordVoiceChannelId) | ||
?? throw new GameNotFoundException(gameEvent.Data.DiscordVoiceChannelId) | ||
; | ||
|
||
var @event = game.StartSeerRound(); | ||
var @event = game.StartSeerRound(); | ||
|
||
await GameEventBus.BroadcastAsync(@event, cancellationToken); | ||
} | ||
await GameEventBus.BroadcastAsync(@event, cancellationToken); | ||
} | ||
} | ||
|
34 changes: 15 additions & 19 deletions
34
src/BackEnd/src/Application/Policies/WitchAntidoteRoundStartedEventPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,27 @@ | ||
using Microsoft.Extensions.Options; | ||
using Wsa.Gaas.Werewolf.Application.Common; | ||
using Wsa.Gaas.Werewolf.Application.Options; | ||
using Wsa.Gaas.Werewolf.Domain.Events; | ||
using Wsa.Gaas.Werewolf.Domain.Exceptions; | ||
|
||
namespace Wsa.Gaas.Werewolf.Application.Policies | ||
namespace Wsa.Gaas.Werewolf.Application.Policies; | ||
internal class WitchAntidoteRoundStartedEventPolicy : Policy<WitchAntidoteRoundStartedEvent> | ||
{ | ||
internal class WitchAntidoteRoundStartedEventPolicy : Policy<WitchAntidoteRoundStartedEvent> | ||
public WitchAntidoteRoundStartedEventPolicy(IOptions<GameSettingOptions> options, IRepository repository, GameEventBus gameEventBus) : base(options, repository, gameEventBus) | ||
{ | ||
public WitchAntidoteRoundStartedEventPolicy(IOptions<GameSettingOptions> options, IRepository repository, GameEventBus gameEventBus) : base(options, repository, gameEventBus) | ||
{ | ||
} | ||
} | ||
|
||
public override async Task Handle(WitchAntidoteRoundStartedEvent gameEvent, CancellationToken cancellationToken = default) | ||
{ | ||
// 15 seconds | ||
await Task.Delay(Options.WitchAntidoteRoundTimer, cancellationToken); | ||
public override async Task Handle(WitchAntidoteRoundStartedEvent gameEvent, CancellationToken cancellationToken = default) | ||
{ | ||
// 15 seconds | ||
await Task.Delay(Options.WitchAntidoteRoundTimer, cancellationToken); | ||
|
||
// 時間到 | ||
var game = Repository.FindByDiscordChannelId(gameEvent.Data.DiscordVoiceChannelId) | ||
?? throw new GameNotFoundException(gameEvent.Data.DiscordVoiceChannelId) | ||
; | ||
// 時間到 | ||
var game = Repository.FindByDiscordChannelId(gameEvent.Data.DiscordVoiceChannelId) | ||
?? throw new GameNotFoundException(gameEvent.Data.DiscordVoiceChannelId) | ||
; | ||
|
||
var @event = game.StartWitchPoisonRound(); | ||
var @event = game.StartWitchPoisonRound(); | ||
|
||
await GameEventBus.BroadcastAsync(@event, cancellationToken); | ||
await GameEventBus.BroadcastAsync(@event, cancellationToken); | ||
|
||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.