Skip to content

shachar67/home-assignment-tunesec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trivia Game

A command-line trivia game where two players can compete against each other by answering multiple-choice questions from various categories.

Prerequisites

  • Python 3.x installed on your system
  • Basic familiarity with running commands in terminal/bash

Quick Start

  1. Clone or download this repository
  2. Navigate to the project directory:
cd path/to/trivia-game
  1. Run the game with default settings:
python main.py

This will start a game with default player names and questions from the demo question set.

Game Features

The game comes with three optional extensions that can be enabled:

  1. Category Choice (--ext1): Players can choose question categories
  2. Score Variation (--ext2): Points vary based on question difficulty
  3. Lifelines (--ext3): Players get helpful lifelines during the game

Command Line Options

python main.py [options]

Options:
  --questions_file FILE  Path to custom questions JSON file (default: demo_questions.json)
  --player1 NAME        Name for Player 1 (default: "player 1")
  --player2 NAME        Name for Player 2 (default: "player 2")
  --ext1               Enable category choice extension
  --ext2               Enable score variation extension
  --ext3               Enable lifelines extension

Examples

  1. Basic game with custom player names:
python main.py --player1 "Alice" --player2 "Bob"
  1. Game with all extensions enabled:
python main.py --ext1 --ext2 --ext3
  1. Using a custom questions file:
python main.py --questions_file my_questions.json

Custom Questions File

You can create your own questions file following the format in demo_questions.json. The file should contain an array of questions with the following structure:

{
  "questions": [
    {
      "type": "multiple",
      "difficulty": "easy|medium|hard",
      "category": "Your Category",
      "question": "Your question text?",
      "correct_answer": "Correct option",
      "incorrect_answers": [
        "Wrong option 1",
        "Wrong option 2",
        "Wrong option 3"
      ]
    }
  ]
}

Requirements for questions file:

  • Must contain an even number of questions
  • At least 2 questions are required
  • Each question must follow the format above

Gameplay

  1. Players take turns answering questions
  2. Each correct answer earns points
  3. With score variation (--ext2), points depend on difficulty:
    • Easy: 1 point
    • Medium: 2 points
    • Hard: 3 points
  4. The player with the most points at the end wins

Tips

  • Use the category choice extension (--ext1) for more strategic gameplay
  • Enable lifelines (--ext3) to make the game more exciting
  • Create your own questions file to customize the experience
  • Make sure your questions file has an even number of questions

Troubleshooting

If you encounter errors:

  • Verify your Python version is 3.x
  • Check that your questions file follows the correct JSON format
  • Ensure your questions file has an even number of questions
  • Make sure all required files are in the same directory

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages