diff --git a/Arch_Description/ClassDiag.md b/Arch_Description/ClassDiag.md new file mode 100644 index 0000000..4371026 --- /dev/null +++ b/Arch_Description/ClassDiag.md @@ -0,0 +1,157 @@ +@startuml + +package Core { + class GameMenu { + -Game game + +void showMainMenu() + +void selectGameMode(GameMode mode) + +void startGame() + } + + class Game { + -Player player1 + -Player player2 + -GameField field + -boolean gameActive + -GameMode currentMode + +void startGame() + +void endTurn() + +void checkWinCondition() + +void processCardReplacement() + +void setGameMode(GameMode mode) + } + + class GameField { + -List player1Cards + -List player2Cards + -boolean commanderHornActive + -boolean bitingFrostActive + +void calculateScores() + +void clearWeatherEffects() + +int getPlayer1Score() + +int getPlayer2Score() + } +} + +package Players { + abstract class Player { + -String name + -Hand hand + -Deck deck + -boolean hasPassed + +void drawCard() + +void playCard(Card card) + +void pass() + +void autoPassIfNoCards() + +void replaceCards(List cardsToReplace) + +boolean getHasPassed() + +String getName() + +Hand getHand() + +Deck getDeck() +} + + class HumanPlayer { + +void selectCard() + +void decidePass() + } + + class AIPlayer { + +Card chooseCardToPlay() + +boolean decideIfPass() + +List chooseCardsToReplace() + } +} + +package Cards { + abstract class Card { + -String name + -int baseStrength + +void play(GameField field) + +String getName() + +int getBaseStrength() + } + + package Creatures { + class CroneWhispess + class CroneWeavess + class CroneBrewess + class Catapult + class SiegeExpert + class BlueStripesCommando + class CloseCombat + class Archer + } + + package Spells { + class CommanderHorn + class BitingFrost + class ClearSky + } +} + +package Utilities { + class Deck { + -List cards + +void shuffle() + +Card drawCard() + +void initializeDeck() + +List drawDifferentCards(int count, List excluded) + } + + class Hand { + -List cards + +void addCard(Card card) + +void removeCard(Card card) + +List getCards() + +int getSize() + } +} + +package Display { + class GameRenderer { + +void renderMainMenu() + +void renderGameModeSelection() + +void renderGameField(GameField field) + +void renderHand(Hand hand, boolean isHuman) + +void renderScores(int player1Score, int player2Score) + +void renderPassStatus(boolean humanPassed, boolean aiPassed) + +void renderCardReplacementInterface(Hand hand) + } +} + +enum GameMode { + HUMAN_VS_HUMAN + HUMAN_VS_AI +} + +Player <|-- HumanPlayer +Player <|-- AIPlayer + +Card <|-- CroneWhispess +Card <|-- CroneWeavess +Card <|-- CroneBrewess +Card <|-- Catapult +Card <|-- SiegeExpert +Card <|-- BlueStripesCommando +Card <|-- CloseCombat +Card <|-- Archer +Card <|-- CommanderHorn +Card <|-- BitingFrost +Card <|-- ClearSky + +GameMenu --> Game : creates +Game *-- Player +Game *-- GameField +Player *-- Hand +Player *-- Deck +GameField o-- Card +Deck o-- Card +Hand o-- Card + +Game --> GameRenderer : uses +GameRenderer --> GameMenu : displays +AIPlayer --> Card : chooses +HumanPlayer --> Card : selects +GameMenu --> GameMode : uses +Game --> GameMode : has +@enduml diff --git a/Arch_Description/CompDiag.md b/Arch_Description/CompDiag.md new file mode 100644 index 0000000..202d96d --- /dev/null +++ b/Arch_Description/CompDiag.md @@ -0,0 +1,36 @@ +@startuml + +package Core { + [GameMenu] + [Game] + [GameField] +} + +package Players { + [HumanPlayer] + [AIPlayer] +} + +package Cards { + [Deck] + [Hand] + [Card] +} + +package Display { + [GameRenderer] +} + +GameMenu --> Game : starts +Game --> HumanPlayer : manages +Game --> AIPlayer : manages +Game --> GameField : uses +Game --> Deck : uses +Game --> Hand : uses +Game --> GameRenderer : updates +GameRenderer --> GameMenu : displays +GameRenderer --> HumanPlayer : interacts +Hand --> Card : contains +Deck --> Card : contains +GameField --> Card : contains +@enduml diff --git a/Arch_Description/projDescription.md b/Arch_Description/projDescription.md new file mode 100644 index 0000000..8161134 --- /dev/null +++ b/Arch_Description/projDescription.md @@ -0,0 +1,74 @@ +# Simplified Gwent Project Architecture + +## Overview +A simplified card game for two players with single round. Supports two game modes: Human vs Human and Human vs AI. Players can voluntarily stop playing cards before playing all cards in their hand. + +## Deck Composition +Each player has an identical deck of 11 unique cards: + +### **Creatures (8 cards)** +- CroneWhispess - strength 6 +- CroneWeavess - strength 6 +- CroneBrewess - strength 6 +- Catapult - strength 8 +- SiegeExpert - strength 6 +- BlueStripesCommando - strength 4 +- CloseCombat - strength 5 +- Archer - strength 4 + +### **Spells (3 cards)** +- CommanderHorn - doubles creature strength +- BitingFrost - sets all creature strength to 1 +- ClearSky - removes BitingFrost effect + +## Game Flow + +### **Initial Phase** +1. Each player receives 7 random cards from their deck +2. Players can replace up to 2 cards: + - Return selected cards to the deck + - Receive **different random cards from the deck** (not the same ones) + +### **Main Phase** +- Players take turns playing one card at a time +- Player can declare pass on their turn +- After declaring pass, player cannot play more cards this round +- If player has no cards left, they are automatically considered passed +- Round ends when both players have passed + +### **Completion** +- Score calculation considering active effects +- Player with higher total strength wins + +## Class Responsibilities by Package + +### **Core Package** +- **GameMenu** - manages game mode selection and main menu +- **Game** - manages game flow, tracks player pass states and game mode +- **GameField** - calculates current scores considering active effects + +### **Players Package** +- **Player** - base class with pass state management +- **HumanPlayer** - handles human input for card selection and passing +- **AIPlayer** - contains AI logic for card selection and pass decisions + +### **Cards Package** +All cards store only base strength. Effects are calculated dynamically during score calculation. + +### **Utilities Package** +- **Deck** - manages deck operations and card replacement +- **Hand** - manages player's hand cards + +### **Display Package** +- **GameRenderer** - renders game interface, menu, and game state + +## Effect Logic +- **CommanderHorn**: creature strength doubles +- **BitingFrost**: all creature strength set to 1 +- **CommanderHorn + BitingFrost**: all creature strength set to 2 +- **ClearSky**: cancels BitingFrost effect only + +## Pass Strategy +- **HumanPlayer**: can voluntarily declare pass through interface +- **AIPlayer**: makes pass decision based on game state analysis +- **Automatic**: player automatically passes when no cards remain diff --git a/Arch_Description/systemRequirements.md b/Arch_Description/systemRequirements.md new file mode 100644 index 0000000..90d5d50 --- /dev/null +++ b/Arch_Description/systemRequirements.md @@ -0,0 +1,110 @@ +# System Requirements and Use Cases (Final Version) + +## English Version + +### System Requirements + +#### Functional Requirements +1. **Game Mode Selection** + - The system shall provide a menu for selecting game mode: Human vs Human or Human vs AI + - The system shall initialize the appropriate player types based on selected mode + +2. **Game Initialization** + - The system shall create two identical decks of 11 unique cards for each player + - The system shall deal 7 random cards to each player at game start + - The system shall allow each player to replace up to 2 cards with different random cards from their deck + +3. **Game Flow** + - The system shall enforce turn-based gameplay between two human players or human and AI player + - The system shall allow players to either play a card or pass on their turn + - The system shall prevent players who have passed from playing additional cards + - The system shall automatically mark a player as passed when they have no cards left + - The system shall end the round when both players have passed + +4. **Card Effects** + - The system shall apply CommanderHorn effect: double the strength of all creatures + - The system shall apply BitingFrost effect: set strength of all creatures to 1 + - The system shall apply ClearSky effect: remove BitingFrost effect + - The system shall handle effect combination: CommanderHorn + BitingFrost = strength 2 for all creatures + +5. **Victory Condition** + - The system shall calculate final scores considering active effects + - The system shall declare the player with higher total strength as winner + +6. **Card Immutability** + - All card classes shall be immutable after creation + - Card properties (name, baseStrength) shall not be modifiable after object construction + - Card objects shall be reusable across multiple game sessions + - Card effects shall be applied through new object creation or external state management + +### Use Cases + +#### Use Case 0: Select Game Mode +**Actor:** Human Player +**Preconditions:** Application started +**Main Flow:** +1. System displays game mode selection menu +2. Player selects between "Human vs Human" and "Human vs AI" +3. System initializes the game with selected mode +4. System proceeds to initial card replacement phase + +#### Use Case 1: Initial Card Replacement +**Actor:** Human Player (both players in Human vs Human mode) +**Preconditions:** Game mode selected, game has started, player has 7 cards +**Main Flow:** +1. System displays hand of 7 cards +2. Player selects up to 2 cards to replace +3. System removes selected cards from player's hand +4. System adds different random cards from deck to player's hand +5. System continues to main game phase + +**Alternative Flow:** +- Player chooses to replace 0 cards → proceed directly to main game phase + +#### Use Case 2: Play Creature Card +**Actor:** Current Player (Human or AI) +**Preconditions:** Player's turn, player has not passed, hand contains cards +**Main Flow:** +1. Player selects creature card from hand +2. System moves card from hand to game field +3. System recalculates current scores +4. System passes turn to next player + +**Postconditions:** Card is on field, scores updated, turn changed + +#### Use Case 3: Play Spell Card +**Actor:** Current Player (Human or AI) +**Preconditions:** Player's turn, player has not passed, hand contains spell card +**Main Flow:** +1. Player selects spell card from hand +2. System applies spell effect according to rules +3. System removes card from hand +4. System recalculates current scores +5. System passes turn to next player + +#### Use Case 4: Player Pass +**Actor:** Current Player (Human or AI) +**Preconditions:** Player's turn, player has not passed +**Main Flow:** +1. Player selects pass option +2. System marks player as having passed +3. System passes turn to other player +4. If both players have passed, system proceeds to end game + +#### Use Case 5: AI Turn +**Actor:** AI Player +**Preconditions:** AI player's turn, AI has not passed +**Main Flow:** +1. System evaluates game state +2. AI decides to play card or pass based on strategy +3. If playing card, system automatically plays selected card +4. If passing, system marks AI as having passed +5. System updates game state and passes turn + +#### Use Case 6: Player Runs Out of Cards +**Actor:** Current Player (Human or AI) +**Preconditions:** Player's turn, player has no cards in hand, player has not passed +**Main Flow:** +1. System automatically marks player as having passed +2. System passes turn to other player +3. If both players have passed, system proceeds to end game diff --git a/Arch_Description/testingPlan.md b/Arch_Description/testingPlan.md new file mode 100644 index 0000000..9afb515 --- /dev/null +++ b/Arch_Description/testingPlan.md @@ -0,0 +1,96 @@ +### Phase 1: Foundation Tests +**Card Immutability Verification** +- Test that all card classes have only const methods after construction +- Verify that card properties cannot be modified once created +- Ensure card objects can be reused across multiple game instances +- Confirm that card effects don't modify the card objects themselves + +**Basic Class Construction** +- Test instantiation of all 20 classes without errors +- Verify proper initialization of all member variables +- Check that abstract classes cannot be instantiated directly +- Validate enum values and their usage + +### Phase 2: Core Game Logic Tests +**Game Initialization Sequence** +- Test deck creation with exactly 11 unique cards per player +- Verify initial deal of 7 cards to each player +- Validate card replacement mechanics (0-2 cards) +- Confirm that replaced cards are different from original selections + +**Turn Management** +- Test proper turn alternation between players +- Verify pass mechanism prevents further card plays +- Check automatic pass when players run out of cards +- Validate game end condition when both players pass + +### Phase 3: Card Effect Tests +**Individual Effect Verification** +- Test CommanderHorn doubles all creature strengths +- Verify BitingFrost sets all creatures to strength 1 +- Confirm ClearSky removes only BitingFrost effect +- Check that ClearSky doesn't affect CommanderHorn + +**Effect Combination Tests** +- Test CommanderHorn + BitingFrost = strength 2 for all creatures +- Verify effect application order doesn't change final result +- Test multiple spell plays in sequence +- Confirm effect removal works correctly + +### Phase 4: Victory Condition Tests +**Score Calculation** +- Test score calculation with no active effects +- Verify scores with individual effects active +- Check scores with combined effects +- Validate tie detection and handling + +**Winner Determination** +- Test proper winner declaration +- Verify score comparison logic +- Check game state after victory +- Validate reset capability for new games + +### Phase 5: Game Mode Tests +**Mode Selection** +- Test Human vs Human initialization +- Verify Human vs AI initialization +- Check proper player type assignment +- Validate menu navigation and mode selection + +**AI Behavior** +- Test AI decision making within expected parameters +- Verify AI considers game state in decisions +- Check AI pass decision logic +- Validate AI card selection strategy + +### Phase 6: Integration Tests +**End-to-End Game Flow** +- Test complete game from menu to victory +- Verify all state transitions work correctly +- Check error handling and edge cases +- Validate user interface interactions + +**Persistence and State Management** +- Test game state consistency across turns +- Verify proper cleanup and resource management +- Check memory usage with repeated games +- Validate object lifecycle management + +### Phase 7: Edge Case and Boundary Tests +**Exceptional Conditions** +- Test empty hand scenarios +- Verify behavior with maximum card plays +- Check minimum card scenarios +- Validate error conditions and recovery + +**Performance Characteristics** +- Test response times for user interactions +- Verify AI decision time constraints +- Check memory usage patterns +- Validate scalability for future enhancements + +### Testing Strategy +- **Unit Tests**: Individual class and method testing +- **Integration Tests**: Component interaction testing +- **System Tests**: Full game flow validation +- **Property Tests**: Verify immutability and state invariants