|
|
|
@ -3,11 +3,13 @@
|
|
|
|
|
require 'required.php';
|
|
|
|
|
require 'onlyloggedin.php';
|
|
|
|
|
|
|
|
|
|
use AnthonyMartin\GeoLocation\GeoLocation as GeoLocation;
|
|
|
|
|
|
|
|
|
|
if (is_empty($VARS['locationid'])) {
|
|
|
|
|
sendError("No target!", true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$place = $database->select('locations', ['locationid', 'teamid', 'owneruuid', 'currentlife', 'maxlife'], ['locationid' => $VARS['locationid']])[0];
|
|
|
|
|
$place = $database->select('locations', ['locationid', 'teamid', 'owneruuid', 'currentlife', 'maxlife', 'osmid'], ['locationid' => $VARS['locationid']])[0];
|
|
|
|
|
$user = $database->select('players', ['level', 'teamid', 'energy', 'maxenergy', 'latitude', 'longitude'], ['uuid' => $_SESSION['uuid']])[0];
|
|
|
|
|
|
|
|
|
|
// This (probably) shouldn't happen in normal play
|
|
|
|
@ -27,8 +29,25 @@ if ($type_mod == 0.5) {
|
|
|
|
|
|
|
|
|
|
$terrain_mod = 1.0;
|
|
|
|
|
$weather_mod = 1.0;
|
|
|
|
|
$distance_mod = 1.0;
|
|
|
|
|
if (!is_empty($VARS['lat']) && !is_empty($VARS['long'])) {
|
|
|
|
|
try {
|
|
|
|
|
require_once 'latlong_validate.php';
|
|
|
|
|
if (!is_empty(DARKSKY_APIKEY)) {
|
|
|
|
|
require 'weather_inc.php';
|
|
|
|
|
$weather_icon = $currently['icon'];
|
|
|
|
|
$weather_mod = $WEATHER_GRID[$weather_icon][$user['teamid'] - 1];
|
|
|
|
|
if ($weather_mod == 0.5) {
|
|
|
|
|
$weather_mod = .9;
|
|
|
|
|
} else if ($weather_mod == 2) {
|
|
|
|
|
$weather_mod = 1.1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$weather_mod = 1.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$terrain = json_decode(file_get_contents("http://gis.terranquest.net/terrain.php?key=" . GIS_API_KEY . "&lat=" . $VARS['lat'] . "&long=" . $VARS['long']), TRUE);
|
|
|
|
|
if ($terrain['status'] == 'OK') {
|
|
|
|
|
$terraintype = $terrain['type'];
|
|
|
|
@ -41,16 +60,26 @@ if (!is_empty($VARS['lat']) && !is_empty($VARS['long'])) {
|
|
|
|
|
$terrain_mod = 1.3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$weather_icon = $currently['icon'];
|
|
|
|
|
$weather_mod = $WEATHER_GRID[$weather_icon][$user['teamid'] - 1];
|
|
|
|
|
if ($weather_mod == 0.5) {
|
|
|
|
|
$weather_mod = .9;
|
|
|
|
|
} else if ($weather_mod == 2) {
|
|
|
|
|
$weather_mod = 1.1;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$terrain_mod = 1.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// Round to 2 digits (approx. 1.11 meters/3.6 feet)
|
|
|
|
|
$lat = number_format((float) $VARS['lat'], 5, '.', '');
|
|
|
|
|
$long = number_format((float) $VARS['long'], 5, '.', '');
|
|
|
|
|
$placedata = json_decode(file_get_contents("http://gis.terranquest.net/place.php?key=" . GIS_API_KEY . "&osmid=" . $place['osmid']), true);
|
|
|
|
|
$placelong = $placedata['features'][0]['geometry']['coordinates'][0];
|
|
|
|
|
$placelat = $placedata['features'][0]['geometry']['coordinates'][1];
|
|
|
|
|
$playerlocation = GeoLocation::fromDegrees($lat, $long);
|
|
|
|
|
$placelocation = GeoLocation::fromDegrees($placelat, $placelong);
|
|
|
|
|
$distance_mod = DISTANCE_GRID($playerlocation->distanceTo($placelocation, 'miles'));
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$distance_mod = 1.0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$damage = pow(floor($user['level']), 0.5) * 4 * $type_mod * $terrain_mod * $weather_mod;
|
|
|
|
|
$damage = pow(floor($user['level']), 0.5) * 4 * $type_mod * $terrain_mod * $weather_mod * $distance_mod;
|
|
|
|
|
//$damage = 2 * $userdrain * $TYPE_GRID[$user['teamid']][$place['teamid']];
|
|
|
|
|
// Check if action possible
|
|
|
|
|
if ($user['energy'] < $userdrain) {
|
|
|
|
|