Commit 0a6552e0 authored by Roque's avatar Roque

erp5_officejs_drone_capture_flag: general app fixes

- drop console logs
- update api doc
- refine init map coordinates
- crash drone if logic is empty
- jslint
parent 26f6f688
......@@ -409,7 +409,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
return _this._mapManager.latLonDistance([a.x, a.y], [b.x, b.y]);
}
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();
distance = calculateDistance(drone_position, other_position, context);
if (distance <= VIEW_SCOPE) {
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1010.22181.14558.58982</string> </value>
<value> <string>1010.35063.25322.10700</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1691593350.04</float>
<float>1692366624.83</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -564,9 +564,6 @@ var MapManager = /** @class */ (function () {
[map_dict.max_lat, map_dict.min_lon]),
map_size = Math.ceil(Math.max(max_width, max_height)),
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 = {
"depth": map_size,
"height": map_dict.height,
......@@ -1324,12 +1321,16 @@ var GameManager = /** @class */ (function () {
return false;
}
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) {
code = default_drone_AI;
} else {
code = drone_info.script_content;
}
trim = code.trim();
if (!trim) {
code = "me.onStart = function () { forcedErrorEmptyScript };";
}
code_eval = "let drone = new DroneManager(ctx._scene, " +
index + ', api, team);' +
"let droneMe = function(NativeDate, me, Math, window, DroneManager," +
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1010.22324.3760.41318</string> </value>
<value> <string>1010.23697.26501.43008</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1691601869.17</float>
<float>1691684378.73</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -265,7 +265,7 @@
<!-- loiter -->
<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>
<h5 class="item-param-1">Param</h5>
......@@ -273,15 +273,28 @@
</div>
<div>
<p class="item-param-1">altitude: Float</p>
<p class="item-param-2">altitude value</p>
<p class="item-param-1">X: Float</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>
<h5 class="item-param-1">Example</h5>
</div>
<p class="item-param-1">me.loiter(100);<br>
<p class="item-param-1">me.loiter(lat, lon, altitude, radius);<br>
</p>
<div class="line"></div>
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1010.22088.20940.23517</string> </value>
<value> <string>1010.23624.18144.48810</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1691587714.89</float>
<float>1691679891.23</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -11,8 +11,9 @@
//but map_size is needed here for map randomization (location of objects)
//TODO refactor: or randomization is moved to map manager (seed as param)
//or randomization is done here but with geo-coordinates (not meters)
MAP_SIZE = 902,
min_lat = 45.6475,
MAP_SIZE = 900,
//square map
min_lat = 45.6419,
max_lat = 45.65,
min_lon = 14.265,
max_lon = 14.2766,
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1010.22334.20227.40840</string> </value>
<value> <string>1010.23654.50890.20360</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1691602475.06</float>
<float>1691681704.91</float>
<string>UTC</string>
</tuple>
</state>
......
/*jslint indent: 2, maxlen: 100*/
/*global window, rJS, domsugar, document, URLSearchParams, Blob*/
(function (window, rJS, domsugar, document, URLSearchParams, Blob) {
/*global window, rJS, domsugar, document*/
(function (window, rJS, domsugar, document) {
"use strict";
var SIMULATION_SPEED = 10,
......@@ -23,7 +23,6 @@
MAX_CLIMB_RATE = 8,
MAX_SINK_RATE = 3,
NUMBER_OF_DRONES = 1,
FLAG_WEIGHT = 5,
// Non-inputs parameters
DEFAULT_SCRIPT_CONTENT =
'function assert(a, b, msg) {\n' +
......@@ -98,7 +97,7 @@
return gadget.runGame();
})
.declareJob('runGame', function runGame(options) {
.declareJob('runGame', function runGame() {
var gadget = this, i,
fragment = gadget.element.querySelector('.simulator_div'),
game_parameters_json, map_json;
......@@ -202,17 +201,18 @@
return form_gadget.getContent();
})
.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);
function createLogNode(message) {
var node = document.createElement("div");
var textNode = document.createTextNode(message);
node.appendChild(textNode);
return node;
var log_node = document.createElement("div"),
textNode = document.createTextNode(message);
log_node.appendChild(textNode);
return log_node;
}
var lines = result.console_log.split('\n');
for (var i = 0;i < lines.length;i++) {
var node = createLogNode(lines[i]);
lines = result.console_log.split('\n');
for (l = 0; l < lines.length; l += 1) {
node = createLogNode(lines[l]);
document.querySelector('.test_log').appendChild(node);
}
}, function (error) {
......@@ -221,4 +221,4 @@
});
});
}(window, rJS, domsugar, document, URLSearchParams, Blob));
\ No newline at end of file
}(window, rJS, domsugar, document));
\ No newline at end of file
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1010.22211.26359.65484</string> </value>
<value> <string>1010.33861.49321.40789</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1691595104.74</float>
<float>1692294109.04</float>
<string>UTC</string>
</tuple>
</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