Skip to content

42-Course/Zappy

Repository files navigation

ZappyWeb 42



Intro

This current Directory contains 3 different programs: Client, GraphicalInterface & the main program (The server)

The Client & GraphicalInterface directories (programs) are just for testing, they are not relevant.


Server

The Zappy server is a Game engine where you can run the Trantor World! Trantorians must survive and you can build a bot to play and get to the last elevation level.

Running the server:

You can just compile the project and run with the default configuration (conf.toml)

make all
./Zappy

Optionally if you want you can run the project in debug mode (this will generate aditional debug information on the server side and clients will receive more information) When DEBUG mode is on Clients will receive more information about the command they execute, if they fail and why. To run in debug mode you can generate an executable like this:

make debug
./debug_Zappy
Options

You can change almost all the server configurations. You have the following options available:

Mandatory OPTIONS (For now disabled until later because it's not convenient to write all this info every time you want to run the server)

-c <#clients>       number of players allowed per team
-n team <team2> ... teams, this is, the teams that will exist on trantor
-x <width>          refers to the initial horizontal size of trantor (width > 10)
-y <height>         refers to the initial vertical size of trantor (height > 10)
  • Note:
    Using "Team Rocket" as a default team Port 4242 for players Port 2121 for spectators (grapical interfaces should use this one) x = 20 h = 20 3 clients by default

Other OPTIONS]:

-f <file>    set the configuration file (TOML format)
             by default `./conf.toml` is used
-t <ms>      set the time unit divider, it's 100 by default (100 frames per second)
             the higher this number, the faster the world will be (ms > 0)
-T <ms>      set the connection timeout, if a player doesn't join a team after ms
             doesn't apply to spectators (default to 1min (60000ms)
-l <acronym> default Zappy language <must be present on the conf.file>
-P <port>    set the players port to something else than 4242
-S <port>    set the spectators port to something else than 2121
-h           help

Configuration

The configuration is managed on the configuration file (conf.toml by default)

On the configuration file you can add new languages (for now) In the future I will implement the port(s), address, single port mode; etc

Table of commands

Graphical Client

CMD Request CMD Response Details Example
msz msz X Y\n Map Size, returns the map size
X width
Y height
ExampleSpectator
bct X Y bct X Y q q q q q q q\n Box Content Tile, returns all the resources of a tile in order
Params:
X tile 'x' coordinate
Y tile 'y' coordinate
Resources (q q q q q q q):
Each q represents the amount of a resource, the list is ordered
See Moreq q q q q q q
│ │ │ │ │ │ └ Thystame [7]
│ │ │ │ │ └── Phiras [6]
│ │ │ │ └──── Mendiane [5]
│ │ │ └────── Sibur [4]
│ │ └──────── Deraumère [3]
│ └────────── Linemate [2]
└──────────── Food [1]

Errors:
When '[x, y]' is not found on the map: Tile [x y] is not in the map
Static Badge Static Badge
ExampleBox Content Tile
mct bct X Y q q q q q q q\n
\n
(for each tile)
Map Content Tiles, executes the bct command for all the tiles in the map, followed by an empty new line (end of message)
*Note:the new line mentioned is not the one from the bct command. The mct command will list all the tiles and in the end it will output a new line (empty line)
ExampleMap Contents Tiles
tna tna N\n
\n
(for each team)
Team names, returns all the teams names
N team's name
The end of the list is indicated by an empty new line (end of message)
ExampleTeam Names
- pnw #n X Y O L N\n Player New, notification when a Player connects and joins a team
X x coordinate
Y y coordinate
O orientation
L level
N team's name
ExamplePlayer New NotificationPlayer New Notification
ppo #n ppo #n X Y O\n Player Position, returns the position of player #n
Params:
#n player's id
X x coordinate
Y y coordinate
O orientation
Errors:
When the id is not found: Player not found
ExamplePlayer PositionPlayer Position
plv #n plv #n L\n Player Level, returns the level of player #n
Params:
#n player's id
L level
Errors:
When the id is not found: Player not found
ExamplePlayer Level
pin #n pin #n X Y q q q q q q q\n Player inventory, get the inventory of player #n
Params:
#n player's id
X x coordinate
Y y coordinate
q amount of the resource
Errors:
When the id is not found: Player not found
ExamplePlayers Inventory
players player #n X Y O L q q q q q q q "N"\n (for each player) Players, get all the players information, as described on the Player New and Player inventory, followed by an empty new line (end of message)
Note: The team name is between "" so it can be parsed more easily
ExamplePlayers
NOTE:
All parameters given to a command should be separated by spaces
The commands which take no parameters ignore any parameters if executed with parameters
Commands which require parameters should receive only the parameters which are allowed or they will fallback to `sbp` (server bad params)
All commands not found will fallback to `scu` (server command unknown)
When DEBUG mode is ON, the `suc` & `sbp` will display more information on the reason of the failure

About

Zappy multiplayer game

Topics

Resources

Stars

Watchers

Forks