Commit 30405447 authored by Roque's avatar Roque

Capture the flag app general fixes

See merge request !1810
parents 26f6f688 0a6552e0
...@@ -409,7 +409,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -409,7 +409,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
return _this._mapManager.latLonDistance([a.x, a.y], [b.x, b.y]); return _this._mapManager.latLonDistance([a.x, a.y], [b.x, b.y]);
} }
context._gameManager._droneList.forEach(function (other) { context._gameManager._droneList.forEach(function (other) {
if (other.can_play && drone.id != other.id) { if (other.can_play && drone.id !== other.id) {
other_position = other.getCurrentPosition(); other_position = other.getCurrentPosition();
distance = calculateDistance(drone_position, other_position, context); distance = calculateDistance(drone_position, other_position, context);
if (distance <= VIEW_SCOPE) { if (distance <= VIEW_SCOPE) {
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.22181.14558.58982</string> </value> <value> <string>1010.35063.25322.10700</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1691593350.04</float> <float>1692366624.83</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -564,9 +564,6 @@ var MapManager = /** @class */ (function () { ...@@ -564,9 +564,6 @@ var MapManager = /** @class */ (function () {
[map_dict.max_lat, map_dict.min_lon]), [map_dict.max_lat, map_dict.min_lon]),
map_size = Math.ceil(Math.max(max_width, max_height)), map_size = Math.ceil(Math.max(max_width, max_height)),
starting_point = map_size / 2 * -0.75; starting_point = map_size / 2 * -0.75;
console.log("max_width:",max_width);
console.log("max_height:",max_height);
console.log("map_size:",map_size);
this.map_info = { this.map_info = {
"depth": map_size, "depth": map_size,
"height": map_dict.height, "height": map_dict.height,
...@@ -1324,12 +1321,16 @@ var GameManager = /** @class */ (function () { ...@@ -1324,12 +1321,16 @@ var GameManager = /** @class */ (function () {
return false; return false;
} }
function spawnDrone(x, y, z, index, drone_info, api, team) { function spawnDrone(x, y, z, index, drone_info, api, team) {
var default_drone_AI = api.getDroneAI(), code, base, code_eval; var default_drone_AI = api.getDroneAI(), code, base, code_eval, trim;
if (default_drone_AI) { if (default_drone_AI) {
code = default_drone_AI; code = default_drone_AI;
} else { } else {
code = drone_info.script_content; code = drone_info.script_content;
} }
trim = code.trim();
if (!trim) {
code = "me.onStart = function () { forcedErrorEmptyScript };";
}
code_eval = "let drone = new DroneManager(ctx._scene, " + code_eval = "let drone = new DroneManager(ctx._scene, " +
index + ', api, team);' + index + ', api, team);' +
"let droneMe = function(NativeDate, me, Math, window, DroneManager," + "let droneMe = function(NativeDate, me, Math, window, DroneManager," +
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.22324.3760.41318</string> </value> <value> <string>1010.23697.26501.43008</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1691601869.17</float> <float>1691684378.73</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -265,7 +265,7 @@ ...@@ -265,7 +265,7 @@
<!-- loiter --> <!-- loiter -->
<h4 class="item-name" id="loiter"><span>loiter</span><span>: void</span></h4> <h4 class="item-name" id="loiter"><span>loiter</span><span>: void</span></h4>
<p class="item-descr">Set the drone to loiter mode, it will loiter around last target coordinates.</p> <p class="item-descr">Set the drone to loiter mode, it will loiter around the target coordinates.</p>
<div> <div>
<h5 class="item-param-1">Param</h5> <h5 class="item-param-1">Param</h5>
...@@ -273,15 +273,28 @@ ...@@ -273,15 +273,28 @@
</div> </div>
<div> <div>
<p class="item-param-1">altitude: Float</p> <p class="item-param-1">X: Float</p>
<p class="item-param-2">altitude value</p> <p class="item-param-2">X value - latitude (in degrees).</p>
</div>
<div>
<p class="item-param-1">Y: Float</p>
<p class="item-param-2">Y value - longitude (in degrees).</p>
</div>
<div>
<p class="item-param-1">Z: Float</p>
<p class="item-param-2">Z value - altitude (in meters).</p>
</div>
<div>
<p class="item-param-1">radius: Float</p>
<p class="item-param-2">radius value (in meters).</p>
</div> </div>
<div> <div>
<h5 class="item-param-1">Example</h5> <h5 class="item-param-1">Example</h5>
</div> </div>
<p class="item-param-1">me.loiter(100);<br> <p class="item-param-1">me.loiter(lat, lon, altitude, radius);<br>
</p> </p>
<div class="line"></div> <div class="line"></div>
......
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.22088.20940.23517</string> </value> <value> <string>1010.23624.18144.48810</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -264,7 +264,7 @@ ...@@ -264,7 +264,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1691587714.89</float> <float>1691679891.23</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
//but map_size is needed here for map randomization (location of objects) //but map_size is needed here for map randomization (location of objects)
//TODO refactor: or randomization is moved to map manager (seed as param) //TODO refactor: or randomization is moved to map manager (seed as param)
//or randomization is done here but with geo-coordinates (not meters) //or randomization is done here but with geo-coordinates (not meters)
MAP_SIZE = 902, MAP_SIZE = 900,
min_lat = 45.6475, //square map
min_lat = 45.6419,
max_lat = 45.65, max_lat = 45.65,
min_lon = 14.265, min_lon = 14.265,
max_lon = 14.2766, max_lon = 14.2766,
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.22334.20227.40840</string> </value> <value> <string>1010.23654.50890.20360</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1691602475.06</float> <float>1691681704.91</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*jslint indent: 2, maxlen: 100*/ /*jslint indent: 2, maxlen: 100*/
/*global window, rJS, domsugar, document, URLSearchParams, Blob*/ /*global window, rJS, domsugar, document*/
(function (window, rJS, domsugar, document, URLSearchParams, Blob) { (function (window, rJS, domsugar, document) {
"use strict"; "use strict";
var SIMULATION_SPEED = 10, var SIMULATION_SPEED = 10,
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
MAX_CLIMB_RATE = 8, MAX_CLIMB_RATE = 8,
MAX_SINK_RATE = 3, MAX_SINK_RATE = 3,
NUMBER_OF_DRONES = 1, NUMBER_OF_DRONES = 1,
FLAG_WEIGHT = 5,
// Non-inputs parameters // Non-inputs parameters
DEFAULT_SCRIPT_CONTENT = DEFAULT_SCRIPT_CONTENT =
'function assert(a, b, msg) {\n' + 'function assert(a, b, msg) {\n' +
...@@ -98,7 +97,7 @@ ...@@ -98,7 +97,7 @@
return gadget.runGame(); return gadget.runGame();
}) })
.declareJob('runGame', function runGame(options) { .declareJob('runGame', function runGame() {
var gadget = this, i, var gadget = this, i,
fragment = gadget.element.querySelector('.simulator_div'), fragment = gadget.element.querySelector('.simulator_div'),
game_parameters_json, map_json; game_parameters_json, map_json;
...@@ -202,17 +201,18 @@ ...@@ -202,17 +201,18 @@
return form_gadget.getContent(); return form_gadget.getContent();
}) })
.push(function (result) { .push(function (result) {
var div = domsugar('div', { text: "CONSOLE LOG ENTRIES:" }); var div = domsugar('div', { text: "CONSOLE LOG ENTRIES:" }), lines,
l, node;
document.querySelector('.container').parentNode.appendChild(div); document.querySelector('.container').parentNode.appendChild(div);
function createLogNode(message) { function createLogNode(message) {
var node = document.createElement("div"); var log_node = document.createElement("div"),
var textNode = document.createTextNode(message); textNode = document.createTextNode(message);
node.appendChild(textNode); log_node.appendChild(textNode);
return node; return log_node;
} }
var lines = result.console_log.split('\n'); lines = result.console_log.split('\n');
for (var i = 0;i < lines.length;i++) { for (l = 0; l < lines.length; l += 1) {
var node = createLogNode(lines[i]); node = createLogNode(lines[l]);
document.querySelector('.test_log').appendChild(node); document.querySelector('.test_log').appendChild(node);
} }
}, function (error) { }, function (error) {
...@@ -221,4 +221,4 @@ ...@@ -221,4 +221,4 @@
}); });
}); });
}(window, rJS, domsugar, document, URLSearchParams, Blob)); }(window, rJS, domsugar, document));
\ No newline at end of file \ No newline at end of file
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.22211.26359.65484</string> </value> <value> <string>1010.33861.49321.40789</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1691595104.74</float> <float>1692294109.04</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment