diff --git a/Client/Components/BlazorMap.cs b/Client/Components/BlazorMap.cs index d6d0781..f32cae3 100644 --- a/Client/Components/BlazorMap.cs +++ b/Client/Components/BlazorMap.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using SharedLibrary.MonopolyMap; +using System.ComponentModel; namespace Client.Components; @@ -21,7 +22,7 @@ public class BlazorMap public int BlockHeight => _blockHeight; - public BlazorMap(SharedLibrary.MonopolyMap data) + public BlazorMap(MonopolyMap data) { // 自動Mapping _data 到 _blocks _blocks = new Block[data.Data.Length][]; @@ -35,13 +36,13 @@ public BlazorMap(SharedLibrary.MonopolyMap data) var y = i * (_blockHeight + _blockMargin); _blocks[i][j] = monopolyBlock.Type switch { - SharedLibrary.BlockType.None => null!, - SharedLibrary.BlockType.Land => CreateLand(monopolyBlock, x, y), - SharedLibrary.BlockType.Road => new Road(x, y, monopolyBlock.Id, monopolyBlock.ToRoad().RoadType.ToBlazorRoadType()), - SharedLibrary.BlockType.ParkingLot => new ParkingLot(x, y, monopolyBlock.Id), - SharedLibrary.BlockType.Prison => new Prison(x, y, monopolyBlock.Id), - SharedLibrary.BlockType.StartPoint => new StartPoint(x, y, monopolyBlock.Id), - SharedLibrary.BlockType.Station => new Station(x, y, monopolyBlock.Id, monopolyBlock.ToStation().RoadType.ToBlazorStationRoadType()), + BlockType.None => null!, + BlockType.Land => CreateLand(monopolyBlock, x, y), + BlockType.Road => new Road(x, y, monopolyBlock.Id, monopolyBlock.ToRoad().RoadType.ToBlazorRoadType()), + BlockType.ParkingLot => new ParkingLot(x, y, monopolyBlock.Id), + BlockType.Prison => new Prison(x, y, monopolyBlock.Id), + BlockType.StartPoint => new StartPoint(x, y, monopolyBlock.Id), + BlockType.Station => new Station(x, y, monopolyBlock.Id, monopolyBlock.ToStation().RoadType.ToBlazorStationRoadType()), _ => throw new InvalidEnumArgumentException() }; } @@ -59,7 +60,7 @@ public BlazorMap(SharedLibrary.MonopolyMap data) /// 原座標Y /// /// - private static Land CreateLand(SharedLibrary.BlockBase block, int x, int y) + private static Land CreateLand(BlockBase block, int x, int y) { var type = block.ToLand().LandType.ToBlazorLandType(); double offsetX = type switch @@ -178,67 +179,67 @@ public static string GetImageName(this BlazorMap.StationRoadType stationRoadType return GetImageName(typeof(BlazorMap.StationRoadType), stationRoadType); } - public static SharedLibrary.Land ToLand(this SharedLibrary.BlockBase block) + public static Land ToLand(this BlockBase block) { - return (SharedLibrary.Land)block; + return (Land)block; } - public static BlazorMap.LandType ToBlazorLandType(this SharedLibrary.LandType landType) + public static BlazorMap.LandType ToBlazorLandType(this LandType landType) { return landType switch { - SharedLibrary.LandType.Right => BlazorMap.LandType.Right, - SharedLibrary.LandType.Down => BlazorMap.LandType.Down, - SharedLibrary.LandType.Left => BlazorMap.LandType.Left, - SharedLibrary.LandType.Up => BlazorMap.LandType.Up, + LandType.Right => BlazorMap.LandType.Right, + LandType.Down => BlazorMap.LandType.Down, + LandType.Left => BlazorMap.LandType.Left, + LandType.Up => BlazorMap.LandType.Up, _ => throw new InvalidEnumArgumentException() }; } - public static SharedLibrary.Road ToRoad(this SharedLibrary.BlockBase block) + public static Road ToRoad(this BlockBase block) { - return (SharedLibrary.Road)block; + return (Road)block; } - public static BlazorMap.RoadType ToBlazorRoadType(this SharedLibrary.RoadType roadType) + public static BlazorMap.RoadType ToBlazorRoadType(this RoadType roadType) { return roadType switch { - SharedLibrary.RoadType.TopLeftIntersection => BlazorMap.RoadType.TopLeftIntersection, - SharedLibrary.RoadType.TopIntersection => BlazorMap.RoadType.TopIntersection, - SharedLibrary.RoadType.TopRightIntersection => BlazorMap.RoadType.TopRightIntersection, - SharedLibrary.RoadType.LeftCenterIntersection => BlazorMap.RoadType.LeftCenterIntersection, - SharedLibrary.RoadType.CenterIntersection => BlazorMap.RoadType.CenterIntersection, - SharedLibrary.RoadType.RightCenterIntersection => BlazorMap.RoadType.RightCenterIntersection, - SharedLibrary.RoadType.BottomLeftIntersection => BlazorMap.RoadType.BottomLeftIntersection, - SharedLibrary.RoadType.BottomIntersection => BlazorMap.RoadType.BottomIntersection, - SharedLibrary.RoadType.BottomRightIntersection => BlazorMap.RoadType.BottomRightIntersection, - SharedLibrary.RoadType.HorizontalRoad => BlazorMap.RoadType.HorizontalRoad, - SharedLibrary.RoadType.VerticalRoad => BlazorMap.RoadType.VerticalRoad, + RoadType.TopLeftIntersection => BlazorMap.RoadType.TopLeftIntersection, + RoadType.TopIntersection => BlazorMap.RoadType.TopIntersection, + RoadType.TopRightIntersection => BlazorMap.RoadType.TopRightIntersection, + RoadType.LeftCenterIntersection => BlazorMap.RoadType.LeftCenterIntersection, + RoadType.CenterIntersection => BlazorMap.RoadType.CenterIntersection, + RoadType.RightCenterIntersection => BlazorMap.RoadType.RightCenterIntersection, + RoadType.BottomLeftIntersection => BlazorMap.RoadType.BottomLeftIntersection, + RoadType.BottomIntersection => BlazorMap.RoadType.BottomIntersection, + RoadType.BottomRightIntersection => BlazorMap.RoadType.BottomRightIntersection, + RoadType.HorizontalRoad => BlazorMap.RoadType.HorizontalRoad, + RoadType.VerticalRoad => BlazorMap.RoadType.VerticalRoad, _ => throw new InvalidEnumArgumentException() }; } - public static SharedLibrary.Station ToStation(this SharedLibrary.BlockBase block) + public static Station ToStation(this BlockBase block) { - return (SharedLibrary.Station)block; + return (Station)block; } - public static BlazorMap.StationRoadType ToBlazorStationRoadType(this SharedLibrary.RoadType stationRoadType) + public static BlazorMap.StationRoadType ToBlazorStationRoadType(this RoadType stationRoadType) { return stationRoadType switch { - SharedLibrary.RoadType.TopLeftIntersection => BlazorMap.StationRoadType.TopLeftIntersection, - SharedLibrary.RoadType.TopIntersection => BlazorMap.StationRoadType.TopIntersection, - SharedLibrary.RoadType.TopRightIntersection => BlazorMap.StationRoadType.TopRightIntersection, - SharedLibrary.RoadType.LeftCenterIntersection => BlazorMap.StationRoadType.LeftCenterIntersection, - SharedLibrary.RoadType.CenterIntersection => BlazorMap.StationRoadType.CenterIntersection, - SharedLibrary.RoadType.RightCenterIntersection => BlazorMap.StationRoadType.RightCenterIntersection, - SharedLibrary.RoadType.BottomLeftIntersection => BlazorMap.StationRoadType.BottomLeftIntersection, - SharedLibrary.RoadType.BottomIntersection => BlazorMap.StationRoadType.BottomIntersection, - SharedLibrary.RoadType.BottomRightIntersection => BlazorMap.StationRoadType.BottomRightIntersection, - SharedLibrary.RoadType.HorizontalRoad => BlazorMap.StationRoadType.HorizontalRoad, - SharedLibrary.RoadType.VerticalRoad => BlazorMap.StationRoadType.VerticalRoad, + RoadType.TopLeftIntersection => BlazorMap.StationRoadType.TopLeftIntersection, + RoadType.TopIntersection => BlazorMap.StationRoadType.TopIntersection, + RoadType.TopRightIntersection => BlazorMap.StationRoadType.TopRightIntersection, + RoadType.LeftCenterIntersection => BlazorMap.StationRoadType.LeftCenterIntersection, + RoadType.CenterIntersection => BlazorMap.StationRoadType.CenterIntersection, + RoadType.RightCenterIntersection => BlazorMap.StationRoadType.RightCenterIntersection, + RoadType.BottomLeftIntersection => BlazorMap.StationRoadType.BottomLeftIntersection, + RoadType.BottomIntersection => BlazorMap.StationRoadType.BottomIntersection, + RoadType.BottomRightIntersection => BlazorMap.StationRoadType.BottomRightIntersection, + RoadType.HorizontalRoad => BlazorMap.StationRoadType.HorizontalRoad, + RoadType.VerticalRoad => BlazorMap.StationRoadType.VerticalRoad, _ => throw new InvalidEnumArgumentException() }; } diff --git a/Client/Pages/Game.razor.cs b/Client/Pages/Game.razor.cs index 5f997ef..5382485 100644 --- a/Client/Pages/Game.razor.cs +++ b/Client/Pages/Game.razor.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.SignalR.Client; using Microsoft.Extensions.Options; using MudBlazor; -using SharedLibrary; +using SharedLibrary.MonopolyMap; using System.Net.Http.Json; namespace Client.Pages; diff --git a/Domain/Events/PlayerBuildHouseEvent.cs b/Domain/Events/PlayerBuildHouseEvent.cs index f1fbead..3a14025 100644 --- a/Domain/Events/PlayerBuildHouseEvent.cs +++ b/Domain/Events/PlayerBuildHouseEvent.cs @@ -2,7 +2,7 @@ namespace Domain.Events; -public record PlayerBuildHouseEvent(string GameId, string PlayerId, string BlockId, decimal PlayerMoney, int House) +public record PlayerBuildHouseEvent(string GameId, string PlayerId, string BlockId, decimal PlayerMoney, int House) : DomainEvent(GameId); public record PlayerCannotBuildHouseEvent(string GameId, string PlayerId, string BlockId) diff --git a/Server/Hubs/MonopolyHub.cs b/Server/Hubs/MonopolyHub.cs index 4f7fec4..60ea20d 100644 --- a/Server/Hubs/MonopolyHub.cs +++ b/Server/Hubs/MonopolyHub.cs @@ -2,6 +2,7 @@ using Application.Usecases; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.SignalR; +using SharedLibrary; using System.Security.Claims; namespace Server.Hubs; diff --git a/Server/MonopolyEventBus.cs b/Server/MonopolyEventBus.cs index 58106ee..7ea3c03 100644 --- a/Server/MonopolyEventBus.cs +++ b/Server/MonopolyEventBus.cs @@ -3,6 +3,7 @@ using Domain.Events; using Microsoft.AspNetCore.SignalR; using Server.Hubs; +using SharedLibrary; namespace Server; diff --git a/Server/Program.cs b/Server/Program.cs index 315346f..7cd00cf 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -8,7 +8,7 @@ using Server.Hubs; using Server.Repositories; using Server.Services; -using SharedLibrary; +using SharedLibrary.MonopolyMap; using System.Security.Claims; var builder = WebApplication.CreateBuilder(args); diff --git a/Server/Hubs/IMonopolyResponses.cs b/SharedLibrary/IMonopolyResponse.cs similarity index 98% rename from Server/Hubs/IMonopolyResponses.cs rename to SharedLibrary/IMonopolyResponse.cs index 6632320..d23a686 100644 --- a/Server/Hubs/IMonopolyResponses.cs +++ b/SharedLibrary/IMonopolyResponse.cs @@ -1,4 +1,4 @@ -namespace Server.Hubs; +namespace SharedLibrary; public interface IMonopolyResponses { diff --git a/SharedLibrary/MonopolyMap.cs b/SharedLibrary/MonopolyMap/MonopolyMap.cs similarity index 98% rename from SharedLibrary/MonopolyMap.cs rename to SharedLibrary/MonopolyMap/MonopolyMap.cs index ee99693..98cf1ac 100644 --- a/SharedLibrary/MonopolyMap.cs +++ b/SharedLibrary/MonopolyMap/MonopolyMap.cs @@ -1,7 +1,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace SharedLibrary; +namespace SharedLibrary.MonopolyMap; public class MonopolyMap { @@ -66,11 +66,11 @@ public enum LandType Up } -public class TestMap +public class TestMap { public MonopolyMap Map { get; set; } - public TestMap() - { + public TestMap() + { var emptyBlock = new EmptyBlock(); var land = (string id, LandType landType) => new Land(id, landType); var road = (string id, RoadType roadType) => new Road(id, roadType); diff --git a/SharedLibrary/SharedLibrary.csproj b/SharedLibrary/SharedLibrary.csproj index cfadb03..a5c22cd 100644 --- a/SharedLibrary/SharedLibrary.csproj +++ b/SharedLibrary/SharedLibrary.csproj @@ -6,4 +6,8 @@ enable + + + + diff --git a/Test/ServerTests/AcceptanceTests/BuildHouseTest.cs b/Test/ServerTests/AcceptanceTests/BuildHouseTest.cs index 8a3f08c..026d79e 100644 --- a/Test/ServerTests/AcceptanceTests/BuildHouseTest.cs +++ b/Test/ServerTests/AcceptanceTests/BuildHouseTest.cs @@ -1,5 +1,6 @@ using Domain; using Server.Hubs; +using SharedLibrary; using static Domain.Map; using static ServerTests.Utils; diff --git a/Test/ServerTests/AcceptanceTests/BuyBlockTest.cs b/Test/ServerTests/AcceptanceTests/BuyBlockTest.cs index 9c62c0a..30c7bc6 100644 --- a/Test/ServerTests/AcceptanceTests/BuyBlockTest.cs +++ b/Test/ServerTests/AcceptanceTests/BuyBlockTest.cs @@ -1,5 +1,6 @@ using Domain; using Server.Hubs; +using SharedLibrary; using static Domain.Map; using static ServerTests.Utils; diff --git a/Test/ServerTests/AcceptanceTests/MortgageTest.cs b/Test/ServerTests/AcceptanceTests/MortgageTest.cs index 2d16bed..c5aae1e 100644 --- a/Test/ServerTests/AcceptanceTests/MortgageTest.cs +++ b/Test/ServerTests/AcceptanceTests/MortgageTest.cs @@ -1,5 +1,6 @@ using Domain; using Server.Hubs; +using SharedLibrary; using static Domain.Map; using static ServerTests.Utils; diff --git a/Test/ServerTests/AcceptanceTests/PayTollTest.cs b/Test/ServerTests/AcceptanceTests/PayTollTest.cs index 7da1ffe..0ae6e44 100644 --- a/Test/ServerTests/AcceptanceTests/PayTollTest.cs +++ b/Test/ServerTests/AcceptanceTests/PayTollTest.cs @@ -1,5 +1,6 @@ using Domain; using Server.Hubs; +using SharedLibrary; using static Domain.Map; using static ServerTests.Utils; diff --git a/Test/ServerTests/AcceptanceTests/PlayerJoinGameTest.cs b/Test/ServerTests/AcceptanceTests/PlayerJoinGameTest.cs index ae1f3cf..9c9421d 100644 --- a/Test/ServerTests/AcceptanceTests/PlayerJoinGameTest.cs +++ b/Test/ServerTests/AcceptanceTests/PlayerJoinGameTest.cs @@ -2,8 +2,8 @@ using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.Options; using Server.DataModels; -using Server.Hubs; using Server.Repositories; +using SharedLibrary; using System.Net.Http.Headers; using System.Net.Http.Json; diff --git a/Test/ServerTests/AcceptanceTests/RedeemTest.cs b/Test/ServerTests/AcceptanceTests/RedeemTest.cs index 0195175..970a428 100644 --- a/Test/ServerTests/AcceptanceTests/RedeemTest.cs +++ b/Test/ServerTests/AcceptanceTests/RedeemTest.cs @@ -1,5 +1,6 @@ using Domain; using Server.Hubs; +using SharedLibrary; using static Domain.Map; using static ServerTests.Utils; diff --git a/Test/ServerTests/AcceptanceTests/RollDiceTest.cs b/Test/ServerTests/AcceptanceTests/RollDiceTest.cs index 3347f6d..516e6cd 100644 --- a/Test/ServerTests/AcceptanceTests/RollDiceTest.cs +++ b/Test/ServerTests/AcceptanceTests/RollDiceTest.cs @@ -2,6 +2,7 @@ using Domain; using Domain.Maps; using Server.Hubs; +using SharedLibrary; using static Domain.Map; using static ServerTests.Utils; diff --git a/Test/ServerTests/AcceptanceTests/SelectDirectionTest.cs b/Test/ServerTests/AcceptanceTests/SelectDirectionTest.cs index e516b4f..8dd73e2 100644 --- a/Test/ServerTests/AcceptanceTests/SelectDirectionTest.cs +++ b/Test/ServerTests/AcceptanceTests/SelectDirectionTest.cs @@ -1,6 +1,7 @@ using Application.Common; using Domain; using Server.Hubs; +using SharedLibrary; using static Domain.Map; using static ServerTests.Utils; diff --git a/Test/ServerTests/MonopolyTestServer.cs b/Test/ServerTests/MonopolyTestServer.cs index c159817..b29248c 100644 --- a/Test/ServerTests/MonopolyTestServer.cs +++ b/Test/ServerTests/MonopolyTestServer.cs @@ -9,8 +9,8 @@ using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Server.DataModels; -using Server.Hubs; using Server.Services; +using SharedLibrary; using System.Collections.Concurrent; using System.IdentityModel.Tokens.Jwt; using System.Reflection; diff --git a/Test/ServerTests/Utils.cs b/Test/ServerTests/Utils.cs index 5e15686..0a5fc76 100644 --- a/Test/ServerTests/Utils.cs +++ b/Test/ServerTests/Utils.cs @@ -3,7 +3,7 @@ using Domain.Interfaces; using Domain.Maps; using Moq; -using Server.Hubs; +using SharedLibrary; using static Domain.Map; namespace ServerTests;