This file contains guidelines and commands for agentic coding agents working on the Card Game Simulator repository.
Card Game Simulator is a Unity-based digital platform for playing card games on a virtual tabletop. The project uses C# with Unity Engine and follows specific coding conventions.
Tech Stack:
- Unity 6.3
- C# (.NET Standard)
- Unity Netcode for GameObjects (multiplayer)
- Unity UI System (uGUI) and UI Toolkit
- Newtonsoft.Json for JSON handling
- NUnit for testing
Key Directories:
Assets/Scripts/Cgs/- Main game logicAssets/Scripts/UnityExtensionMethods/- Unity utilitiesAssets/Scripts/FinolDigital.Cgs.Json.Unity/- JSON handlingAssets/Tests/PlayMode/- Unit testsAssets/WebGLSupport/- WebGL compatibilitydocs/- Documentation and game schemas
- Run in Unity Editor: Open project in Unity and press Play
- Build for WebGL: Unity Build Settings → WebGL → Build
- Build for Windows: Unity Build Settings → StandaloneWindows64 → Build
- Run All Tests: In Unity Editor → Window → General → Test Runner → Run All
- Run Single Test: Use Unity Test Runner GUI to select specific test
- Run Tests via Command Line:
# Unity command line testing (requires Unity path) /path/to/Unity -batchmode -runTests -projectPath [ProjectPath] -testResults [ResultFile]
- GitHub Actions: Tests run automatically on PR/merge to develop branch
- Test Coverage: Uses Unity Test Tools Code Coverage package
- Deployment: Automated via GameCI workflows
All C# files must start with the MPL 2.0 license header:
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */- Classes: PascalCase (e.g.,
CardGameManager,PlayController) - Methods: PascalCase (e.g.,
LoadGame,HandleInput) - Constants: PascalCase with descriptive names (e.g.,
LoadErrorMessage,MainMenuSceneIndex) - Properties: PascalCase (e.g.,
IsFocused,WasFocused) - Variables: camelCase (e.g.,
cardGameManager,isFocused) - Private fields: camelCase with underscore prefix (e.g.,
_moveAction,_inputFields)
- Use regions for organizing large classes
- Keep methods focused and under 50 lines when possible
- Use
[RequireComponent(typeof(Component))]for mandatory Unity components - Use
[UsedImplicitly]JetBrains annotation for Unity-serialized fields accessed via reflection
- Use descriptive constant strings for error messages (see
CardGameManager.cs) - Log errors with
Debug.LogError()for critical issues - Use try-catch blocks for file operations and network requests
- Validate inputs at method entry points
- Use
#if UNITY_ANDROID && !UNITY_EDITORfor platform-specific code - Use
usingstatements for disposable Unity objects (UnityWebRequest, etc.) - Implement proper Unity lifecycle methods (Awake, Start, Update, OnDestroy)
- Use ScriptableObject for data containers when appropriate
- Use Unity Events for UI interactions
- Tests are in
Assets/Tests/PlayMode/namespaceTests.PlayMode - Use NUnit framework with
[Test],[SetUp],[UnityTest]attributes - Use
GameObject.Instantiate()for test objects - Clean up test objects in
[TearDown]or useUnityTestattribute - Mock Unity services when needed
- Main code:
Cgs.asmdef - Tests:
PlayMode.asmdef - Utilities:
UnityExtensionMethods.asmdef - JSON handling:
FinolDigital.Cgs.Json.Unity.asmdef
- Use object pooling for frequently instantiated objects
- Avoid expensive operations in Update() methods
- Use coroutines for async operations
- Optimize UI updates with dirty flags
- Use Unity's Profiler for performance analysis
- Use Unity Netcode for GameObjects
- Implement
CgsNetPlayablebase class for networked objects - Use NetworkVariables for synchronized data
- Handle client/server authority properly
- Test multiplayer functionality thoroughly
- Main development branch:
develop - PRs target
mainbranch - Use descriptive commit messages
- Include tests for new features
- Unity Documentation: https://docs.unity3d.com/
- Unity Netcode: https://docs-multiplayer.unity3d.com/
- NUnit Documentation: https://nunit.org/
- Project Wiki: https://github.com/finol-digital/Card-Game-Simulator/wiki