-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmap.php
More file actions
executable file
·73 lines (56 loc) · 2.66 KB
/
map.php
File metadata and controls
executable file
·73 lines (56 loc) · 2.66 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace map;
include_once "page.php";
function get_html_characters_map($db, $player, $radius=3){
$str_position = $player["position"];
if (is_player_dimension_grid_based($db, $player)){
$page_id = get_first_page_with_position($db, $str_position, $player["dimension"]);
if ($page_id){
$arr_position = explode(" ", $str_position);
$query = "
SELECT
biome.color,
biome.characters
FROM
page
LEFT JOIN biome ON biome.id=page.biome_id
WHERE
page.dimension_id=".$player["dimension"]."
AND page.is_hidden=0
AND page.position=?
ORDER BY page.id ASC
";
$statement = $db->prepare($query);
$final_str = "";
for ($y = $arr_position[1] + $radius; $y >= $arr_position[1] - $radius; $y--){
for ($x = $arr_position[0] - $radius; $x <= $arr_position[0] + $radius; $x++){
if ($x == $arr_position[0] && $arr_position[1] == $y){
$final_str .= "<span style='color:white;'>"."☺"."</span>";
}
else{
$statement->execute([$x." ".$y]);
$position_fetch = $statement->fetch();
if ($position_fetch){
$final_str .= "<span style='color:#".$position_fetch["color"].";'>".mb_substr($position_fetch["characters"], 0, 1)."</span>";
}
else{
$final_str .= "?";
}
}
$final_str .= " ";
}
$final_str .= "<br>";
}
$final_str = "You stop for a minute and try to remember what the surroundings look like.<br>For every place you have not explored yet, you write a '?'.<br><br>".$final_str;
return $final_str;
}
else{
// Note: This is a bug! It should not happen
return "Unsure of where you are exactly, you fail to draw a map that reminds of you of the places you've been.";
}
}
else{
return "For this region's locations are bound by storylines, and not straight paths, it is impossible for you to make a map from memory.";
}
}
?>