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:
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 = {
"bridge": {
"id_n": 0,
......@@ -61,9 +61,10 @@ OBJS = {
}
COLORS = {
"GREEN": ["green", "#008000", [0, 128, 0]],
"PURPLE": ["purple", "#800080", [128, 0, 128]],
"PINK" : ["pink", "#ffc0cb", [255, 192, 203]]
"green": ["green", "#008000", [0, 128, 0]],
"red": ["red", "#ff0000", [255, 0, 0]],
"yellow" : ["yellow", "#ffa500", [255, 165, 0]],
"blue": ["blue", "#1b4ccd", [27, 76, 205]]
}
......@@ -81,7 +82,7 @@ NAME_GEN = name_generator()
@socketio.on('click')
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"]
......@@ -91,8 +92,6 @@ def sample_preview_board(config):
f"{golmi_server}/slurk/{room_id}/state"
)
print(f"{golmi_server}/slurk/{room_id}/state")
state = req.json()
obj = OBJS[config["shape"]]
obj["color"] = COLORS[config["color"]]
......@@ -110,8 +109,7 @@ def sample_preview_board(config):
client = clients[room_id]
client.load_state(state)
print(client)
print(room_id)
else:
req = requests.get(
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):
if piece:
piece = list(piece.values())[0]
socketio.emit("gripped", {
"color": piece["color"][0].upper(),
"color": piece["color"][0],
"shape": piece["type"],
})
@socketio.on('change')
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"]
req = requests.get(
f"{golmi_server}/slurk/{room_id}/state"
......@@ -147,12 +145,10 @@ def change(data):
obj = piece[id_n]
if data["color"] in COLORS:
print("change color")
new_color = COLORS[data["color"]]
obj["color"] = new_color
if data["shape"] in OBJS:
print("change shape")
new_shape = data["shape"]
new_matrix = OBJS[data["shape"]]["block_matrix"]
obj["block_matrix"] = new_matrix
......@@ -174,8 +170,8 @@ def disconnection():
@home.route('/')
def main():
room_id = str(uuid.uuid4())
golmi_address = f'http://{current_app.config["golmi_host"]}:{current_app.config["golmi_port"]}'
room_id = str(uuid.uuid4()).split("-")[0]
golmi_address = f'{current_app.config["golmi_host"]}:{current_app.config["golmi_port"]}'
golmi_pswd = current_app.config["golmi_pswd"]
client = GolmiClient()
......@@ -187,6 +183,8 @@ def main():
client.load_config(CONFIG)
print(f"Your room id: {room_id}")
return render_template(
"home.html",
room_id=room_id,
......
......@@ -54,10 +54,10 @@
<a>Shape: </a>
<select class="ui selection dropdown" id="shape">
<option value=""> </option>
<option value="nut"> NUT </option>
<option value="washer"> WASHER </option>
<option value="screw"> SCREW </option>
<option value="bridge"> BRIDGE </option>
<option value="nut"> nut </option>
<option value="washer"> washer </option>
<option value="screw"> screw </option>
<option value="bridge"> bridge </option>
</select>
</div>
......@@ -65,9 +65,10 @@
<a>Color: </a>
<select class="ui selection dropdown" id="color">
<option value=""> </option>
<option value="GREEN"> GREEN </option>
<option value="PURPLE"> PURPLE </option>
<option value="PINK"> PINK </option>
<option value="green"> green </option>
<option value="yellow"> yellow </option>
<option value="red"> red </option>
<option value="blue">blue</option>
</select>
</div>
......
......@@ -10,18 +10,19 @@ docker run --network host \
-e GOLMI_PORT=$GOLMI_PORT \
-d $GOLMI_NAME
# cd ../cocobotdemo
# GUI_NAME="cocobotdemo"
# GUI_ADDRESS="127.0.0.1"
# GUI_PORT=5000
# GOLMI_PSWD="GiveMeTheBigBluePasswordOnTheLeft"
cd ../cocobotdemo
GUI_NAME="cocobotdemo"
GUI_ADDRESS="127.0.0.1"
GUI_PORT=5000
GOLMI_PSWD="GiveMeTheBigBluePasswordOnTheLeft"
# docker build --tag "$GUI_NAME" -f dockerfile .
# docker run --network host \
# --restart unless-stopped \
# -e ADDRESS=$GUI_ADDRESS \
# -e PORT=$GUI_PORT \
# -e GOLMI_PSWD=$GOLMI_PSWD \
# -e GOLMI_HOST=$GOLMI_HOST \
# -e GOLMI_PORT=$GOLMI_PORT \
# -d $GUI_NAME
docker build --tag "$GUI_NAME" -f dockerfile .
docker run \
--restart unless-stopped \
-e ADDRESS=$GUI_ADDRESS \
-e PORT=$GUI_PORT \
-e GOLMI_PSWD=$GOLMI_PSWD \
-e GOLMI_HOST=$GOLMI_HOST \
-e GOLMI_PORT=$GOLMI_PORT \
--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