buffer spaceterminal(buffer page) {
string trim( string text ) {
while( text.starts_with(" ") ) text = text.substring(1);
while( text.ends_with(" ") ) text = text.substring(0, text.length() - 1);
return text;
}
matcher m = "<td>Current planet: Planet Name: ([^<]+)<br>".create_matcher(page);
if( m.find() ) {
print("Planet name: " + m.group(1));
set_property("_spacegatePlanetName", m.group(1).trim());
}
m = "<br>Coordinates: ([^<]+)<br>".create_matcher(page);
if( m.find() ) {
print("Coordinates: " + m.group(1));
set_property("_spacegateCoordinates", m.group(1).trim());
}
m = "<br><p>Environmental Hazards:<Br>(.*)<br>Plant Life:".create_matcher(page);
if( m.find() ) {
string hazards = m.group(1).replace_string(" ","").replace_string("<br>","|").trim();
print("Hazards: " + hazards);
set_property("_spacegateHazards", hazards);
}
m = "<br>Plant Life: (<font color=\\w+>)?([^<]+)(</font>)?(<font color=\w+>(\\(hostile\\))</font>)?<br>".create_matcher(page);
if( m.find() ) {
if( m.group(3) != "" )
set_property("_spacegatePlantLife", m.group(2) + m.group(5));
else
set_property("_spacegatePlantLife", m.group(2).trim());
print("Plant Life: " + get_property("_spacegatePlantLife") );
}
m = "<br>Animal Life: (<font color=\\w+>)?([^<]+)(</font>)?(<font color=\w+>(\\(hostile\\))</font>)?<br>".create_matcher(page);
if( m.find() ) {
if( m.group(3) != "" )
set_property("_spacegateAnimalLife", m.group(2) + m.group(5));
else
set_property("_spacegateAnimalLife", m.group(2).trim());
print("Animal Life: " + get_property("_spacegateAnimalLife") );
}
m = "<br>Intelligent Life: (<font color=\\w+>)?([^<]+)(</font>)?(<font color=\w+>(\\(hostile\\))</font>)?<br>".create_matcher(page);
if( m.find() ) {
if( m.group(3) != "" )
set_property("_spacegateIntelligentLife", m.group(2) + m.group(5));
else
set_property("_spacegateIntelligentLife", m.group(2).trim());
print("Intelligent Life: " + get_property("_spacegateIntelligentLife") );
}
m = "<b>Spant</b>".create_matcher(page);
if( m.find() ) {
print("Spant chemical signature detected");
set_property("_spacegateSpant", true);
} else {
print("No spant chemical signature detected");
set_property("_spacegateSpant", false);
}
m = "<b>Murderbot</b>".create_matcher(page);
if( m.find() ) {
print("Murderbot chemical signature detected");
set_property("_spacegateMurderbot", true);
} else {
print("No Murderbot chemical signature detected");
set_property("_spacegateMurderbot", false);
}
m = "<br>ALERT: ANCIENT RUINS DETECTED<br>".create_matcher(page);
if( m.find() ) {
print("Ancient ruins detected");
set_property("_spacegateRuins", true);
} else {
print("No ancient ruins detected");
set_property("_spacegateRuins", false);
}
m = "<p>Spacegate Energy remaining: <b><font size=\\+2>(\\d+) </font>".create_matcher(page);
if( m.find() ) {
print("Spacegate turns left: " + m.group(1));
set_property("_spacegateTurnsLeft", m.group(1));
} else {
print("No spacegate turns left?");
set_property("_spacegateTurnsLeft", "0");
}
return page;
}