This repository contains my implementation of the Shotgun game as part of Inlämningsuppgift 2 in the course Objektorienterad programmering med C# .NET.
The player competes against the computer using actions Shoot, Load, Block, and the special Shotgun move.
- Extended Description
- Assignment Scope
- Game Rules
- How to Run Locally
- Implementation Notes (OOP)
- Screenshots / Demo
- Project Documentation
- Author
- Assignment Status
This project was created during the course Objektorienterad programmering med C# .NET.
The task was to build a playable Windows Forms (WinForms) application where the user plays Shotgun against a computer opponent that picks moves randomly.
Key objectives:
- Show each player’s current bullet count clearly at all times.
- Prevent shooting unless the player has bullets (same for the computer).
- Announce the winner and allow “Play Again.”
- Enable the Shotgun action only when the player has ≥ 3 bullets.
- Write clean, object-oriented C# code following the course guidelines.
All core features are implemented as required for a passing grade (G).
This submission focuses on:
- A functional WinForms UI for interaction and status display.
- A game engine enforcing rules, turn results, and win conditions.
- A simple AI (random move selection).
Optional improvements (not required for G) are noted in the roadmap and can be added later (e.g., smarter AI).
- Load vs Load → Both players gain +1 bullet.
- Load vs Block → The loading player gains +1 bullet.
- Block vs Block → No change.
- Shoot vs Block → The shooter loses 1 bullet.
- Shoot vs Shoot → Both players lose 1 bullet.
- Shoot vs Load → Shooter wins the game.
- Shotgun (needs 3+ bullets) → Instant win (even if opponent shoots or blocks).
- Clone the repo:
git clone https://github.com/<your-username>/ShotgunGame.git
-
GameState class to track bullets, last moves, and win state.
-
Player abstraction for Human and Computer:
-
Human: selected via UI buttons.
-
Computer: random strategy (can be extended).
-
-
GameEngine service:
-
Validates actions (e.g., cannot Shoot with 0 bullets).
-
Resolves round outcomes based on rules.
-
Exposes events/results to the UI.
-
-
WinForms UI:
-
Clearly displays bullet counts and last actions.
-
Disables invalid buttons (e.g., Shoot when bullets = 0; Shotgun when bullets < 3).
-
Dialog to show winner and Play Again option.
-
-
Roadmap (optional):
- Smarter AI (avoid “Block” when opponent has 0 bullets, etc.)
- Sound effects and animations
- Persistent high scores
Player loads a bullet while opponent blocks
Shooting action and empty bullets warning
Shotgun move → instant win
A short technical note is included in the repo (e.g., docs/notes.md) describing:
- Class responsibilities (GameState, GameEngine, Player).
- UI flow and state updates.
- How to extend AI logic.
Sanali Sewwandi Cloud Developer Student – CUA24S JENSEN Yrkeshögskola, 2025




