fix bugs ?? tromgeroffel

This commit is contained in:
Laila van Reenen 2024-08-08 20:55:40 +02:00
parent 56d26cd751
commit 463843bf8b
Signed by: LailaTheElf
GPG Key ID: 1F4E6EE3E6DDF769
2 changed files with 5 additions and 5 deletions

View File

@ -59,23 +59,20 @@ async def echoClients(client):
async def takeControll(client, boat):
global boats
print("DEBUG: " + client['id'] + " takes controll of " + boat)
if (client['boat'] is not None):
client['boat']["state"] = BOAT_STATE_AVAILABLE
client["boat"] = None
for b in boats:
if (b['id'] == boat):
print("DEBUG: boat found")
if (b['state'] == BOAT_STATE_AVAILABLE):
b["state"] = BOAT_STATE_INCTRL
print("take controll: " + str(client["id"]) + " -> " + b["name"])
client["boat"] = b
client['ws'].send("OK")
return
else:
print("WARN: takeControll: " + b["name"] + " not available (" + str(client["id"]) + ")")
break
else:
print("DEBUG: " + boat + " != " + b['id'])
client['ws'].send("FAIL")
async def freeBoat(boat):
global boats, clients
@ -131,6 +128,7 @@ async def onMessage(message, client):
print("WARN: controll cmd (" + client['id'] + ") to None: " + data[2])
else:
print("INFO: controll cmd (" + client['id'] + ") to " + client['boat']['name'] + ": " + data[2])
client['boat']['ws'].send("d:" + data[2])
else:
print("WARN: invalid command (" + client['id'] + "): '" + data[1] + "'")

View File

@ -90,6 +90,8 @@
}
function send(x,y,angle){
x = Math.round((x + 100) * 163.84);
y = Math.round((y + 100) * 163.84);
var data = clientId + ";d;" + x.toString() + "," + y.toString();
connection.send(data);
}