Skip to content

🐍 Python3 client-server CLI game over sockets ⌨️

Notifications You must be signed in to change notification settings

Serfati/keyboard_spamming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

👑 Keyboard Spamming Battle Royale ⌨

Description

Your objective is to write a client-server application which will implement a fast-paced Keyboard Spamming game. The players in this game are randomly divided into two teams, which have ten seconds to mash as many keys on the keyboard as possible. Each team in the course will write both a client application and a server application, and everybody’s clients and servers are expected to work together with full compatibility.

Suggested Architecture

The client is a single-threaded app, which has three states: ● Looking for a server. You leave this state when you get an offer message. ● Connecting to a server. You leave this state when you successfully connect using TCP ● Game mode - collect characters and from the keyboard and send them over TCP. collect data from the network and print it onscreen. Note that in game mode the client responds to two events - both keyboard presses and data coming in over TCP. Think about how you can do this. The server is multi-threaded since it has to manage multiple clients. It has two states: ● Waiting for clients - sending out offer messages and responding to request messages and new TCP connections. You leave this state after 10 seconds. ● Game mode - collect characters from the network and calculate the score. You leave this state after 10 seconds.

Packet Formats

● Servers broadcast their announcements with destination port 13117 using UDP. There is one packet format used for all UDP communications: ○ Magic cookie (4 bytes): 0xfeedbeef. The message is rejected if it doesn’t start with this cookie ○ Message type (1 byte): 0x2 for offer. No other message types are supported. ○ Server port (2 bytes): The port on the server that the client is supposed to connect to over TCP (the IP address of the server is the same for the UDP and TCP connections, so it doesn't need to be sent). The data over TCP has no packet format. After connecting, the client sends the predefined team name to the server, followed by a line break (‘\n’). After that, the client simply prints anything it gets from the server onscreen, and sends anything it gets from the keyboard to the server.

⚠️ Prerequisites

📦 How To Install

You can modify or contribute to this project by following the steps below:

1. Clone the repository

  • Open terminal ( Ctrl + Alt + T )

  • Clone to a location on your machine.

# Clone the repository 
$> git clone https://github.com/serfati/bibi.git  

# Navigate to the directory 
$> cd bibi

2. Install Dependencies

# install with requirments
$> ./setup.sh

3. launch of the server

# Run Server 
$> python3 server.py

4. launch of the client

# Run Client 
$> python3 client.py

5. enjoy


author Serfati

⚖️ License

This program is free software: you can redistribute it and/or modify it under the terms of the MIT LICENSE as published by the Free Software Foundation.

⬆ back to top

About

🐍 Python3 client-server CLI game over sockets ⌨️

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published