Skip to content

sorooshm78/sea

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sea

Sea Battle game by Django

Types of game

index

  • Single player

play_game single_play score_board

  • Two player

search_user two_player game_history

Attack Type

1.Bomb

By selecting a cell as a bomb, only that cell is selected bomb

2.Liner

By selecting a cell as a liner, it moves from the left to the right of the selected row until it hits the ship liner

3.Explosion

By selecting a cell as explosion, the 3x3 area of that cell is selected explosion

4.Radar

By selecting a cell as a radar, a 3x3 area of that cell's contents (empty or ships) will be displayed. radar

Usage

With docker

first step clone my project

git clone https://github.com/sorooshm78/sea/

and then run docker-compose

docker-compose up --build

"sea battle game" app will start on 0.0.0.0:8000

enjoy it!

Manually and without docker

I am using python "3.10.6" version

first step clone my project

git clone https://github.com/sorooshm78/sea/

and go to app directory and then install requirements

pip install -r requirements.txt

this will create all the migrations file (database migrations) now, to apply this migrations run the following command

python manage.py makemigrations
python manage.py migrate

Setup Redis Cache

Install Redis on Linux

sudo apt-get update
sudo apt-get install redis

and you change redis configurations in core/settings.py to:

# Cache setting
CACHE_TTL = 15 * 60  # 15 minutes
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379/",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
        },
    }
}
CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {
            "hosts": [("127.0.0.1", 6379)],
        },
    },
}

Running the code

Just go into the code directory and type

python manage.py runserver

"sea battle game" app will start on 127.0.0.1:8000 (Local Address).

enjoy it!

Task lists

  • Add single player
  • Add two player (real time)
  • Add play by bot