Skip to content
Snippets Groups Projects
Commit d6288865 authored by seba's avatar seba
Browse files

working with 7x7

parent 54fa5305
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ with open("piece_variables.json", encoding="utf-8") as infile: ...@@ -20,7 +20,7 @@ with open("piece_variables.json", encoding="utf-8") as infile:
PIECE_VARIABLES = json.load(infile) PIECE_VARIABLES = json.load(infile)
CONFIG = {"width": 4.0, "height": 4.0, "move_step": 1, "prevent_overlap": False} CONFIG = {"width": 7.0, "height": 7.0, "move_step": 1, "prevent_overlap": False}
OBJS = { OBJS = {
"bridge": { "bridge": {
"id_n": 0, "id_n": 0,
...@@ -61,9 +61,10 @@ OBJS = { ...@@ -61,9 +61,10 @@ OBJS = {
} }
COLORS = { COLORS = {
"GREEN": ["green", "#008000", [0, 128, 0]], "green": ["green", "#008000", [0, 128, 0]],
"PURPLE": ["purple", "#800080", [128, 0, 128]], "red": ["red", "#ff0000", [255, 0, 0]],
"PINK" : ["pink", "#ffc0cb", [255, 192, 203]] "yellow" : ["yellow", "#ffa500", [255, 165, 0]],
"blue": ["blue", "#1b4ccd", [27, 76, 205]]
} }
...@@ -81,7 +82,7 @@ NAME_GEN = name_generator() ...@@ -81,7 +82,7 @@ NAME_GEN = name_generator()
@socketio.on('click') @socketio.on('click')
def sample_preview_board(config): def sample_preview_board(config):
golmi_server = f'http://{current_app.config["golmi_host"]}:{current_app.config["golmi_port"]}' golmi_server = f'{current_app.config["golmi_host"]}:{current_app.config["golmi_port"]}'
room_id = config["room_id"] room_id = config["room_id"]
...@@ -91,8 +92,6 @@ def sample_preview_board(config): ...@@ -91,8 +92,6 @@ def sample_preview_board(config):
f"{golmi_server}/slurk/{room_id}/state" f"{golmi_server}/slurk/{room_id}/state"
) )
print(f"{golmi_server}/slurk/{room_id}/state")
state = req.json() state = req.json()
obj = OBJS[config["shape"]] obj = OBJS[config["shape"]]
obj["color"] = COLORS[config["color"]] obj["color"] = COLORS[config["color"]]
...@@ -110,8 +109,7 @@ def sample_preview_board(config): ...@@ -110,8 +109,7 @@ def sample_preview_board(config):
client = clients[room_id] client = clients[room_id]
client.load_state(state) client.load_state(state)
print(client)
print(room_id)
else: else:
req = requests.get( req = requests.get(
f'{golmi_server}/slurk/{room_id}/{config["coordinates"]["x"]}/{config["coordinates"]["y"]}/{config["coordinates"]["block_size"]}' f'{golmi_server}/slurk/{room_id}/{config["coordinates"]["x"]}/{config["coordinates"]["y"]}/{config["coordinates"]["block_size"]}'
...@@ -123,14 +121,14 @@ def sample_preview_board(config): ...@@ -123,14 +121,14 @@ def sample_preview_board(config):
if piece: if piece:
piece = list(piece.values())[0] piece = list(piece.values())[0]
socketio.emit("gripped", { socketio.emit("gripped", {
"color": piece["color"][0].upper(), "color": piece["color"][0],
"shape": piece["type"], "shape": piece["type"],
}) })
@socketio.on('change') @socketio.on('change')
def change(data): def change(data):
golmi_server = f'http://{current_app.config["golmi_host"]}:{current_app.config["golmi_port"]}' golmi_server = f'{current_app.config["golmi_host"]}:{current_app.config["golmi_port"]}'
room_id = data["room_id"] room_id = data["room_id"]
req = requests.get( req = requests.get(
f"{golmi_server}/slurk/{room_id}/state" f"{golmi_server}/slurk/{room_id}/state"
...@@ -147,12 +145,10 @@ def change(data): ...@@ -147,12 +145,10 @@ def change(data):
obj = piece[id_n] obj = piece[id_n]
if data["color"] in COLORS: if data["color"] in COLORS:
print("change color")
new_color = COLORS[data["color"]] new_color = COLORS[data["color"]]
obj["color"] = new_color obj["color"] = new_color
if data["shape"] in OBJS: if data["shape"] in OBJS:
print("change shape")
new_shape = data["shape"] new_shape = data["shape"]
new_matrix = OBJS[data["shape"]]["block_matrix"] new_matrix = OBJS[data["shape"]]["block_matrix"]
obj["block_matrix"] = new_matrix obj["block_matrix"] = new_matrix
...@@ -174,8 +170,8 @@ def disconnection(): ...@@ -174,8 +170,8 @@ def disconnection():
@home.route('/') @home.route('/')
def main(): def main():
room_id = str(uuid.uuid4()) room_id = str(uuid.uuid4()).split("-")[0]
golmi_address = f'http://{current_app.config["golmi_host"]}:{current_app.config["golmi_port"]}' golmi_address = f'{current_app.config["golmi_host"]}:{current_app.config["golmi_port"]}'
golmi_pswd = current_app.config["golmi_pswd"] golmi_pswd = current_app.config["golmi_pswd"]
client = GolmiClient() client = GolmiClient()
...@@ -187,6 +183,8 @@ def main(): ...@@ -187,6 +183,8 @@ def main():
client.load_config(CONFIG) client.load_config(CONFIG)
print(f"Your room id: {room_id}")
return render_template( return render_template(
"home.html", "home.html",
room_id=room_id, room_id=room_id,
......
...@@ -54,10 +54,10 @@ ...@@ -54,10 +54,10 @@
<a>Shape: </a> <a>Shape: </a>
<select class="ui selection dropdown" id="shape"> <select class="ui selection dropdown" id="shape">
<option value=""> </option> <option value=""> </option>
<option value="nut"> NUT </option> <option value="nut"> nut </option>
<option value="washer"> WASHER </option> <option value="washer"> washer </option>
<option value="screw"> SCREW </option> <option value="screw"> screw </option>
<option value="bridge"> BRIDGE </option> <option value="bridge"> bridge </option>
</select> </select>
</div> </div>
...@@ -65,9 +65,10 @@ ...@@ -65,9 +65,10 @@
<a>Color: </a> <a>Color: </a>
<select class="ui selection dropdown" id="color"> <select class="ui selection dropdown" id="color">
<option value=""> </option> <option value=""> </option>
<option value="GREEN"> GREEN </option> <option value="green"> green </option>
<option value="PURPLE"> PURPLE </option> <option value="yellow"> yellow </option>
<option value="PINK"> PINK </option> <option value="red"> red </option>
<option value="blue">blue</option>
</select> </select>
</div> </div>
......
...@@ -10,18 +10,19 @@ docker run --network host \ ...@@ -10,18 +10,19 @@ docker run --network host \
-e GOLMI_PORT=$GOLMI_PORT \ -e GOLMI_PORT=$GOLMI_PORT \
-d $GOLMI_NAME -d $GOLMI_NAME
# cd ../cocobotdemo cd ../cocobotdemo
# GUI_NAME="cocobotdemo" GUI_NAME="cocobotdemo"
# GUI_ADDRESS="127.0.0.1" GUI_ADDRESS="127.0.0.1"
# GUI_PORT=5000 GUI_PORT=5000
# GOLMI_PSWD="GiveMeTheBigBluePasswordOnTheLeft" GOLMI_PSWD="GiveMeTheBigBluePasswordOnTheLeft"
# docker build --tag "$GUI_NAME" -f dockerfile . docker build --tag "$GUI_NAME" -f dockerfile .
# docker run --network host \ docker run \
# --restart unless-stopped \ --restart unless-stopped \
# -e ADDRESS=$GUI_ADDRESS \ -e ADDRESS=$GUI_ADDRESS \
# -e PORT=$GUI_PORT \ -e PORT=$GUI_PORT \
# -e GOLMI_PSWD=$GOLMI_PSWD \ -e GOLMI_PSWD=$GOLMI_PSWD \
# -e GOLMI_HOST=$GOLMI_HOST \ -e GOLMI_HOST=$GOLMI_HOST \
# -e GOLMI_PORT=$GOLMI_PORT \ -e GOLMI_PORT=$GOLMI_PORT \
# -d $GUI_NAME --net host \
-d $GUI_NAME
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment