From 90eacf34cdc2f2084cdd6aa6809533e3b6ee30ae Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Mon, 3 Oct 2016 19:49:03 -0600 Subject: [PATCH] Add terrain and weather damage multipliers --- attackplace.php | 28 +++++++++++++++++++++++++++- type_grid.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/attackplace.php b/attackplace.php index 9cfdaf6..2669148 100644 --- a/attackplace.php +++ b/attackplace.php @@ -22,7 +22,33 @@ $type_mod = $TYPE_GRID[$user['teamid']][$place['teamid']]; if ($type_mod == 0.5) { $type_mod = 0.8; } -$damage = pow(floor($user['level']), 0.5) * 4 * $type_mod; + +$terrain_mod = 1.0; +$weather_mod = 1.0; +if (!is_empty($VARS['lat']) && !is_empty($VARS['long'])) { + require 'weather_inc.php'; + $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']; + $terrain_mod = $TERRAIN_GRID[$terraintype][$user['teamid'] - 1]; + if ($terrain_mod == 0.5) { + $terrain_mod = .9; + } else if ($terrain_mod == 2) { + $terrain_mod = 1.1; + } else if ($terrain_mod == 3) { + $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; + } +} + +$damage = pow(floor($user['level']), 0.5) * 4 * $type_mod * $terrain_mod * $weather_mod; //$damage = 2 * $userdrain * $TYPE_GRID[$user['teamid']][$place['teamid']]; // Check if action possible if ($user['energy'] < $userdrain) { diff --git a/type_grid.php b/type_grid.php index 9b2d56d..747c73d 100644 --- a/type_grid.php +++ b/type_grid.php @@ -14,3 +14,35 @@ $TYPE_GRID = [ ["light", 1, 1, 1, 1, 0, 2], ["dark", 1, 0.5, 1, 2, 0.5, 0] ]; + +$TERRAIN_GRID = [ + // Water Fire Earth Wind Light Dark + 0 => [3, 0.5, 0.5, 1, 1, 1], + 1 => [1, 1, 1, 1, 1, 2], + 2 => [1, 1, 1, 1, 1, 1], + 3 => [1, 1, 1, 1, 1, 1], + 4 => [1, 1, 1, 1, 1, 1], + 5 => [1, 1, 1, 1, 1, 1], + 6 => [1, 1, 1, 1, 1, 1], + 7 => [1, 1, 1, 1, 1, 1], + 8 => [1, 2, 1, 1, 1, 1], + 9 => [1, 2, 1, 1, 1, 1], + 10 => [1, 1, 2, 2, 2, 0.5], + 11 => [1, 1, 2, 2, 2, 0.5], + 12 => [0.5, 1, 1, 1, 1, 1], + 13 => [1, 1, 1, 0.5, 0.5, 2] +]; + +$WEATHER_GRID = [ + // Water Fire Earth Wind Light Dark + "rain" => [2, 0.5, 1, 1, 1, 1], + "clear-day" => [1, 1, 1, 1, 2, 1], + "clear-night" => [1, 1, 1, 1, 1, 2], + "partly-cloudy-day" => [1, 1, 1, 1, 2, 1], + "partly-cloudy-night" => [1, 1, 1, 1, 1, 2], + "cloudy" => [1, 1, 1, 1, 1, 1], + "sleet" => [1, 1, 1, 1, 1, 1], + "snow" => [1, 1, 1, 1, 1, 1], + "wind" => [1, 1, 1, 2, 1, 1], + "fog" => [1, 1, 1, 1, 1, 1] +];