Skip to content

A card game using Object oriented programming (OOPs) in Python .

Notifications You must be signed in to change notification settings

watermelon588/WAR-Card-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

WAR-Card-game

A card game using Object oriented programming (OOPs) in Python .

♠️ WAR: Python Card Game

This project is a Python implementation of the classic card game "War" between two players β€” in this case, GOJO and GETO.

πŸ“œ Game Rules

  • A standard 52-card deck is divided equally between two players.
  • Each round, both players draw the top card of their deck.
  • The player with the higher card value wins the round and collects both cards.
  • If the cards are equal, a "WAR" occurs:
    • Each player places 5 additional cards.
    • The 6th card (last one added) is compared.
    • The player with the higher 6th card wins all cards on the table.
    • If a player doesn’t have enough cards (i.e., < 5) to continue WAR, they lose.

🧠 Program Structure

Card Class

  • Represents a single playing card.
  • Stores suit, rank, and its numerical value.

Deck Class

  • Creates and holds a full shuffled deck of 52 cards.
  • Deals cards using pick_one_card().

Player Class

  • Holds each player's cards in a list.
  • Supports adding and removing cards.

Game Loop

  • Continuously plays rounds until one player runs out of cards.
  • Handles comparison of cards and WAR scenarios.

πŸ’‘ Key Features

  • Clean OOP structure (Object-Oriented Programming).
  • Handles recursive "WAR" logic with safeguards for edge cases.
  • Includes print statements to trace the game round-by-round.

πŸ“Œ Requirements

  • Python 3.x
  • No external libraries required (only built-in random)

πŸš€ How to Run

python "MILESTONE 2.py"

Make sure the filename matches your script.

πŸ”š Game End

  • The game ends when a player runs out of cards.
  • In a WAR situation, if a player cannot provide 5 cards, they immediately lose.

πŸ“‚ Contributions are welcome! Feel free to fork, suggest optimizations, or add enhancements.


πŸƒ Happy Coding and may the best deck win!

About

A card game using Object oriented programming (OOPs) in Python .

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages