forked from JustinMorrill/NastyFightingTurtles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
reader.php
43 lines (35 loc) · 994 Bytes
/
reader.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
$file = file_get_contents('amogus.csv');
$lines = explode("\r\n", $file);
$output = "";
//echo $lines[count($lines) - 1];
foreach ($lines as &$line) {
$line = explode(',', $line);
foreach ($line as &$item) {
$item = ($item != '') ? intval($item) : 0;
}
$line = implode(',',$line);
}
$output = "[[";
$output .= implode("],\n[",$lines);
$output .= "]]";
file_put_contents("map.json", $output);
$array = json_decode($output, true);
$checks = ['tasks', -10,-11,-12,-13,-14,-15,-16,-17,-18,-19];
$put2 = "{";
foreach ($checks as $vent) {
$put2 .= "\"$vent\" : [";
$alr = false;
for ($j = 0; $j < count($array); $j++) {
for ($i = 0; $i < count($array[0]); $i++) {
if ($vent <= -10 ? ($array[$j][$i] == $vent) : ($array[$j][$i] >= 3 && $array[$j][$i] <= 16)) {
if ($alr) { $put2 .= ",";}
$put2 .= "[" . $i . ',' . $j . "]";
$alr = true;
}
}
}
$put2 .= "]" . ($vent == -19 ? '' : ',') . "\n";
}
$put2 .= "}";
file_put_contents("map_extras.json", $put2);