Skip to content

Commit

Permalink
ende
Browse files Browse the repository at this point in the history
  • Loading branch information
voloder committed Jan 28, 2024
1 parent 6f9b882 commit b4a25ba
Show file tree
Hide file tree
Showing 6 changed files with 511 additions and 231 deletions.
16 changes: 8 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ async def udji(kod : str, igrac : Igrac) -> Soba:
raise HTTPException(status_code=404, detail="Soba ne postoji")

@app.post("/sobe/kreiraj/")
async def kreiraj(postavke : SobaPostavke) -> str:
async def kreiraj() -> str:

kod = str(random.randint(1000, 9999))
soba = Soba(kod=kod, igraci=[], postavke=postavke)
print(soba.postavke.kategorije)
soba = Soba(kod=kod, igraci=[])
sobe.append(soba)
asyncio.create_task(cisti(soba))
return kod

@app.post("/sobe/zapocni/")
async def zapocni(kod : str):
async def zapocni(kod : str, postavke : SobaPostavke):
soba = nadji_sobu(kod)
soba.postavke = postavke
asyncio.create_task(zapocni_sobu(soba))
return 200

Expand Down Expand Up @@ -99,10 +99,10 @@ async def odabir(event : str, sid : str, data : str):

async def update_sobu(soba : Soba):
s = soba.model_dump()

s["postavke"].pop("custom_pitanja")
s["postavke"].pop("kategorije")

if(soba.postavke is not None):
s["postavke"].pop("custom_pitanja")
s["postavke"].pop("kategorije")
await sio.emit("soba_" + soba.kod, json.dumps(s))

async def odbroji(soba : Soba, vrjeme : int):
Expand Down
2 changes: 1 addition & 1 deletion models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Soba(BaseModel):
stanje: str = "cekanje"
trenutno_pitanje: int = 0

postavke : SobaPostavke
postavke : SobaPostavke | None = None

def nadji_igraca(self, ime, avatar) -> Igrac:
return [igrac for igrac in self.igraci if (igrac.ime, igrac.avatar) == (ime, avatar)][0]
Expand Down
Binary file added static/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b4a25ba

Please sign in to comment.