69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
$json = file_get_contents("/home/grizzly/.botany/grizzly_plant_data.json");
|
|
$data = json_decode($json, true);
|
|
$art = file_get_contents("/srv/botany/botany/art/" . $data['stage'] . ".txt");
|
|
|
|
// https://github.com/jifunks/botany/blob/master/menu_screen.py#L233
|
|
function water_gauge($last) {
|
|
$water_left_pct = 1 - ((time() - $last)/86400);
|
|
# don't allow negative value
|
|
$water_left_pct = max(0, $water_left_pct);
|
|
$water_left = intval(ceil($water_left_pct * 10));
|
|
//$water_string = "(" . (")" * $water_left) . ("." * (10 - $water_left)) . ") " . strval(intval($water_left_pct * 100)) . "% ";
|
|
$water_string = strval(intval($water_left_pct * 100)) . "% ";
|
|
return $water_string;
|
|
}
|
|
?>
|
|
|
|
<div class="plant">
|
|
<div class="status <?php echo $data['is_dead'] ? "dead" : "alive" ?>"><?php echo $data['is_dead'] ? "Dead 💀" : "Alive 👍" ?></div>
|
|
<div class="stats">
|
|
plant: <?=$data['stage']?><br />
|
|
score: <?=$data['score']?><br />
|
|
age: <?=$data['age']?><br />
|
|
generation: <?=$data['generation']?><br />
|
|
water: <?=water_gauge($data['last_watered'])?>
|
|
|
|
<em class="description"><?=$data['description']?></em>
|
|
</div>
|
|
<div class="ascii">
|
|
<pre><?=$art?></pre>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.plant {
|
|
display: flex;
|
|
width: 420px;
|
|
border: 4px dotted greenyellow;
|
|
padding: 10px;
|
|
border-radius: 1rem;
|
|
background-color: beige;
|
|
position: relative;
|
|
}
|
|
.stats {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
width: 50%;
|
|
}
|
|
.ascii {
|
|
width: 50%;
|
|
}
|
|
em.description {
|
|
margin-top: 10px;
|
|
}
|
|
.status {
|
|
position: absolute;
|
|
top: 0;
|
|
right: 0;
|
|
padding: 10px;
|
|
}
|
|
.alive {
|
|
color: green;
|
|
}
|
|
.dead {
|
|
color: red;
|
|
}
|
|
</style>
|