2020-09-11 12:30:40 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2020-09-25 23:56:15 +00:00
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
2020-09-11 12:30:40 +00:00
|
|
|
<title>Drag</title>
|
|
|
|
|
|
|
|
<script src="static/jquery-3.5.1.js"></script>
|
|
|
|
<script src="static/jquery-ui.min.js"></script>
|
2020-09-25 23:56:15 +00:00
|
|
|
<script src="static/bootstrap.min.js"></script>
|
2020-09-11 12:30:40 +00:00
|
|
|
|
2020-09-25 23:56:15 +00:00
|
|
|
<link rel="stylesheet" href="static/bootstrap.css">
|
2020-09-11 12:30:40 +00:00
|
|
|
<link rel="stylesheet" href="static/style.css">
|
|
|
|
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<!-- container -->
|
|
|
|
<div class="container">
|
2020-09-25 23:56:15 +00:00
|
|
|
<h1>Hallo Spieler {{ player_id + 1 }}</h1>
|
2020-09-11 12:30:40 +00:00
|
|
|
|
2020-09-25 23:56:15 +00:00
|
|
|
<div class="row top-buffer">
|
|
|
|
<div class="main-canvas">
|
|
|
|
{% for i in range(0,9) %}
|
|
|
|
<div class="box card{{ i }}" name="{{ cmds[i].number }}" >{{ cmds[i].action }}
|
|
|
|
<p style="font-size: 10px">{{ cmds[i].priority }}</p>
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
2020-09-11 12:30:40 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-09-25 23:56:15 +00:00
|
|
|
<div class="row top-buffer">
|
2020-09-25 21:31:31 +00:00
|
|
|
{% if robot_info is none %}
|
2020-09-25 23:56:15 +00:00
|
|
|
<div class="col-sm">
|
|
|
|
<label for="inputRobotX">X Position:</label>
|
|
|
|
<input class="form-control" type="number" id="inputRobotX" name="robot_x" min="1" max="13" value="1">
|
2020-09-25 21:31:31 +00:00
|
|
|
<br>
|
2020-09-25 23:56:15 +00:00
|
|
|
<label for="inputRobotY">Y Position:</label>
|
|
|
|
<input class="form-control" type="number" id="inputRobotY" name="robot_y" min="1" max="7" value="1">
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<label for="orientation">Blickrichtung:</label><br>
|
2020-09-25 21:31:31 +00:00
|
|
|
<img id="orientation" class="robotOrientation" src="/static/orientation.png" alt="0">
|
|
|
|
<input hidden id="inputRobotOrientation" value=">" readonly>
|
2020-09-25 23:56:15 +00:00
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<label for="inputRobotID">Roboter ID:</label>
|
|
|
|
<select name="robotID" class="form-control" id="inputRobotID">
|
2020-09-25 21:31:31 +00:00
|
|
|
<option value="11">11</option>
|
|
|
|
<option value="12">12</option>
|
|
|
|
<option value="13">13</option>
|
|
|
|
<option value="14">14</option>
|
|
|
|
</select>
|
2020-09-25 23:56:15 +00:00
|
|
|
<label for="outputRobotFlags">Flaggen:</label><br>
|
|
|
|
{% for f in ['a', 'b', 'c', 'd'] %}
|
|
|
|
<input type="checkbox" class="form-check-input" id="flag_{{ f }}" onclick="return false;">
|
|
|
|
<label class="form-check-label" for="flag_{{ f }}">{{ f }}</label><br>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
2020-09-24 21:58:17 +00:00
|
|
|
{% else %}
|
2020-09-25 23:56:15 +00:00
|
|
|
<div class="col-sm">
|
|
|
|
<label for="outputRobotX">X Position:</label>
|
|
|
|
<input class="form-control" type="number" id="outputRobotX" name="robot_x" min="1" max="12" value="{{ robot_info[0] }}" readonly>
|
2020-09-25 21:31:31 +00:00
|
|
|
<br>
|
2020-09-25 23:56:15 +00:00
|
|
|
<label for="outputRobotY">Y Position:</label>
|
|
|
|
<input class="form-control" type="number" id="outputRobotY" name="robot_y" min="1" max="6" value="{{ robot_info[1] }}" readonly>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<label for="outputOrientation">Blickrichtung:</label><br>
|
2020-09-25 21:31:31 +00:00
|
|
|
{% if robot_info[2] == '>' %}
|
|
|
|
<img id="outputOrientation" class="robotOrientation" src="/static/orientation.png" alt="0">
|
|
|
|
{% elif robot_info[2] == 'v' %}
|
|
|
|
<img id="outputOrientation" class="robotOrientation90" src="/static/orientation.png" alt="0">
|
|
|
|
{% elif robot_info[2] == '<' %}
|
|
|
|
<img id="outputOrientation" class="robotOrientation180" src="/static/orientation.png" alt="0">
|
|
|
|
{% elif robot_info[2] == '^' %}
|
|
|
|
<img id="outputOrientation" class="robotOrientation270" src="/static/orientation.png" alt="0">
|
|
|
|
{% endif %}
|
|
|
|
<br>
|
2020-09-25 23:56:15 +00:00
|
|
|
<label for="outputRobotDmg">Schaden:</label><br>
|
|
|
|
<input class="form-control" name="robotDmg" id="outputRobotDmg" value="{{ robot_info[4] }}" readonly>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<label for="outputRobotID">Roboter ID:</label>
|
|
|
|
<input class="form-control" name="robotID" id="outputRobotID" value="{{ robot_info[3] }}" readonly>
|
|
|
|
<label for="outputRobotFlags">Flaggen:</label><br>
|
|
|
|
{% for f in ['a', 'b', 'c', 'd'] %}
|
|
|
|
{% if f in robot_info[5] %}
|
|
|
|
<input type="checkbox" class="form-check-input" id="flag_{{ f }}" checked onclick="return false;">
|
|
|
|
{% else %}
|
|
|
|
<input type="checkbox" class="form-check-input" id="flag_{{ f }}" onclick="return false;">
|
|
|
|
{% endif %}
|
|
|
|
<label class="form-check-label" for="flag_{{ f }}">{{ f }}</label><br>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
2020-09-24 21:58:17 +00:00
|
|
|
{% endif %}
|
2020-09-25 23:56:15 +00:00
|
|
|
</div>
|
2020-09-24 22:37:10 +00:00
|
|
|
|
2020-09-25 23:56:15 +00:00
|
|
|
<div class="row top-buffer">
|
|
|
|
<input class="btn btn-primary" id="btnSubmit" type="submit" value="Befehle abschicken" />
|
|
|
|
</div>
|
2020-09-24 21:58:17 +00:00
|
|
|
|
2020-09-11 12:30:40 +00:00
|
|
|
</div><!-- container -->
|
|
|
|
|
2020-09-11 20:49:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
<div class="container notification" hidden>
|
|
|
|
Bitte warten, bis alle Spieler ihre Aktion gewählt haben...
|
|
|
|
</div>
|
|
|
|
|
2020-09-11 12:30:40 +00:00
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
2020-09-11 20:49:56 +00:00
|
|
|
var please_wait = $(".notification").hide();
|
|
|
|
|
2020-09-11 12:30:40 +00:00
|
|
|
var box = $(".box");
|
|
|
|
var mainCanvas = $(".main-canvas");
|
|
|
|
|
2020-09-24 22:37:10 +00:00
|
|
|
var orientation_icon = $("#orientation");
|
2020-09-25 21:31:31 +00:00
|
|
|
var orientation_input = $("#inputRobotOrientation");
|
2020-09-24 22:37:10 +00:00
|
|
|
|
|
|
|
orientation_icon.click(function () {
|
|
|
|
if (this.alt === "0") {
|
|
|
|
this.alt = "90";
|
2020-09-25 21:31:31 +00:00
|
|
|
$("#inputRobotOrientation").val("v");
|
|
|
|
//document.getElementById("inputRobotOrientation").value = "v";
|
2020-09-24 22:37:10 +00:00
|
|
|
}
|
|
|
|
else if (this.alt === "90") {
|
|
|
|
this.alt = "180";
|
2020-09-25 21:31:31 +00:00
|
|
|
$("#inputRobotOrientation").val("<");
|
|
|
|
//document.getElementById("inputRobotOrientation").value = "<";
|
2020-09-24 22:37:10 +00:00
|
|
|
}
|
|
|
|
else if (this.alt === "180") {
|
|
|
|
this.alt = "270";
|
2020-09-25 21:31:31 +00:00
|
|
|
$("#inputRobotOrientation").val("^");
|
|
|
|
//document.getElementById("inputRobotOrientation").value = "^";
|
2020-09-24 22:37:10 +00:00
|
|
|
}
|
|
|
|
else if (this.alt === "270") {
|
|
|
|
this.alt = "0";
|
2020-09-25 21:31:31 +00:00
|
|
|
$("#inputRobotOrientation").val(">");
|
|
|
|
//document.getElementById("inputRobotOrientation").value = ">";
|
2020-09-24 22:37:10 +00:00
|
|
|
}
|
|
|
|
$(this).css({'transform' : 'rotate('+ this.alt +'deg)'});
|
|
|
|
});
|
2020-09-24 21:58:17 +00:00
|
|
|
|
|
|
|
|
2020-09-11 20:49:56 +00:00
|
|
|
$("#btnSubmit").click(function () {
|
2020-09-24 21:58:17 +00:00
|
|
|
var robot_x = $("#inputRobotX");
|
|
|
|
var robot_y = $("#inputRobotY");
|
2020-09-25 21:31:31 +00:00
|
|
|
var robot_orient = $("#inputRobotOrientation");
|
|
|
|
var robot_id = $("#inputRobotID");
|
2020-09-11 20:49:56 +00:00
|
|
|
//alert("button");
|
2020-09-25 23:56:15 +00:00
|
|
|
|
2020-09-14 12:56:30 +00:00
|
|
|
for (i = 0; i < 9; i++) {
|
2020-09-11 20:49:56 +00:00
|
|
|
var c = document.getElementsByClassName("box card" + String(i));
|
2020-09-14 12:56:30 +00:00
|
|
|
if (c[0].offsetTop === 0) {
|
|
|
|
$(c).hide();
|
|
|
|
}
|
2020-09-11 20:49:56 +00:00
|
|
|
}
|
|
|
|
$(please_wait).show();
|
|
|
|
|
2020-09-25 21:31:31 +00:00
|
|
|
$.post("/send_cmds", { "x" : robot_x.val(), "y": robot_y.val(), "orient": robot_orient.val(), "marker_id": robot_id.val()}, function (data) {
|
2020-09-11 20:49:56 +00:00
|
|
|
console.log(data);
|
2020-09-14 12:56:30 +00:00
|
|
|
if (data === 'OK') {
|
|
|
|
location.reload(); // reload page to get new cards for next round
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
console.log('waiting...')
|
|
|
|
$.get("/send_cmds", "", function (data) {
|
|
|
|
if (data === 'OK') {
|
|
|
|
location.reload(); // reload page to get new cards for next round
|
|
|
|
}
|
|
|
|
})
|
2020-09-11 20:49:56 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2020-09-11 12:30:40 +00:00
|
|
|
box.draggable({
|
|
|
|
containment: mainCanvas,
|
|
|
|
helper: "clone",
|
|
|
|
|
|
|
|
start: function () {
|
|
|
|
$(this).css({
|
|
|
|
opacity: 0
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".box").css("z-index", "0");
|
|
|
|
},
|
|
|
|
|
|
|
|
stop: function () {
|
|
|
|
$(this).css({
|
|
|
|
opacity: 1
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
box.droppable({
|
|
|
|
accept: box,
|
|
|
|
|
|
|
|
drop: function (event, ui) {
|
|
|
|
var draggable = ui.draggable;
|
|
|
|
var droppable = $(this);
|
|
|
|
var dragPos = draggable.position();
|
|
|
|
var dropPos = droppable.position();
|
|
|
|
|
2020-09-11 13:44:38 +00:00
|
|
|
var cmds = [ui.draggable.attr('name').toString(), $(this).attr('name')]
|
|
|
|
|
|
|
|
//console.log(dragPos);
|
|
|
|
//console.log(dropPos);
|
|
|
|
|
2020-09-11 20:49:56 +00:00
|
|
|
//console.log($(cmds));
|
|
|
|
// notify server that cards have been swapped
|
2020-09-11 13:44:38 +00:00
|
|
|
$.post(url='/', {drag: ui.draggable.attr('name'), drop: $(this).attr('name')});
|
2020-09-11 12:30:40 +00:00
|
|
|
|
|
|
|
draggable.css({
|
|
|
|
left: dropPos.left + "px",
|
|
|
|
top: dropPos.top + "px",
|
|
|
|
"z-index": 20
|
|
|
|
});
|
|
|
|
|
|
|
|
droppable.css("z-index", 10).animate({
|
|
|
|
left: dragPos.left,
|
|
|
|
top: dragPos.top
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|