Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Treasure Hunt Management System

A command-line treasure hunt management system in C, featuring a hub-monitor architecture to manage hunts, treasures, and user scores.


Table of Contents


Overview

This system allows administrators to manage treasure hunts by adding, viewing, listing, and removing treasures, as well as calculating user scores. It uses:

  • Hub: Central controller that starts/stops the monitor and sends commands.
  • Monitor: Waits for commands from the hub and executes treasure operations.
  • Treasures: Stored in per-hunt treasures.dat files.
  • Scores: Calculated per user based on collected treasures.

The architecture is as follows:

+-------+         commands         +---------+
|  Hub  | ----------------------> | Monitor |
+-------+                          +---------+
     ^                                |
     |                                v
     +------------------- Treasure Files (treasures.dat)

Features

  • Start and stop the monitor process.
  • Add, list, view, and remove treasures.
  • Remove entire hunts.
  • List all treasure hunts.
  • Calculate scores per user.
  • Logs all actions for each hunt.

Project Structure

.
├── hub.c                  # Hub process code
├── treasure_monitor.c     # Monitor process code
├── treasure_manager.c     # Treasure management functions
├── calculate_score.c      # Score calculation utility
├── hub.h                  # Hub header
├── treasure_manager.h     # Treasure manager header
├── monitor_command.txt    # Command file (created at runtime)
└── README.md

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/treasure-hunt.git
cd treasure-hunt
  1. Compile all components:
gcc -o hub hub.c treasure_manager.c -Wall
gcc -o treasure_monitor treasure_monitor.c treasure_manager.c -Wall
gcc -o calculate_score calculate_score.c treasure_manager.c -Wall

Ensure all executables (hub, treasure_monitor, calculate_score) are in the same directory.


Usage

  1. Start the hub:
./hub
  1. Use hub commands to control the monitor and manage hunts/treasures.

Commands

Hub commands:

Command Description
start_monitor Starts the monitor process
stop_monitor Stops the monitor process
list_hunts Lists all active treasure hunts
list_treasures <hunt> Lists treasures in a specific hunt
view_treasure <hunt> <id> Displays details of a specific treasure
calculate_score Calculates scores for all users in all hunts
exit Exits the hub (monitor must be stopped first)

Monitor commands are handled internally; users do not interact with it directly.


Example Workflow

  1. Start the monitor:
> start_monitor
Monitor started (PID: 12345).
  1. Add a treasure to a hunt (handled by monitor via command):
> add_treasure hunt:001
Enter Treasure ID: 1
Enter Username: alice
Enter Latitude: 12.345
Enter Longitude: 67.890
Enter Clue: Under the old oak
Enter Value: 100
Treasure added to hunt hunt:001.
  1. List treasures:
> list_treasures hunt:001
ID: 1 | User: alice | GPS: (12.3450, 67.8900) | Value: 100
  1. View user scores:
> calculate_score
alice: 100
  1. Stop the monitor before exiting hub:
> stop_monitor
[Monitor] Stopping...
Monitor terminated.
> exit

About

Project

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages