18 changed files with 482 additions and 418 deletions
@ -1,418 +1,5 @@ |
|||
# ---> VisualStudio |
|||
## Ignore Visual Studio temporary files, build results, and |
|||
## files generated by popular Visual Studio add-ons. |
|||
## |
|||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore |
|||
|
|||
# User-specific files |
|||
*.rsuser |
|||
*.suo |
|||
*.user |
|||
*.userosscache |
|||
*.sln.docstates |
|||
|
|||
# User-specific files (MonoDevelop/Xamarin Studio) |
|||
*.userprefs |
|||
|
|||
# Mono auto generated files |
|||
mono_crash.* |
|||
|
|||
# Build results |
|||
[Dd]ebug/ |
|||
[Dd]ebugPublic/ |
|||
[Rr]elease/ |
|||
[Rr]eleases/ |
|||
x64/ |
|||
x86/ |
|||
[Ww][Ii][Nn]32/ |
|||
[Aa][Rr][Mm]/ |
|||
[Aa][Rr][Mm]64/ |
|||
bld/ |
|||
[Bb]in/ |
|||
[Oo]bj/ |
|||
[Ll]og/ |
|||
[Ll]ogs/ |
|||
|
|||
# Visual Studio 2015/2017 cache/options directory |
|||
.vs/ |
|||
# Uncomment if you have tasks that create the project's static files in wwwroot |
|||
#wwwroot/ |
|||
|
|||
# Visual Studio 2017 auto generated files |
|||
Generated\ Files/ |
|||
|
|||
# MSTest test Results |
|||
[Tt]est[Rr]esult*/ |
|||
[Bb]uild[Ll]og.* |
|||
|
|||
# NUnit |
|||
*.VisualState.xml |
|||
TestResult.xml |
|||
nunit-*.xml |
|||
|
|||
# Build Results of an ATL Project |
|||
[Dd]ebugPS/ |
|||
[Rr]eleasePS/ |
|||
dlldata.c |
|||
|
|||
# Benchmark Results |
|||
BenchmarkDotNet.Artifacts/ |
|||
|
|||
# .NET Core |
|||
project.lock.json |
|||
project.fragment.lock.json |
|||
artifacts/ |
|||
|
|||
# ASP.NET Scaffolding |
|||
ScaffoldingReadMe.txt |
|||
|
|||
# StyleCop |
|||
StyleCopReport.xml |
|||
|
|||
# Files built by Visual Studio |
|||
*_i.c |
|||
*_p.c |
|||
*_h.h |
|||
*.ilk |
|||
*.meta |
|||
*.obj |
|||
*.iobj |
|||
*.pch |
|||
*.pdb |
|||
*.ipdb |
|||
*.pgc |
|||
*.pgd |
|||
*.rsp |
|||
*.sbr |
|||
*.tlb |
|||
*.tli |
|||
*.tlh |
|||
*.tmp |
|||
*.tmp_proj |
|||
*_wpftmp.csproj |
|||
*.log |
|||
*.tlog |
|||
*.vspscc |
|||
*.vssscc |
|||
.builds |
|||
*.pidb |
|||
*.svclog |
|||
*.scc |
|||
|
|||
# Chutzpah Test files |
|||
_Chutzpah* |
|||
|
|||
# Visual C++ cache files |
|||
ipch/ |
|||
*.aps |
|||
*.ncb |
|||
*.opendb |
|||
*.opensdf |
|||
*.sdf |
|||
*.cachefile |
|||
*.VC.db |
|||
*.VC.VC.opendb |
|||
|
|||
# Visual Studio profiler |
|||
*.psess |
|||
*.vsp |
|||
*.vspx |
|||
*.sap |
|||
|
|||
# Visual Studio Trace Files |
|||
*.e2e |
|||
|
|||
# TFS 2012 Local Workspace |
|||
$tf/ |
|||
|
|||
# Guidance Automation Toolkit |
|||
*.gpState |
|||
|
|||
# ReSharper is a .NET coding add-in |
|||
_ReSharper*/ |
|||
*.[Rr]e[Ss]harper |
|||
*.DotSettings.user |
|||
|
|||
# TeamCity is a build add-in |
|||
_TeamCity* |
|||
|
|||
# DotCover is a Code Coverage Tool |
|||
*.dotCover |
|||
|
|||
# AxoCover is a Code Coverage Tool |
|||
.axoCover/* |
|||
!.axoCover/settings.json |
|||
|
|||
# Coverlet is a free, cross platform Code Coverage Tool |
|||
coverage*.json |
|||
coverage*.xml |
|||
coverage*.info |
|||
|
|||
# Visual Studio code coverage results |
|||
*.coverage |
|||
*.coveragexml |
|||
|
|||
# NCrunch |
|||
_NCrunch_* |
|||
.*crunch*.local.xml |
|||
nCrunchTemp_* |
|||
|
|||
# MightyMoose |
|||
*.mm.* |
|||
AutoTest.Net/ |
|||
|
|||
# Web workbench (sass) |
|||
.sass-cache/ |
|||
|
|||
# Installshield output folder |
|||
[Ee]xpress/ |
|||
|
|||
# DocProject is a documentation generator add-in |
|||
DocProject/buildhelp/ |
|||
DocProject/Help/*.HxT |
|||
DocProject/Help/*.HxC |
|||
DocProject/Help/*.hhc |
|||
DocProject/Help/*.hhk |
|||
DocProject/Help/*.hhp |
|||
DocProject/Help/Html2 |
|||
DocProject/Help/html |
|||
|
|||
# Click-Once directory |
|||
publish/ |
|||
|
|||
# Publish Web Output |
|||
*.[Pp]ublish.xml |
|||
*.azurePubxml |
|||
# Note: Comment the next line if you want to checkin your web deploy settings, |
|||
# but database connection strings (with potential passwords) will be unencrypted |
|||
*.pubxml |
|||
*.publishproj |
|||
|
|||
# Microsoft Azure Web App publish settings. Comment the next line if you want to |
|||
# checkin your Azure Web App publish settings, but sensitive information contained |
|||
# in these scripts will be unencrypted |
|||
PublishScripts/ |
|||
|
|||
# NuGet Packages |
|||
*.nupkg |
|||
# NuGet Symbol Packages |
|||
*.snupkg |
|||
# The packages folder can be ignored because of Package Restore |
|||
**/[Pp]ackages/* |
|||
# except build/, which is used as an MSBuild target. |
|||
!**/[Pp]ackages/build/ |
|||
# Uncomment if necessary however generally it will be regenerated when needed |
|||
#!**/[Pp]ackages/repositories.config |
|||
# NuGet v3's project.json files produces more ignorable files |
|||
*.nuget.props |
|||
*.nuget.targets |
|||
|
|||
# Nuget personal access tokens and Credentials |
|||
nuget.config |
|||
|
|||
# Microsoft Azure Build Output |
|||
csx/ |
|||
*.build.csdef |
|||
|
|||
# Microsoft Azure Emulator |
|||
ecf/ |
|||
rcf/ |
|||
|
|||
# Windows Store app package directories and files |
|||
AppPackages/ |
|||
BundleArtifacts/ |
|||
Package.StoreAssociation.xml |
|||
_pkginfo.txt |
|||
*.appx |
|||
*.appxbundle |
|||
*.appxupload |
|||
|
|||
# Visual Studio cache files |
|||
# files ending in .cache can be ignored |
|||
*.[Cc]ache |
|||
# but keep track of directories ending in .cache |
|||
!?*.[Cc]ache/ |
|||
|
|||
# Others |
|||
ClientBin/ |
|||
~$* |
|||
*~ |
|||
*.dbmdl |
|||
*.dbproj.schemaview |
|||
*.jfm |
|||
*.pfx |
|||
*.publishsettings |
|||
orleans.codegen.cs |
|||
|
|||
# Including strong name files can present a security risk |
|||
# (https://github.com/github/gitignore/pull/2483#issue-259490424) |
|||
#*.snk |
|||
|
|||
# Since there are multiple workflows, uncomment next line to ignore bower_components |
|||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) |
|||
#bower_components/ |
|||
|
|||
# RIA/Silverlight projects |
|||
Generated_Code/ |
|||
|
|||
# Backup & report files from converting an old project file |
|||
# to a newer Visual Studio version. Backup files are not needed, |
|||
# because we have git ;-) |
|||
_UpgradeReport_Files/ |
|||
Backup*/ |
|||
UpgradeLog*.XML |
|||
UpgradeLog*.htm |
|||
ServiceFabricBackup/ |
|||
*.rptproj.bak |
|||
|
|||
# SQL Server files |
|||
*.mdf |
|||
*.ldf |
|||
*.ndf |
|||
|
|||
# Business Intelligence projects |
|||
*.rdl.data |
|||
*.bim.layout |
|||
*.bim_*.settings |
|||
*.rptproj.rsuser |
|||
*- [Bb]ackup.rdl |
|||
*- [Bb]ackup ([0-9]).rdl |
|||
*- [Bb]ackup ([0-9][0-9]).rdl |
|||
|
|||
# Microsoft Fakes |
|||
FakesAssemblies/ |
|||
|
|||
# GhostDoc plugin setting file |
|||
*.GhostDoc.xml |
|||
|
|||
# Node.js Tools for Visual Studio |
|||
.ntvs_analysis.dat |
|||
node_modules/ |
|||
|
|||
# Visual Studio 6 build log |
|||
*.plg |
|||
|
|||
# Visual Studio 6 workspace options file |
|||
*.opt |
|||
|
|||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) |
|||
*.vbw |
|||
|
|||
# Visual Studio LightSwitch build output |
|||
**/*.HTMLClient/GeneratedArtifacts |
|||
**/*.DesktopClient/GeneratedArtifacts |
|||
**/*.DesktopClient/ModelManifest.xml |
|||
**/*.Server/GeneratedArtifacts |
|||
**/*.Server/ModelManifest.xml |
|||
_Pvt_Extensions |
|||
|
|||
# Paket dependency manager |
|||
.paket/paket.exe |
|||
paket-files/ |
|||
|
|||
# FAKE - F# Make |
|||
.fake/ |
|||
|
|||
# CodeRush personal settings |
|||
.cr/personal |
|||
|
|||
# Python Tools for Visual Studio (PTVS) |
|||
__pycache__/ |
|||
*.pyc |
|||
|
|||
# Cake - Uncomment if you are using it |
|||
# tools/** |
|||
# !tools/packages.config |
|||
|
|||
# Tabs Studio |
|||
*.tss |
|||
|
|||
# Telerik's JustMock configuration file |
|||
*.jmconfig |
|||
|
|||
# BizTalk build output |
|||
*.btp.cs |
|||
*.btm.cs |
|||
*.odx.cs |
|||
*.xsd.cs |
|||
|
|||
# OpenCover UI analysis results |
|||
OpenCover/ |
|||
|
|||
# Azure Stream Analytics local run output |
|||
ASALocalRun/ |
|||
|
|||
# MSBuild Binary and Structured Log |
|||
*.binlog |
|||
|
|||
# NVidia Nsight GPU debugger configuration file |
|||
*.nvuser |
|||
|
|||
# MFractors (Xamarin productivity tool) working folder |
|||
.mfractor/ |
|||
|
|||
# Local History for Visual Studio |
|||
.localhistory/ |
|||
|
|||
# BeatPulse healthcheck temp database |
|||
healthchecksdb |
|||
|
|||
# Backup folder for Package Reference Convert tool in Visual Studio 2017 |
|||
MigrationBackup/ |
|||
|
|||
# Ionide (cross platform F# VS Code tools) working folder |
|||
.ionide/ |
|||
|
|||
# Fody - auto-generated XML schema |
|||
FodyWeavers.xsd |
|||
|
|||
# VS Code files for those working on multiple tools |
|||
.vscode/* |
|||
!.vscode/settings.json |
|||
!.vscode/tasks.json |
|||
!.vscode/launch.json |
|||
!.vscode/extensions.json |
|||
*.code-workspace |
|||
|
|||
# Local History for Visual Studio Code |
|||
.history/ |
|||
|
|||
# Windows Installer files from build outputs |
|||
*.cab |
|||
*.msi |
|||
*.msix |
|||
*.msm |
|||
*.msp |
|||
|
|||
# JetBrains Rider |
|||
.idea/ |
|||
*.sln.iml |
|||
|
|||
# ---> macOS |
|||
# General |
|||
.DS_Store |
|||
.AppleDouble |
|||
.LSOverride |
|||
|
|||
# Icon must end with two \r |
|||
Icon |
|||
|
|||
# Thumbnails |
|||
._* |
|||
|
|||
# Files that might appear in the root of a volume |
|||
.DocumentRevisions-V100 |
|||
.fseventsd |
|||
.Spotlight-V100 |
|||
.TemporaryItems |
|||
.Trashes |
|||
.VolumeIcon.icns |
|||
.com.apple.timemachine.donotpresent |
|||
|
|||
# Directories potentially created on remote AFP share |
|||
.AppleDB |
|||
.AppleDesktop |
|||
Network Trash Folder |
|||
Temporary Items |
|||
.apdisk |
|||
|
|||
bin/ |
|||
obj/ |
|||
/packages/ |
|||
riderModule.iml |
|||
/_ReSharper.Caches/ |
|||
@ -0,0 +1,4 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" /> |
|||
</project> |
|||
@ -0,0 +1,8 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="UserContentModel"> |
|||
<attachedFolders /> |
|||
<explicitIncludes /> |
|||
<explicitExcludes /> |
|||
</component> |
|||
</project> |
|||
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="RiderProjectSettingsUpdater"> |
|||
<option name="vcsConfiguration" value="2" /> |
|||
</component> |
|||
</project> |
|||
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="VcsDirectoryMappings"> |
|||
<mapping directory="$PROJECT_DIR$" vcs="Git" /> |
|||
</component> |
|||
</project> |
|||
@ -0,0 +1,123 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="AutoGeneratedRunConfigurationManager"> |
|||
<projectFile profileName="ooya.ga_api">ooya.ga_api.csproj</projectFile> |
|||
<projectFile profileName="IIS Express">ooya.ga_api.csproj</projectFile> |
|||
</component> |
|||
<component name="AutoImportSettings"> |
|||
<option name="autoReloadType" value="SELECTIVE" /> |
|||
</component> |
|||
<component name="ChangeListManager"> |
|||
<list default="true" id="97a4fbc7-90e8-4882-8129-7938d939c953" name="Changes" comment=""> |
|||
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/.idea/.idea.ooya.ga_api/.idea/encodings.xml" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/.idea/.idea.ooya.ga_api/.idea/indexLayout.xml" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/.idea/.idea.ooya.ga_api/.idea/projectSettingsUpdater.xml" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/.idea/.idea.ooya.ga_api/.idea/vcs.xml" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/Controllers/ApiController.cs" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/Model/Game.cs" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/Model/GameDto.cs" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/Model/Mapper.cs" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/Model/Witch.cs" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/Model/WitchDto.cs" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/Program.cs" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/Properties/launchSettings.json" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/appsettings.Development.json" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/appsettings.json" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/ooya.ga_api.csproj" afterDir="false" /> |
|||
<change afterPath="$PROJECT_DIR$/ooya.ga_api.sln" afterDir="false" /> |
|||
</list> |
|||
<option name="SHOW_DIALOG" value="false" /> |
|||
<option name="HIGHLIGHT_CONFLICTS" value="true" /> |
|||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> |
|||
<option name="LAST_RESOLUTION" value="IGNORE" /> |
|||
</component> |
|||
<component name="MarkdownSettingsMigration"> |
|||
<option name="stateVersion" value="1" /> |
|||
</component> |
|||
<component name="ProjectId" id="24iidujCwn0qJ7iYpIOnKboQGVW" /> |
|||
<component name="ProjectLevelVcsManager" settingsEditedManually="true"> |
|||
<ConfirmationsSetting value="2" id="Add" /> |
|||
</component> |
|||
<component name="ProjectViewState"> |
|||
<option name="hideEmptyMiddlePackages" value="true" /> |
|||
<option name="showLibraryContents" value="true" /> |
|||
</component> |
|||
<component name="PropertiesComponent"> |
|||
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" /> |
|||
<property name="ASKED_SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> |
|||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> |
|||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> |
|||
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> |
|||
<property name="WebServerToolWindowFactoryState" value="false" /> |
|||
<property name="node.js.detected.package.eslint" value="true" /> |
|||
<property name="node.js.detected.package.tslint" value="true" /> |
|||
<property name="node.js.selected.package.eslint" value="(autodetect)" /> |
|||
<property name="node.js.selected.package.tslint" value="(autodetect)" /> |
|||
<property name="settings.editor.selected.configurable" value="project.propVCSSupport.CommitDialog" /> |
|||
<property name="vue.rearranger.settings.migration" value="true" /> |
|||
</component> |
|||
<component name="RunManager" selected=".NET Launch Settings Profile.ooya.ga_api"> |
|||
<configuration name="ooya.ga_api" type="LaunchSettings" factoryName=".NET Launch Settings Profile"> |
|||
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/ooya.ga_api.csproj" /> |
|||
<option name="LAUNCH_PROFILE_TFM" value="net6.0" /> |
|||
<option name="LAUNCH_PROFILE_NAME" value="ooya.ga_api" /> |
|||
<option name="USE_EXTERNAL_CONSOLE" value="0" /> |
|||
<option name="USE_MONO" value="0" /> |
|||
<option name="RUNTIME_ARGUMENTS" value="" /> |
|||
<option name="GENERATE_APPLICATIONHOST_CONFIG" value="1" /> |
|||
<option name="SHOW_IIS_EXPRESS_OUTPUT" value="0" /> |
|||
<option name="SEND_DEBUG_REQUEST" value="1" /> |
|||
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" /> |
|||
<method v="2"> |
|||
<option name="Build" /> |
|||
</method> |
|||
</configuration> |
|||
<configuration name="ooya.ga_api: IIS Express" type="LaunchSettings" factoryName=".NET Launch Settings Profile"> |
|||
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/ooya.ga_api.csproj" /> |
|||
<option name="LAUNCH_PROFILE_TFM" value="net6.0" /> |
|||
<option name="LAUNCH_PROFILE_NAME" value="IIS Express" /> |
|||
<option name="USE_EXTERNAL_CONSOLE" value="0" /> |
|||
<option name="USE_MONO" value="0" /> |
|||
<option name="RUNTIME_ARGUMENTS" value="" /> |
|||
<option name="GENERATE_APPLICATIONHOST_CONFIG" value="1" /> |
|||
<option name="SHOW_IIS_EXPRESS_OUTPUT" value="0" /> |
|||
<option name="SEND_DEBUG_REQUEST" value="1" /> |
|||
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" /> |
|||
<method v="2"> |
|||
<option name="Build" /> |
|||
</method> |
|||
</configuration> |
|||
</component> |
|||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> |
|||
<component name="TaskManager"> |
|||
<task active="true" id="Default" summary="Default task"> |
|||
<changelist id="97a4fbc7-90e8-4882-8129-7938d939c953" name="Changes" comment="" /> |
|||
<created>1644119899867</created> |
|||
<option name="number" value="Default" /> |
|||
<option name="presentableId" value="Default" /> |
|||
<updated>1644119899867</updated> |
|||
<workItem from="1644119909814" duration="2390000" /> |
|||
</task> |
|||
<servers /> |
|||
</component> |
|||
<component name="TypeScriptGeneratedFilesManager"> |
|||
<option name="version" value="3" /> |
|||
</component> |
|||
<component name="Vcs.Log.Tabs.Properties"> |
|||
<option name="TAB_STATES"> |
|||
<map> |
|||
<entry key="MAIN"> |
|||
<value> |
|||
<State /> |
|||
</value> |
|||
</entry> |
|||
</map> |
|||
</option> |
|||
</component> |
|||
<component name="VcsManagerConfiguration"> |
|||
<option name="CHECK_NEW_TODO" value="false" /> |
|||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" /> |
|||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" /> |
|||
</component> |
|||
</project> |
|||
@ -0,0 +1,81 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace ooya.ga_api.Controllers; |
|||
|
|||
[ApiController] |
|||
[Microsoft.AspNetCore.Mvc.Route("/api/v1")] |
|||
public class ApiController : ControllerBase |
|||
{ |
|||
private static readonly Random Random = new Random(); |
|||
private static readonly List<Game> GameList = new List<Game>(); |
|||
|
|||
private readonly ILogger<ApiController> _logger; |
|||
|
|||
public ApiController(ILogger<ApiController> logger) |
|||
{ |
|||
_logger = logger; |
|||
} |
|||
|
|||
[HttpGet("version", Name = "version", Order = 1)] |
|||
public string Version() |
|||
{ |
|||
return "1.0.0"; |
|||
} |
|||
|
|||
[HttpGet("game", Name = "game", Order = 2)] |
|||
public GameDto NewGame() |
|||
{ |
|||
Game pGame = h_NewGame(0); |
|||
GameList.Add(pGame); |
|||
return Mapper.ToGameDto(pGame); |
|||
} |
|||
|
|||
[HttpGet("turn", Name = "turn", Order = 3)] |
|||
public GameDto? Turn( |
|||
string gameGuid, |
|||
string witchGuid |
|||
) |
|||
{ |
|||
Game pGame = GameList.FirstOrDefault(p => p.Guid == gameGuid); |
|||
if (pGame == null) return null; |
|||
Witch pWitch = pGame.Witches.FirstOrDefault(p => p.Guid == witchGuid); |
|||
if (pWitch == null) return null; |
|||
if (pWitch.FlagReal) |
|||
{ |
|||
Game pNewGame = h_NewGame(pGame.Score + pGame.Witches.Count()); |
|||
GameList.Add(pNewGame); |
|||
return Mapper.ToGameDto(pNewGame); |
|||
} |
|||
else |
|||
{ |
|||
pGame.Score--; |
|||
return Mapper.ToGameDto(pGame); |
|||
} |
|||
} |
|||
|
|||
#region private methods
|
|||
|
|||
private Game h_NewGame(int iScore) |
|||
{ |
|||
Game pGame = new Game(iScore) |
|||
{ |
|||
Witches = h_CreateWitches(Random.Next(2, 5)) |
|||
}; |
|||
return pGame; |
|||
} |
|||
|
|||
private IEnumerable<Witch> h_CreateWitches(int count) |
|||
{ |
|||
List<Witch> witches = new List<Witch>(); |
|||
for (int ii = 0; ii < count; ii++) |
|||
{ |
|||
witches.Add(new Witch(ii)); |
|||
} |
|||
|
|||
int iIndex = Random.Next(0, count); |
|||
witches[iIndex].FlagReal = true; |
|||
return witches; |
|||
} |
|||
|
|||
#endregion
|
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace ooya.ga_api; |
|||
|
|||
public class Game |
|||
{ |
|||
/// <summary>
|
|||
/// Текущая дата и время
|
|||
/// </summary>
|
|||
[Required] |
|||
public DateTime Date { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Идентификатор игры
|
|||
/// </summary>
|
|||
[Required] |
|||
public string Guid { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Количество очков
|
|||
/// </summary>
|
|||
[Required] |
|||
public int Score { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Ведьмы раунда
|
|||
/// </summary>
|
|||
[Required] |
|||
public IEnumerable<Witch> Witches { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Конструктор
|
|||
/// </summary>
|
|||
/// <param name="score">первоначальное количество очков</param>
|
|||
public Game(int score = 0) |
|||
{ |
|||
Date = DateTime.Now; |
|||
Score = score; |
|||
Witches = new List<Witch>(); |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
namespace ooya.ga_api; |
|||
|
|||
public class GameDto |
|||
{ |
|||
/// <summary>
|
|||
/// Текущая дата и время
|
|||
/// </summary>
|
|||
public DateTime Date { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Идентификатор игры
|
|||
/// </summary>
|
|||
public string Guid { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Количество очков
|
|||
/// </summary>
|
|||
public int Score { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Ведьмы раунда
|
|||
/// </summary>
|
|||
public IEnumerable<WitchDto> Witches { get; set; } |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
namespace ooya.ga_api; |
|||
|
|||
public static class Mapper |
|||
{ |
|||
/// <summary>
|
|||
/// Для передачи в сторону пользователя
|
|||
/// </summary>
|
|||
/// <param name="pGame"></param>
|
|||
/// <returns></returns>
|
|||
public static GameDto ToGameDto(Game pGame) |
|||
{ |
|||
GameDto pGameDto = new GameDto(); |
|||
pGameDto.Guid = pGame.Guid; |
|||
pGameDto.Date = pGame.Date; |
|||
pGameDto.Score = pGame.Score; |
|||
pGameDto.Witches = pGame.Witches.Select(p => ToWitchDto(p)); |
|||
return pGameDto; |
|||
} |
|||
/// <summary>
|
|||
/// Для передачи в сторону пользователя
|
|||
/// </summary>
|
|||
/// <param name="pWitch"></param>
|
|||
/// <returns></returns>
|
|||
public static WitchDto ToWitchDto(Witch pWitch) |
|||
{ |
|||
WitchDto pWitchDto = new WitchDto(); |
|||
pWitchDto.Guid = pWitch.Guid; |
|||
pWitchDto.Position = pWitch.Position; |
|||
return pWitchDto; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace ooya.ga_api; |
|||
|
|||
public class Witch |
|||
{ |
|||
/// <summary>
|
|||
/// Идентификатор ведьмы
|
|||
/// </summary>
|
|||
[Required] |
|||
public string Guid { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Является ли настоящей
|
|||
/// </summary>
|
|||
[Required] |
|||
public bool FlagReal { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Позиция ведьмы
|
|||
/// </summary>
|
|||
[Required] |
|||
public int Position { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// Конструктор
|
|||
/// </summary>
|
|||
/// <param name="position"></param>
|
|||
public Witch(int position) |
|||
{ |
|||
Guid = (new Guid()).ToString("N"); |
|||
Position = position; |
|||
FlagReal = false; |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
namespace ooya.ga_api; |
|||
|
|||
public class WitchDto |
|||
{ |
|||
/// <summary>
|
|||
/// Идентификатор ведьмы
|
|||
/// </summary>
|
|||
public string Guid { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Позиция ведьмы
|
|||
/// </summary>
|
|||
public int Position { get; set; } |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
var builder = WebApplication.CreateBuilder(args); |
|||
|
|||
// Add services to the container.
|
|||
|
|||
builder.Services.AddControllers(); |
|||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|||
builder.Services.AddEndpointsApiExplorer(); |
|||
builder.Services.AddSwaggerGen(); |
|||
|
|||
var app = builder.Build(); |
|||
|
|||
// Configure the HTTP request pipeline.
|
|||
if (app.Environment.IsDevelopment()) |
|||
{ |
|||
app.UseSwagger(); |
|||
app.UseSwaggerUI(); |
|||
} |
|||
|
|||
app.UseHttpsRedirection(); |
|||
|
|||
app.UseAuthorization(); |
|||
|
|||
app.MapControllers(); |
|||
|
|||
app.Run(); |
|||
@ -0,0 +1,31 @@ |
|||
{ |
|||
"$schema": "https://json.schemastore.org/launchsettings.json", |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:24043", |
|||
"sslPort": 44355 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"ooya.ga_api": { |
|||
"commandName": "Project", |
|||
"dotnetRunMessages": true, |
|||
"launchBrowser": true, |
|||
"launchUrl": "swagger", |
|||
"applicationUrl": "https://localhost:7115;http://localhost:5001", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"launchUrl": "swagger", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft.AspNetCore": "Warning" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft.AspNetCore": "Warning" |
|||
} |
|||
}, |
|||
"AllowedHosts": "*" |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<Nullable>enable</Nullable> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,16 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ooya.ga_api", "ooya.ga_api.csproj", "{8046F827-FD8E-4F3A-9921-ADC42F935B12}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{8046F827-FD8E-4F3A-9921-ADC42F935B12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{8046F827-FD8E-4F3A-9921-ADC42F935B12}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{8046F827-FD8E-4F3A-9921-ADC42F935B12}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{8046F827-FD8E-4F3A-9921-ADC42F935B12}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
EndGlobal |
|||
Loading…
Reference in new issue