{"id":31632735,"url":"https://github.com/cod-e-codes/cardgame","last_synced_at":"2026-05-16T11:32:06.885Z","repository":{"id":317571195,"uuid":"1067989370","full_name":"Cod-e-Codes/CardGame","owner":"Cod-e-Codes","description":"A turn-based card game built with Love2D featuring AI opponent, drag-and-drop gameplay, and comprehensive testing. Includes modular architecture with scene management, animation system, and responsive UI layout.","archived":false,"fork":false,"pushed_at":"2025-10-01T17:51:02.000Z","size":84,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-01T19:22:38.690Z","etag":null,"topics":["ai","animation","card-game","drag-and-drop","game-development","love2d","lua","modular-architecture","scene-management","testing","turn-based","ui-layout"],"latest_commit_sha":null,"homepage":"https://github.com/Cod-e-Codes/CardGame","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cod-e-Codes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-01T17:27:14.000Z","updated_at":"2025-10-01T17:51:06.000Z","dependencies_parsed_at":"2025-10-01T19:22:41.767Z","dependency_job_id":"6af23bca-3c76-4e68-9ecc-1d6fc86c9917","html_url":"https://github.com/Cod-e-Codes/CardGame","commit_stats":null,"previous_names":["cod-e-codes/cardgame"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Cod-e-Codes/CardGame","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cod-e-Codes%2FCardGame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cod-e-Codes%2FCardGame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cod-e-Codes%2FCardGame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cod-e-Codes%2FCardGame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cod-e-Codes","download_url":"https://codeload.github.com/Cod-e-Codes/CardGame/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cod-e-Codes%2FCardGame/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278692948,"owners_count":26029408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","animation","card-game","drag-and-drop","game-development","love2d","lua","modular-architecture","scene-management","testing","turn-based","ui-layout"],"created_at":"2025-10-06T23:03:50.124Z","updated_at":"2025-10-06T23:05:29.155Z","avatar_url":"https://github.com/Cod-e-Codes.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Love2D Card Game\n\nA turn-based card game implementation built with Love2D. Features a playable game with AI opponent, modular architecture, and comprehensive testing.\n\n## Features\n\n### Game Implementation\n- Turn-based gameplay with mana system and win conditions\n- AI opponent with strategic card playing\n- Card effects system with multiple abilities (damage, healing, burn, armor)\n- Interactive UI with drag-and-drop card playing\n- Multiple scenes: menu, game, deck builder, settings\n\n### User Experience\n- Responsive UI that adapts to different screen resolutions\n- Non-blocking animation system with multiple easing functions\n- Clean card rendering with proper text spacing\n- Smooth transitions between game states\n- Unified input handling for mouse, keyboard, and touch\n\n### Architecture\n- Modular design with clean system separation\n- Data-driven card definitions in Lua tables\n- Stack-based scene management supporting overlays\n- Seedable random number generation for consistent gameplay\n- Comprehensive test suite with coverage reporting\n\n## Installation\n\n### Prerequisites\n- Love2D 11.4+ installed from https://love2d.org/\n- Basic knowledge of Lua programming\n\n### Running the Game\n\n1. **Clone the repository:**\n   ```bash\n   git clone https://github.com/Cod-e-Codes/CardGame.git\n   cd CardGame\n   ```\n\n2. **Install Love2D:**\n   - Download from https://love2d.org/\n   - **Windows**: Add Love2D to your PATH, or use full path to executable\n   - **Linux**: Install via package manager or add to PATH\n\n3. **Run the game:**\n   \n   **If Love2D is in PATH:**\n   ```bash\n   love .\n   ```\n   \n   **If Love2D is not in PATH (Windows):**\n   ```bash\n   \"C:\\Program Files\\LOVE\\love.exe\" .\n   ```\n   \n   **If Love2D is not in PATH (Linux):**\n   ```bash\n   /usr/bin/love .\n   # or wherever you installed Love2D\n   ```\n   \n   **Alternative**: Drag the CardGame folder onto the Love2D executable\n\n4. **Run tests:**\n   ```bash\n   love . --test\n   ```\n\n## How to Play\n\n1. Start Game: Click \"Start Game\" from the main menu\n2. Play Cards: Drag cards from your hand to the play area\n3. Use Mana: Each card costs mana - you get more each turn\n4. End Turn: Click \"End Turn\" to let the AI play\n5. Win Condition: Reduce opponent's health to 0 or survive 25 turns\n\n## Card Types\n\n- **Creatures**: Have attack/health stats and can have special abilities\n- **Spells**: Instant effects like direct damage or healing\n- **Artifacts**: Permanent effects or mana generation\n\n**Special Abilities**:\n- Direct Damage: Lightning bolt effects\n- Healing: Restore health points\n- Burn: Extra damage over time\n- Armor: Damage reduction\n- Flying: Cannot be blocked\n- Regenerate: Heal owner when played\n\n## Project Structure\n\n```\nCardGame/\n├── main.lua                    # Love2D entry point and game loop\n├── conf.lua                   # Love2D configuration\n├── lib/                       # Core engine modules\n│   ├── scene_manager.lua      # Scene state management\n│   ├── layout.lua            # UI positioning and containers\n│   ├── animation.lua         # Tweening and easing system\n│   ├── input.lua             # Input handling and events\n│   ├── card_renderer.lua     # Card drawing and effects\n│   ├── audio_manager.lua     # Sound effects and music\n│   └── utils.lua             # Math, RNG, and utilities\n├── scenes/                    # Game state scenes\n│   ├── game_scene.lua        # Main gameplay with turn-based combat\n│   ├── menu_scene.lua        # Main menu with navigation\n│   ├── deck_builder.lua      # Card collection and deck building\n│   └── settings_scene.lua    # Game settings and options\n├── data/                      # Game data definitions\n│   ├── cards.lua             # Card definitions with abilities\n│   └── atlas_config.lua      # Sprite atlas configuration\n└── tests/                     # Test suite\n    ├── test_runner.lua       # Test framework with coverage\n    ├── test_cards.lua        # Card system tests\n    ├── test_utils.lua        # Utility function tests\n    ├── test_animation.lua    # Animation system tests\n    ├── test_layout.lua       # UI layout tests\n    ├── test_input.lua        # Input handling tests\n    ├── test_scenes.lua       # Scene management tests\n    └── test_coverage.lua     # Code coverage reporting\n```\n\n## Core Systems\n\n### Scene Management\n\nHandles game state transitions with support for scene stacking and smooth transitions:\n\n```lua\n-- Switch to a new scene\nGame.scene_manager:switchScene(\"game_scene\", {\n    type = \"fade\",\n    duration = 0.5\n})\n\n-- Push scene as overlay\nGame.scene_manager:pushScene(\"pause_menu\")\n\n-- Return to previous scene\nGame.scene_manager:popScene()\n```\n\n### Animation System\n\nNon-blocking animation system with chaining and parallel execution:\n\n```lua\nlocal Animation = require('lib.animation')\n\n-- Basic tween\nlocal tween = Animation.Tween:new(card, 0.5, {x = 100, y = 200}, Animation.Easing.outCubic)\n\n-- Chain animations\nlocal bounce = Animation.Tween:new(card, 0.2, {scale = 1.2}, Animation.Easing.outBack)\nlocal settle = Animation.Tween:new(card, 0.15, {scale = 1.0}, Animation.Easing.inCubic)\nbounce:chain(settle)\n\n-- Play with callback\nGame.animation:play(bounce, function()\n    print(\"Animation complete!\")\nend)\n```\n\n### Responsive UI Layout\n\nContainer-based layout system with anchoring and automatic scaling:\n\n```lua\nlocal Layout = require('lib.layout')\n\n-- Create container\nlocal container = Layout.Container:new(0, 0, 400, 300, {\n    background_color = {0.2, 0.2, 0.3, 0.8},\n    border_color = {0.4, 0.4, 0.5, 1}\n})\n\n-- Anchor to screen center\ncontainer:setAnchor(\"center\", 0, 0)\n\n-- Add child with relative positioning\nlocal button = Layout.Container:new(0, 0, 100, 50)\ncontainer:addChild(button, {\n    anchor = \"bottom-center\",\n    padding = {10, 10, 10, 10}\n})\n```\n\n## Card Data Schema\n\nCards are defined using Lua tables with a standardized schema:\n\n```lua\n{\n    id = \"fire_sprite\",\n    name = \"Fire Sprite\",\n    description = \"A small elemental creature that deals burn damage.\",\n    cost = 1,\n    type = \"creature\",\n    attack = 1,\n    health = 1,\n    abilities = {\"burn\"},\n    artwork = \"fire_sprite\",\n    rarity = \"common\",\n    collectible = true,\n    set = \"basic\",\n    flavor_text = \"Born from ember, destined for flame.\"\n}\n```\n\n### Adding New Cards\n\n1. Define card data in `data/cards.lua`\n2. Add artwork to sprite atlas\n3. Update `data/atlas_config.lua` with sprite coordinates\n4. Implement any new abilities in game logic\n\n## Testing\n\nThe framework includes a comprehensive test suite with over 150 unit tests covering all major systems.\n\n### Running Tests\n\n```bash\nlove . --test\n```\n\nExample output:\n```\n✓ test_cards         PASS (25/25)\n✓ test_utils         PASS (35/35) \n✓ test_animation     PASS (20/20)\n✓ test_layout        PASS (18/18)\n✓ test_input         PASS (22/22)\n✓ test_scenes        PASS (15/15)\n\nTOTAL: 135 passed, 0 failed (45.2 ms)\nCode Coverage: 78.5% (156/199 functions)\n```\n\n### Test Coverage\n\nThe test suite provides detailed coverage reporting:\n- Function Coverage: Tracks which functions are tested\n- Module Breakdown: Per-module coverage statistics  \n- Performance Metrics: Test execution time\n- Missing Coverage: Lists untested functions\n\n### Test Categories\n\n- Card System: Validation, filtering, copying, schema consistency\n- Utilities: RNG, math functions, table operations, string handling\n- Animation: Tweening, easing functions, chaining, performance\n- Layout: UI containers, anchoring, responsive design\n- Input: Key/mouse handling, drag-and-drop, touch support\n- Scenes: Scene management, transitions, lifecycle events\n\n## Development\n\n### Debug Mode\n\nThe game includes built-in debug features:\n\n```bash\nlove . --debug\n```\n\nDebug Features:\n- Performance Overlay: FPS, memory usage, draw calls\n- Visual Bounds: UI container boundaries  \n- Input State: Current key/mouse states\n- Animation Info: Active tweens and timing\n\n### In-Game Hotkeys\n\n- `F1`: Toggle debug overlay\n- `F2`: Run test suite (debug mode only)\n- `D`: Draw new card (in game scene)\n- `T`: End turn (in game scene)  \n- `Escape`: Go back/return to menu\n- `Q`: Quit game (from main menu)\n\n### Development Workflow\n\n1. Make Changes: Edit Lua files\n2. Test Changes: `love . --test` \n3. Run Game: `love .`\n4. Debug Issues: `love . --debug`\n\n### Adding New Features\n\nThe modular architecture makes it easy to extend:\n- New Cards: Add to `data/cards.lua`\n- New Scenes: Create in `scenes/` directory\n- New Abilities: Extend card effect system\n- New UI: Use layout system components\n- New Tests: Add to `tests/` directory\n\n## Performance Guidelines\n\n### Memory Management\n\n- Use object pooling for frequently created objects\n- Batch draw calls using SpriteBatch\n- Limit simultaneous audio instances (max 16)\n- Cache layout calculations\n- Clean up completed animations\n\n### Rendering Optimization\n\n- Use texture atlases to reduce draw calls\n- Enable nearest-neighbor filtering for pixel art\n- Minimize GPU state changes\n- Implement efficient collision detection\n\n### Animation Performance\n\n- Use fixed timestep for deterministic updates\n- Cache easing function calculations\n- Automatically clean up completed tweens\n- Limit concurrent animations per object\n\n## Multiplayer Considerations\n\n### Deterministic Gameplay\n\nThe framework uses seedable RNG for consistent game states:\n\n```lua\n-- Set seed for deterministic shuffling\nUtils.setSeed(12345)\nlocal shuffled_deck = Utils.shuffle(deck)\n```\n\n### Networking Architecture\n\nFor multiplayer implementation:\n1. Authoritative Server: Validate all game actions server-side\n2. Client Prediction: Show immediate feedback, rollback on mismatch  \n3. State Synchronization: Send delta updates, not full game state\n4. Input Buffering: Handle network latency gracefully\n\n### Recommended Libraries\n\n- lua-enet: Low-latency UDP networking (included with Love2D)\n- json.lua: For network message serialization\n- lz4: For state compression\n\n## Contributing\n\nContributions are welcome. Please test your changes and follow the existing code style.\n\n## License\n\nMIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcod-e-codes%2Fcardgame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcod-e-codes%2Fcardgame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcod-e-codes%2Fcardgame/lists"}