fix game not ending on sheriff death
This commit is contained in:
parent
72cd2295b3
commit
c27660de61
25
backend/Readme.md
Normal file
25
backend/Readme.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Bang Backend
|
||||
How to get started
|
||||
## Development
|
||||
Create a virtual env
|
||||
```bash
|
||||
python3 -m venv PATHTOENV
|
||||
```
|
||||
activate the new environment
|
||||
```bash
|
||||
souce PATHTOENV/bin/activate
|
||||
```
|
||||
|
||||
now with the current directory in the backend folder install the dependencies
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
then you can start the python file `__init__.py`, I recommend you use *nodemon* for that, as it will automatically reload the server on new changes. If you don't already have it, you can install nodemon with
|
||||
```
|
||||
npm i -g nodemon
|
||||
```
|
||||
then you will be able to start the server with
|
||||
```
|
||||
nodemon __init__.py
|
||||
```
|
@ -38,6 +38,8 @@ class Game:
|
||||
self.incremental_turn = 0
|
||||
self.did_resuscitate_deadman = False
|
||||
self.is_handling_death = False
|
||||
self.pending_winners = []
|
||||
|
||||
|
||||
def notify_room(self, sid=None):
|
||||
if len([p for p in self.players if p.character == None]) != 0 or sid:
|
||||
@ -271,6 +273,16 @@ class Game:
|
||||
if self.readyCount == self.waiting_for:
|
||||
self.waiting_for = 0
|
||||
self.readyCount = 0
|
||||
if self.pending_winners:
|
||||
print('WE HAVE A WINNER')
|
||||
for p in self.get_alive_players():
|
||||
p.win_status = p in self.pending_winners
|
||||
if p.win_status:
|
||||
self.sio.emit('chat_message', room=self.name, data=f'_won|{p.name}')
|
||||
p.notify_self()
|
||||
for i in range(5):
|
||||
self.sio.emit('chat_message', room=self.name, data=f'_lobby_reset|{5-i}')
|
||||
eventlet.sleep(1)
|
||||
if self.dalton_on:
|
||||
self.dalton_on = False
|
||||
print(f'notifying {self.players[self.turn].name} about his turn')
|
||||
@ -460,12 +472,15 @@ class Game:
|
||||
print('WE HAVE A WINNER')
|
||||
for p in self.get_alive_players():
|
||||
p.win_status = p in winners
|
||||
if p.win_status:
|
||||
self.sio.emit('chat_message', room=self.name, data=f'_won|{p.name}')
|
||||
p.notify_self()
|
||||
for i in range(5):
|
||||
self.sio.emit('chat_message', room=self.name, data=f'_lobby_reset|{5-i}')
|
||||
eventlet.sleep(1)
|
||||
return self.reset()
|
||||
elif len(winners) > 0: # non tutti hanno risposto, ma ci sono vincitori.
|
||||
self.pending_winners = winners
|
||||
|
||||
vulture = [p for p in self.get_alive_players() if p.character.check(self, characters.VultureSam)]
|
||||
if len(vulture) == 0:
|
||||
@ -519,6 +534,7 @@ class Game:
|
||||
self.is_handling_death = False
|
||||
self.waiting_for = 0
|
||||
self.incremental_turn = 0
|
||||
self.pending_winners = []
|
||||
for p in self.players:
|
||||
p.reset()
|
||||
p.notify_self()
|
||||
|
@ -1,4 +1,4 @@
|
||||
# frontend
|
||||
# Bang Frontend
|
||||
|
||||
## Project setup
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user