@@ -177,7 +177,8 @@ discard block |
||
| 177 | 177 | // |
| 178 | 178 | // Retruns max depth of array |
| 179 | 179 | ######################################################################## |
| 180 | -function get_depth($arr) { |
|
| 180 | +function get_depth($arr) |
|
| 181 | +{ |
|
| 181 | 182 | $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr)); |
| 182 | 183 | $depth = 0; |
| 183 | 184 | foreach ($it as $v) { |
@@ -195,12 +196,16 @@ discard block |
||
| 195 | 196 | // |
| 196 | 197 | // Return all pokemon with data at a certain tree depth |
| 197 | 198 | ######################################################################## |
| 198 | -function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) { |
|
| 199 | - if ($depth == $currentDepth) { // Found depth |
|
| 199 | +function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) |
|
| 200 | +{ |
|
| 201 | + if ($depth == $currentDepth) { |
|
| 202 | +// Found depth |
|
| 200 | 203 | return tree_remove_bellow($trees, $max_pokemon); |
| 201 | - } else { // Go deeper |
|
| 204 | + } else { |
|
| 205 | +// Go deeper |
|
| 202 | 206 | $arr = array(); |
| 203 | - foreach ($trees as $temp) { // Go into all trees |
|
| 207 | + foreach ($trees as $temp) { |
|
| 208 | +// Go into all trees |
|
| 204 | 209 | $tree = $temp->evolutions; |
| 205 | 210 | $results = tree_remove_bellow(get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1), $max_pokemon); |
| 206 | 211 | $arr = tree_check_array($results, $arr, $depth - $currentDepth == 1); |
@@ -212,12 +217,16 @@ discard block |
||
| 212 | 217 | ######################################################################## |
| 213 | 218 | // used in get_tree_at_depth |
| 214 | 219 | ######################################################################## |
| 215 | -function tree_check_array($array_check, $array_add, $correct_arrow) { |
|
| 220 | +function tree_check_array($array_check, $array_add, $correct_arrow) |
|
| 221 | +{ |
|
| 216 | 222 | $count = count($array_check); |
| 217 | 223 | $i = 0; |
| 218 | - if (!is_null($array_check)) { // check if exists |
|
| 219 | - foreach ($array_check as $res) { // Check if above, equal or bellow center |
|
| 220 | - if ($count != 1 && $correct_arrow) { // only add arrow once |
|
| 224 | + if (!is_null($array_check)) { |
|
| 225 | +// check if exists |
|
| 226 | + foreach ($array_check as $res) { |
|
| 227 | +// Check if above, equal or bellow center |
|
| 228 | + if ($count != 1 && $correct_arrow) { |
|
| 229 | +// only add arrow once |
|
| 221 | 230 | $num = $i / ($count - 1); |
| 222 | 231 | if ($num < 0.5) { |
| 223 | 232 | $res->array_sufix = "_up"; |
@@ -241,7 +250,8 @@ discard block |
||
| 241 | 250 | return null; |
| 242 | 251 | } |
| 243 | 252 | $arr = array(); |
| 244 | - foreach ($tree as $item) { // Check if above, equal or bellow center |
|
| 253 | + foreach ($tree as $item) { |
|
| 254 | +// Check if above, equal or bellow center |
|
| 245 | 255 | if ($item->id <= $max_pokemon) { |
| 246 | 256 | $arr[] = $item; |
| 247 | 257 | } |
@@ -227,8 +227,8 @@ |
||
| 227 | 227 | $res->array_sufix = ""; |
| 228 | 228 | } |
| 229 | 229 | } else { |
| 230 | - $res->array_sufix = ""; |
|
| 231 | - } |
|
| 230 | + $res->array_sufix = ""; |
|
| 231 | + } |
|
| 232 | 232 | $array_add[] = $res; |
| 233 | 233 | $i++; |
| 234 | 234 | } |
@@ -323,8 +323,7 @@ |
||
| 323 | 323 | } elseif (isset($obj->info)) { |
| 324 | 324 | $infoName = 'INFO_' . $obj->info; |
| 325 | 325 | echo '<br>(' . $locales->$infoName . ')'; |
| 326 | - } |
|
| 327 | - else { |
|
| 326 | + } else { |
|
| 328 | 327 | echo '<br> </br>'; |
| 329 | 328 | } |
| 330 | 329 | ?> |
@@ -316,11 +316,11 @@ |
||
| 316 | 316 | <img src="core/img/arrow<?=$obj->array_sufix?>.png" alt="Arrow" class="img"> |
| 317 | 317 | <p class="pkmn-name"> |
| 318 | 318 | <?php |
| 319 | - if (isset($obj->candies)) { |
|
| 320 | - echo $obj->candies . ' ' . $locales->POKEMON_CANDIES; |
|
| 321 | - } else { |
|
| 322 | - echo '? ' . $locales->POKEMON_CANDIES; |
|
| 323 | - } |
|
| 319 | + if (isset($obj->candies)) { |
|
| 320 | + echo $obj->candies . ' ' . $locales->POKEMON_CANDIES; |
|
| 321 | + } else { |
|
| 322 | + echo '? ' . $locales->POKEMON_CANDIES; |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | 325 | if (isset($obj->item)) { |
| 326 | 326 | $itemName = 'ITEM_' . $obj->item; |
@@ -317,17 +317,17 @@ |
||
| 317 | 317 | <p class="pkmn-name"> |
| 318 | 318 | <?php |
| 319 | 319 | if (isset($obj->candies)) { |
| 320 | - echo $obj->candies . ' ' . $locales->POKEMON_CANDIES; |
|
| 320 | + echo $obj->candies.' '.$locales->POKEMON_CANDIES; |
|
| 321 | 321 | } else { |
| 322 | - echo '? ' . $locales->POKEMON_CANDIES; |
|
| 322 | + echo '? '.$locales->POKEMON_CANDIES; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | if (isset($obj->item)) { |
| 326 | - $itemName = 'ITEM_' . $obj->item; |
|
| 327 | - echo '<br>+ ' . $locales->$itemName; |
|
| 326 | + $itemName = 'ITEM_'.$obj->item; |
|
| 327 | + echo '<br>+ '.$locales->$itemName; |
|
| 328 | 328 | } elseif (isset($obj->info)) { |
| 329 | - $infoName = 'INFO_' . $obj->info; |
|
| 330 | - echo '<br>(' . $locales->$infoName . ')'; |
|
| 329 | + $infoName = 'INFO_'.$obj->info; |
|
| 330 | + echo '<br>('.$locales->$infoName.')'; |
|
| 331 | 331 | } |
| 332 | 332 | else { |
| 333 | 333 | echo '<br> </br>'; |