Genesis Game Server Project Setup
This commit is contained in:
274
.gitignore
vendored
Normal file
274
.gitignore
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/aspnetcore
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=aspnetcore
|
||||
|
||||
### ASPNETCore ###
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# DNX
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.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
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# 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
|
||||
# TODO: 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
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# 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
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# 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/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/aspnetcore
|
||||
3
GameServer.slnx
Normal file
3
GameServer.slnx
Normal file
@@ -0,0 +1,3 @@
|
||||
<Solution>
|
||||
<Project Path="GameServer/GameServer.csproj" />
|
||||
</Solution>
|
||||
35
GameServer/Controllers/CharacterController.cs
Normal file
35
GameServer/Controllers/CharacterController.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using GameServer.Data; // DbContext가 있는 폴더
|
||||
using GameServer.Models; // Model이 있는 폴더
|
||||
|
||||
namespace GameServer.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("myGame")] // 접속 주소: /myGame
|
||||
public class CharacterController : ControllerBase
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
// DB 연결 도구(Context)를 가져옵니다.
|
||||
public CharacterController(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// 플레이어블 캐릭터 목록
|
||||
[HttpGet("playableCharacters")]
|
||||
public async Task<IActionResult> GetPlayableCharacters()
|
||||
{
|
||||
List<CharacterModel> list = await _context.Characters
|
||||
.Where(x => x.CharacterType == "PLAYABLE")
|
||||
.ToListAsync();
|
||||
|
||||
return Ok(new ApiResponse<List<CharacterModel>>
|
||||
{
|
||||
Data = list,
|
||||
Count = list.Count
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
62
GameServer/Controllers/UserController.cs
Normal file
62
GameServer/Controllers/UserController.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using GameServer.Data; // DbContext가 있는 폴더
|
||||
using GameServer.Models; // Model이 있는 폴더
|
||||
|
||||
namespace GameServer.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("myGame")] // 접속 주소: /myGame
|
||||
public class UserController : ControllerBase
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
// DB 연결 도구(Context)를 가져옵니다.
|
||||
public UserController(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// 모든 유저들의 캐릭터 목록
|
||||
[HttpGet("userCharacters")]
|
||||
public async Task<IActionResult> GetAllUserCharacters()
|
||||
{
|
||||
List<UserCharacterModel> list = await _context.UserCharacters.ToListAsync();
|
||||
|
||||
return Ok(new ApiResponse<List<UserCharacterModel>>
|
||||
{
|
||||
Data = list,
|
||||
Count = list.Count
|
||||
});
|
||||
}
|
||||
|
||||
// 특정 유저의 캐릭터 목록
|
||||
[HttpGet("userCharacters/{user_no}")]
|
||||
public async Task<IActionResult> GetUserCharacters(int user_no)
|
||||
{
|
||||
List<UserCharacterModel> list = await _context.UserCharacters
|
||||
.Where(x => x.UserNo == user_no)
|
||||
.ToListAsync();
|
||||
|
||||
return Ok(new ApiResponse<List<UserCharacterModel>>
|
||||
{
|
||||
Data = list,
|
||||
Count = list.Count
|
||||
});
|
||||
}
|
||||
|
||||
// 새 캐릭터 저장하기
|
||||
[HttpPost("create")]
|
||||
public async Task<IActionResult> CreatePlayer([FromBody] UserCharacterModel newUserCharacter)
|
||||
{
|
||||
_context.UserCharacters.Add(newUserCharacter);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Ok(new ApiResponse<UserCharacterModel>
|
||||
{
|
||||
Data = newUserCharacter,
|
||||
Message = "캐릭터 생성 완료!"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
28
GameServer/Controllers/WeatherForecastController.cs
Normal file
28
GameServer/Controllers/WeatherForecastController.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace GameServer.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("myGame")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
// 서버 메모리에 임시로 저장할 데이터 (나중에 DB로 바꿀 부분)
|
||||
private static int _tempData = 100;
|
||||
|
||||
// 데이터 로드
|
||||
[HttpGet("data")]
|
||||
public IActionResult GetCores()
|
||||
{
|
||||
// 유니티에게 JSON 형태로 데이터를 보냄
|
||||
return Ok(new { data = _tempData, message = "데이터 로드 성공!" });
|
||||
}
|
||||
|
||||
// 데이터 수정
|
||||
[HttpPost("add-data")]
|
||||
public IActionResult AddCore([FromBody] int value)
|
||||
{
|
||||
_tempData = value;
|
||||
return Ok(new { data = _tempData, message = $"{value}로 데이터 수정 완료!" });
|
||||
}
|
||||
}
|
||||
}
|
||||
15
GameServer/Data/AppDbContext.cs
Normal file
15
GameServer/Data/AppDbContext.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using GameServer.Models;
|
||||
|
||||
namespace GameServer.Data
|
||||
{
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
|
||||
{
|
||||
|
||||
}
|
||||
public DbSet<UserCharacterModel> UserCharacters { get; set; }
|
||||
public DbSet<CharacterModel> Characters { get; set; }
|
||||
}
|
||||
}
|
||||
18
GameServer/GameServer.csproj
Normal file
18
GameServer/GameServer.csproj
Normal file
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.13">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0" />
|
||||
<PackageReference Include="Scalar.AspNetCore" Version="2.13.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
6
GameServer/GameServer.http
Normal file
6
GameServer/GameServer.http
Normal file
@@ -0,0 +1,6 @@
|
||||
@GameServer_HostAddress = http://localhost:5281
|
||||
|
||||
GET {{GameServer_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
9
GameServer/Models/ApiResponse.cs
Normal file
9
GameServer/Models/ApiResponse.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace GameServer.Models
|
||||
{
|
||||
public class ApiResponse<T>
|
||||
{
|
||||
public T? Data { get; set; } // 실제 데이터 (단일 객체 혹은 리스트)
|
||||
public int? Count { get; set; } // 배열일 경우 개수 (선택사항)
|
||||
public string Message { get; set; } = "Success";
|
||||
}
|
||||
}
|
||||
17
GameServer/Models/CharacterModel.cs
Normal file
17
GameServer/Models/CharacterModel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace GameServer.Models
|
||||
{
|
||||
[Table("tb_character")]
|
||||
public class CharacterModel
|
||||
{
|
||||
[Key]
|
||||
[Column("character_code")]
|
||||
public string CharacterCode { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[Column("character_type")]
|
||||
public string CharacterType { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
39
GameServer/Models/UserCharacterModel.cs
Normal file
39
GameServer/Models/UserCharacterModel.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace GameServer.Models
|
||||
{
|
||||
[Table("tb_user_characters")]
|
||||
public class UserCharacterModel
|
||||
{
|
||||
[Key]
|
||||
[Column("user_character_no")]
|
||||
public int UserCharacterNo { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("user_no")]
|
||||
public int UserNo { get; set; } = 0;
|
||||
|
||||
[Column("character_code")]
|
||||
public string CharacterCode { get; set; } = string.Empty;
|
||||
|
||||
[Column("lv")]
|
||||
public int Lv { get; set; } = 0;
|
||||
|
||||
[Column("str_stat")]
|
||||
public int StrStat { get; set; } = 0;
|
||||
|
||||
[Column("int_stat")]
|
||||
public int IntStat { get; set; } = 0;
|
||||
|
||||
[Column("max_hp")]
|
||||
public int MaxHp { get; set; } = 0;
|
||||
|
||||
[Column("max_mp")]
|
||||
public int MaxMp { get; set; } = 0;
|
||||
|
||||
[Column("default_control")]
|
||||
public bool DefaultControl { get; set; } = false;
|
||||
|
||||
}
|
||||
}
|
||||
29
GameServer/Program.cs
Normal file
29
GameServer/Program.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using GameServer.Data;
|
||||
using Scalar.AspNetCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// appsettings.json에서 연결 문자열(Connection String) 가져오기
|
||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
|
||||
|
||||
// MariaDB(Pomelo) 엔진 등록
|
||||
builder.Services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
app.MapScalarApiReference();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
23
GameServer/Properties/launchSettings.json
Normal file
23
GameServer/Properties/launchSettings.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5281",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://localhost:7134;http://localhost:5281",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
GameServer/WeatherForecast.cs
Normal file
13
GameServer/WeatherForecast.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace GameServer
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
||||
8
GameServer/appsettings.Development.json
Normal file
8
GameServer/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
12
GameServer/appsettings.json
Normal file
12
GameServer/appsettings.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=nackjoonpc.iptime.org;Port=3363;Database=myGame;Uid=root;Pwd=!skrwns8023!;"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user