Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaeyeon1 committed Dec 10, 2024
2 parents cb43e09 + 5b400b8 commit ae23e10
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions backend/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import random
import sys
import json
from collections import defaultdict
from datetime import datetime
Expand All @@ -24,6 +25,8 @@
allow_headers=["*"],
)

sys.setrecursionlimit(2000)

# WebSocket Check

class Player:
Expand Down Expand Up @@ -306,9 +309,13 @@ async def start_wolf_round(self):
await self.room.broadcast(Process(
type = "process",
state = "night",
time = 30
time = self.wolf_timer
))
self.process = "night"
await self.room.broadcast(Alert(
type="alert",
text = "To Night...."
))

await self.room.broadcast(GameInfo(
type="gameInfo",
Expand Down Expand Up @@ -369,7 +376,8 @@ def receive_wolf_choice(self,chosen_victim : str):

def receive_vote(self, voter_id: str, voted_player: str):
if voted_player in self.votes:
self.votes[voted_player] += 1
self.votes[voter_id] += 1
print("cur Vote List {self.votes}")

async def kill_player(self, player):
self.players.remove(player)
Expand All @@ -392,9 +400,11 @@ async def check_game_end(self):
num_alive = len(self.players)
if self.wolf not in self.players:
self.winner = "pigs"
self.running = False
return True
elif num_alive == 2 and self.wolf in self.players:
self.winner = "wolf"
self.running = False
return True
return False

Expand Down Expand Up @@ -741,7 +751,7 @@ async def handle_room_while(websocket: WebSocket, room: ConnectionManager,room_i
curGame = game_manager.get_game(room.room_id)

curGame.receive_vote(message.userID, user_id)
print("vote player")
print("vote player {user_id} => {message.userID}")
elif message.type == "kill":
curGame = game_manager.get_game(room.room_id)

Expand Down

0 comments on commit ae23e10

Please sign in to comment.