This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateNewGameFunctionBuilder(BaseFunctionBuilder): | |
def __init__(self): | |
super().__init__(command_name='create_new_game') | |
def register_command(self): | |
""" | |
Registers create_new_game redis gears fucntion to redis. | |
For each generate_new_game call creates a new HASH under game namespace: | |
GAME:[game_id] owner [user_id], secret [hash], private [bool], playercount [int] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd airsim | |
pip install -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import airsimimport argparsefrom flyDroneService import FlyDroneServiceimport time | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() parser.add_argument('-u', '--level', help='Game Level', type=int, default=1) args = parser.parse_args() # connect to the AirSim simulator client = airsim.MultirotorClient() FlyDroneService.initializeAirSimClient(client) | |
gameLevel = args.level print(gameLevel) # set the coordinates to set up the path for drone to travel if gameLevel == 3: print('Level 3') client.simEnableWeather(True) FlyDroneService.setFlyingCoordsForDroneAtThirdLevel(client) elif gameLevel == 2: print('Level 2') client.simEnableWeather(True) FlyDroneService.setFlyingCoordsForDroneAtSecondLevel(client) else: print('Level 1') client.simEnableWeather(True) client.simSetWeatherParameter(airsim.WeatherParameter.Rain, 1) FlyDroneService.setFlyingCoordsForDroneAtFirstLevel(client) #sto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/redis-developer/CropInsurRedis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.8' | |
services: | |
redis: | |
build: | |
dockerfile: ./dockerfiles/Dockerfile_redis | |
context: . | |
environment: | |
- ALLOW_EMPTY_PASSWORD=yes | |
- DISABLE_COMMANDS=FLUSHDB,FLUSHALL,CONFIG,HSCAN | |
volumes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_game(user_id): | |
game = query() | |
if game != [@] and type(game) == list: | |
return game[1].split(":") [1] | |
# CREATE A NEW GAME IF THERE ARE NO GAMES | |
game = execute("RG.TRIGGER", "create_new_game", f"USER:{user_id}") | |
if game: | |
return game[@] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FT.SEARCH "GAME" "(@playercount:[0 1000])" SORTBY playercount DESC LIMIT 0 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FT.CREATE GAME ON HASH PREFIX 1 GAME: SCHEMA owner TEXT secret TEXT private NUMERIC SORTABLE playercount NUMERIC SORTABLE | |
FT.CREATE USER ON HASH PREFIX 1 USER: SCHEMA name TEXT settings TEXT secret TEXT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker-compose up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:15.14WORKDIR /home/node/app | |
COPY ./app/package*.json ./RUN npm install --only=production | |
COPY ./app .CMD [ "npm", "start" ] |