From 703e743878564e5f0c50099d7c31c4406b146609 Mon Sep 17 00:00:00 2001 From: yzamir Date: Tue, 12 Sep 2023 13:00:44 +0300 Subject: [PATCH] Add a common directory to the server application Signed-off-by: yzamir --- rose/server/common/__init__.py | 0 rose/server/common/actions.py | 10 ++++++++++ rose/server/common/config.py | 20 ++++++++++++++++++++ rose/server/common/obstacles.py | 17 +++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 rose/server/common/__init__.py create mode 100644 rose/server/common/actions.py create mode 100644 rose/server/common/config.py create mode 100644 rose/server/common/obstacles.py diff --git a/rose/server/common/__init__.py b/rose/server/common/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/rose/server/common/actions.py b/rose/server/common/actions.py new file mode 100644 index 00000000..85bbffb1 --- /dev/null +++ b/rose/server/common/actions.py @@ -0,0 +1,10 @@ +""" Driving actions """ + +NONE = "none" # NOQA +RIGHT = "right" # NOQA +LEFT = "left" # NOQA +PICKUP = "pickup" # NOQA +JUMP = "jump" # NOQA +BRAKE = "brake" # NOQA + +ALL = (NONE, RIGHT, LEFT, PICKUP, JUMP, BRAKE) diff --git a/rose/server/common/config.py b/rose/server/common/config.py new file mode 100644 index 00000000..38e343da --- /dev/null +++ b/rose/server/common/config.py @@ -0,0 +1,20 @@ +# config.py + +# Default Configuration +drivers = [] +run = "stop" + +game_rate = 1.0 +game_duration = 60 + +matrix_height = 9 +matrix_width = 6 + +max_players = 2 +cells_per_player = 3 + +score_move_forward = 10 +score_move_backward = -10 +score_pickup = 10 +score_jump = 5 +score_brake = 4 diff --git a/rose/server/common/obstacles.py b/rose/server/common/obstacles.py new file mode 100644 index 00000000..3b84f9ca --- /dev/null +++ b/rose/server/common/obstacles.py @@ -0,0 +1,17 @@ +""" Game obstacles """ + +import random + +NONE = "" # NOQA +CRACK = "crack" # NOQA +TRASH = "trash" # NOQA +PENGUIN = "penguin" # NOQA +BIKE = "bike" # NOQA +WATER = "water" # NOQA +BARRIER = "barrier" # NOQA + +ALL = (NONE, CRACK, TRASH, PENGUIN, BIKE, WATER, BARRIER) + + +def get_random_obstacle(): + return random.choice(ALL)