commit
bc1d18d91c
4
.github/workflows/pylint.yml
vendored
4
.github/workflows/pylint.yml
vendored
@ -7,7 +7,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.8", "3.9", "3.10"]
|
python-version: ["3.7"]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
@ -17,6 +17,8 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
|
cd backend
|
||||||
|
pip install --user -r requirements.txt
|
||||||
pip install pylint
|
pip install pylint
|
||||||
- name: Analysing the code with pylint
|
- name: Analysing the code with pylint
|
||||||
run: |
|
run: |
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# pylint: skip-file
|
||||||
|
|
||||||
class DodgeCity():
|
class DodgeCity():
|
||||||
def get_characters():
|
def get_characters():
|
||||||
|
@ -395,6 +395,7 @@ class FucileDaCaccia(Card):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# pylint: disable=function-redefined
|
||||||
def get_starting_deck() -> List[Card]:
|
def get_starting_deck() -> List[Card]:
|
||||||
cards = [
|
cards = [
|
||||||
Barile(Suit.CLUBS, 'A'),
|
Barile(Suit.CLUBS, 'A'),
|
||||||
|
@ -134,6 +134,7 @@ class DocHolyday(Character):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# pylint: disable=function-redefined
|
||||||
def all_characters() -> List[Character]:
|
def all_characters() -> List[Character]:
|
||||||
cards = [
|
cards = [
|
||||||
PixiePete(),
|
PixiePete(),
|
||||||
|
@ -63,6 +63,7 @@ class Player:
|
|||||||
self.committed_suit_manette = None
|
self.committed_suit_manette = None
|
||||||
self.not_chosen_character = None
|
self.not_chosen_character = None
|
||||||
try:
|
try:
|
||||||
|
# pylint: disable=no-member
|
||||||
del self.win_status
|
del self.win_status
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -7,4 +7,5 @@ python-socketio==4.6.1
|
|||||||
six==1.16.0
|
six==1.16.0
|
||||||
pytest==7.1.1
|
pytest==7.1.1
|
||||||
requests==2.27.1
|
requests==2.27.1
|
||||||
discord-webhook==0.15.0
|
discord-webhook==0.15.0
|
||||||
|
datadog==0.44.0
|
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
import time
|
||||||
import random
|
import random
|
||||||
from typing import List
|
from typing import List
|
||||||
import eventlet
|
import eventlet
|
||||||
@ -10,6 +11,17 @@ from bang.players import Player, PendingAction
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
from discord_webhook import DiscordWebhook
|
from discord_webhook import DiscordWebhook
|
||||||
|
from datadog import initialize, api
|
||||||
|
|
||||||
|
|
||||||
|
send_metrics = False
|
||||||
|
if "DATADOG_API_KEY" in os.environ and "DATADOG_APP_KEY" in os.environ:
|
||||||
|
initialize()
|
||||||
|
send_metrics = True
|
||||||
|
api.Event.create(title="Backend start", text="", tags=["server:backend", f"host:{os.environ['HOST']}"], alert_type="info")
|
||||||
|
else:
|
||||||
|
print("Datadog not configured")
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
sys.setrecursionlimit(10**6) # this should prevents bots from stopping
|
sys.setrecursionlimit(10**6) # this should prevents bots from stopping
|
||||||
@ -43,6 +55,8 @@ blacklist: List[str] = []
|
|||||||
def advertise_lobbies():
|
def advertise_lobbies():
|
||||||
sio.emit('lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if not g.started and len(g.players) < 10 and not g.is_hidden])
|
sio.emit('lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if not g.started and len(g.players) < 10 and not g.is_hidden])
|
||||||
sio.emit('spectate_lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if g.started])
|
sio.emit('spectate_lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if g.started])
|
||||||
|
if send_metrics:
|
||||||
|
api.Metric.send(metric='lobbies', points=[(int(time.time()), len(games))], tags=["server:backend", "type:lobbies", f"host:{os.environ['HOST']}"])
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
def connect(sid, environ):
|
def connect(sid, environ):
|
||||||
@ -51,6 +65,8 @@ def connect(sid, environ):
|
|||||||
print('connect ', sid)
|
print('connect ', sid)
|
||||||
sio.enter_room(sid, 'lobby')
|
sio.enter_room(sid, 'lobby')
|
||||||
sio.emit('players', room='lobby', data=online_players)
|
sio.emit('players', room='lobby', data=online_players)
|
||||||
|
if send_metrics:
|
||||||
|
api.Metric.send(metric='online_players', points=[(int(time.time()), online_players)], tags=["server:backend", f"host:{os.environ['HOST']}"])
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
def get_online_players(sid):
|
def get_online_players(sid):
|
||||||
@ -73,6 +89,8 @@ def report(sid, text):
|
|||||||
sio.emit('chat_message', room=sid, data={'color': f'green','text':f'Report OK'})
|
sio.emit('chat_message', room=sid, data={'color': f'green','text':f'Report OK'})
|
||||||
else:
|
else:
|
||||||
print("WARNING: DISCORD_WEBHOOK not found")
|
print("WARNING: DISCORD_WEBHOOK not found")
|
||||||
|
if send_metrics:
|
||||||
|
api.Event.create(title="BUG REPORT", text=data, tags=["server:backend", f"host:{os.environ['HOST']}"])
|
||||||
print(f'New bug report, replay at https://www.toptal.com/developers/hastebin/{key}')
|
print(f'New bug report, replay at https://www.toptal.com/developers/hastebin/{key}')
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
@ -156,6 +174,8 @@ def disconnect(sid):
|
|||||||
games.pop(games.index(sio.get_session(sid).game))
|
games.pop(games.index(sio.get_session(sid).game))
|
||||||
print('disconnect ', sid)
|
print('disconnect ', sid)
|
||||||
advertise_lobbies()
|
advertise_lobbies()
|
||||||
|
if send_metrics:
|
||||||
|
api.Metric.send(metric='online_players', points=[(int(time.time()), online_players)], tags=["server:backend", f"host:{os.environ['HOST']}"])
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
def create_room(sid, room_name):
|
def create_room(sid, room_name):
|
||||||
@ -263,11 +283,15 @@ def start_game(sid):
|
|||||||
ses: Player = sio.get_session(sid)
|
ses: Player = sio.get_session(sid)
|
||||||
ses.game.start_game()
|
ses.game.start_game()
|
||||||
advertise_lobbies()
|
advertise_lobbies()
|
||||||
|
if send_metrics:
|
||||||
|
api.Metric.send(metric='start_game', points=[(int(time.time()), 1)], tags=["server:backend", f"host:{os.environ['HOST']}", [f"exp:{e}" for e in ses.game.expansions]])
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
def set_character(sid, name):
|
def set_character(sid, name):
|
||||||
ses: Player = sio.get_session(sid)
|
ses: Player = sio.get_session(sid)
|
||||||
ses.game.rpc_log.append(f'{ses.name};set_character;{name}')
|
ses.game.rpc_log.append(f'{ses.name};set_character;{name}')
|
||||||
|
if send_metrics:
|
||||||
|
api.Metric.send(metric='set_character', points=[(int(time.time()), 1)], tags=["server:backend", f"host:{os.environ['HOST']}", f"char:{name}"])
|
||||||
ses.set_character(name)
|
ses.set_character(name)
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
|
@ -479,7 +479,7 @@ def test_saloon():
|
|||||||
assert p.lives == p.max_lives
|
assert p.lives == p.max_lives
|
||||||
|
|
||||||
# test WellsFargo
|
# test WellsFargo
|
||||||
def test_diligenza():
|
def test_wells_fargo():
|
||||||
sio = DummySocket()
|
sio = DummySocket()
|
||||||
g = Game('test', sio)
|
g = Game('test', sio)
|
||||||
ps = [Player(f'p{i}', f'p{i}', sio) for i in range(4)]
|
ps = [Player(f'p{i}', f'p{i}', sio) for i in range(4)]
|
||||||
|
Loading…
Reference in New Issue
Block a user