Added full source code

This commit is contained in:
Emmanuel BENOîT 2016-01-10 11:01:49 +01:00
commit 33f8586698
1377 changed files with 123808 additions and 0 deletions

View file

@ -0,0 +1,69 @@
<?php
class msgformat_abandon {
function msgformat_abandon($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Military Advisor';
}
function getSLink() {
return "";
}
function getRecipient() {
$name = $this->players->call('getName', $this->player);
return utf8entities($name);
}
function getRLink() {
return "";
}
function getSubject() {
if (is_array($this->data[0])) {
$c = count($this->data);
} else {
$c = 1;
}
return "$c planet" . ($c>1?"s":"") . " abandoned";
}
function getReplyLink() {
return "";
}
function getContents() {
if (is_array($this->data[0])) {
$data = $this->data;
} else {
$data = array($this->data);
}
$c = count($data);
$str = "Sir! Our forces have completed the evacuation of planet" . ($c>1?"s":"") . " ";
for ($i=0;$i<$c;$i++) {
if ($i > 0) {
if ($i == $c - 1) {
$str .= ' and ';
} else {
$str .= ', ';
}
}
$str .= "<a href='planet?id={$data[$i]['p_id']}'><b>"
. utf8entities($data[$i]['p_name']) . "</b></a>";
}
$str .= ". The citizens of th" . ($c>1?"ese":"is") . " world" . ($c>1?"s":"")
. " are left to fend for themselves.";
return $str;
}
}
?>

View file

@ -0,0 +1,47 @@
<?php
class msgformat_admin {
private $contents = array();
public function __construct($game) {
$this->game = $game;
$this->db = $game->db;
$this->players = $game->getLib('beta5/player');
$this->forums = $game->getLib('main/forums');
}
public function getRecipient() {
return utf8entities($this->players->call('getName', $this->player),ENT_COMPAT);
}
public function getSender() { return 'LegacyWorlds Administrators'; }
public function getSLink() { return ""; }
public function getRLink() { return ""; }
public function getReplyLink() { return ""; }
public function getSubject() {
$c = $this->readContents();
return $c['subject'];
}
public function getContents() {
$c = $this->readContents();
return $this->forums->call('substitute', $c['contents'], 't', 'f');
}
private function readContents() {
if (is_null($this->msgContents[$this->data['spam']])) {
$q = $this->db->query("SELECT * FROM admin_spam WHERE id = {$this->data['spam']}");
if (!($q && dbCount($q))) {
return array();
}
$this->msgContents[$this->data['spam']] = dbFetchHash($q);
}
return $this->msgContents[$this->data['spam']];
}
}
?>

View file

@ -0,0 +1,146 @@
<?php
class msgformat_alint {
function msgformat_alint($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getPlayer() {
if (is_null($this->data['player']))
return null;
return $this->players->call('get', $this->data['player']);
}
function getSender() {
return "Alliance [".utf8entities($this->data['tag']) . "]";
}
function getSLink() {
if (is_null($this->data['alliance'])) {
return "";
}
return "2,".$this->data['alliance'];
}
function getRecipient() {
$name = $this->players->call('getName', $this->player);
return utf8entities($name);
}
function getRLink() {
return "";
}
function getSubject() {
$p = $this->getPlayer();
switch ($this->data['msg_type']) :
case 0: $s = "A player has requested to join the alliance!"; break;
case 1: $s = "A player has cancelled his request to join!"; break;
case 2: $s = "You have been removed as " . utf8entities($p['name']) ."'s successor"; break;
case 3: $s = "You have been made " . utf8entities($p['name']) . "'s successor"; break;
case 4: $s = "[".utf8entities($this->data['tag'])."] has become a democracy"; break;
case 5: $s = "[".utf8entities($this->data['tag'])."] has become a dictature"; break;
case 6: $s = "You have stepped down from the head of [".utf8entities($this->data['tag'])."]"; break;
case 7: $s = "You are the new leader of [".utf8entities($this->data['tag'])."]"; break;
case 8: $s = "Leadership change in [".utf8entities($this->data['tag'])."]"; break;
case 9: $s = "A player has left the alliance"; break;
case 10: $s = "Request granted!"; break;
case 11: $s = "A player has been accepted into the alliance"; break;
case 12: $s = "Request rejected!"; break;
case 13: $s = "A request to join has been denied"; break;
case 14: $s = "Leadership change in [".utf8entities($this->data['tag'])."]"; break;
case 15: $s = "[".utf8entities($this->data['tag'])."] no longer has a leader!"; break;
case 16: $s = "New candidate for presidency"; break;
case 17: $s = "A candidate is no longer running for the alliance's presidency"; break;
case 18: $s = "You have taken the alliance's presidency"; break;
case 19: $s = "Leadership change in [".utf8entities($this->data['tag'])."]"; break;
case 20: $s = "New technology trading orders issued"; break;
endswitch;
return $s;
}
function getReplyLink() {
return "";
}
function getContents() {
$p = $this->getPlayer();
switch ($this->data['msg_type']) :
case 0:
$s = "Player <b>".utf8entities($p['name'])."</b> has sent a request to join the <b>[".utf8entities($this->data['tag'])."]</b> alliance.";
// FIXME: link to admission page
break;
case 1:
$s = "Player <b>".utf8entities($p['name'])."</b> has cancelled his request to join the <b>[".utf8entities($this->data['tag'])."]</b> alliance.";
break;
case 2:
$s = "You are no longer <b>".utf8entities($p['name'])."</b>'s successor at the head of <b>[".utf8entities($this->data['tag'])."]</b>.";
break;
case 3:
$s = "You have been designated by <b>".utf8entities($p['name'])."</b> to be his successor at the head of <b>[".utf8entities($this->data['tag'])."]</b>. ";
$s .= "If <b>".utf8entities($p['name'])."</b> leaves the alliance, you will automatically be in charge.";
break;
case 4:
$s = "By orders of <b>".utf8entities($p['name'])."</b>, the <b>[".utf8entities($this->data['tag'])."]</b> alliance has become a democracy.";
break;
case 5:
$s = "By orders of <b>".utf8entities($p['name'])."</b>, the <b>[".utf8entities($this->data['tag'])."]</b> alliance has become a dictature.";
break;
case 6:
$s = "You have stepped down from the head of the <b>[".utf8entities($this->data['tag'])."]</b> alliance.<br/><b>".utf8entities($p['name'])."</b>,";
$s .= "your successor, has assumed control of the alliance.";
break;
case 7:
$s = "<b>".utf8entities($p['name'])."</b>, who was the leader of the <b>[".utf8entities($this->data['tag'])."]</b> alliance, has stepped down from ";
$s .= "power.<br/>As his successor, you are the new leader of the alliance.";
break;
case 8:
$s = "The leader of the <b>[".utf8entities($this->data['tag'])."]</b> alliance has stepped down from power.<br/>";
$s .= "<b>".utf8entities($p['name'])."</b>, his successor, is the new leader of the alliance.";
break;
case 9:
$s = "<b>".utf8entities($p['name'])."</b> has left the <b>[".utf8entities($this->data['tag'])."]</b> alliance.";
break;
case 10:
$s = "You have been accepted into the <b>[".utf8entities($this->data['tag'])."]</b> alliance.";
break;
case 11:
$s = "Player <b>".utf8entities($p['name'])."</b> has been accepted into the <b>[".utf8entities($this->data['tag'])."]</b> alliance.";
break;
case 12:
$s = "Your request to join the <b>[".utf8entities($this->data['tag'])."]</b> alliance has been rejected.";
break;
case 13:
$s = "The request from player <b>".utf8entities($p['name'])."</b> to join the <b>[".utf8entities($this->data['tag'])."]</b> alliance has been rejected.";
break;
case 14:
$s = "<b>[".utf8entities($this->data['tag'])."]</b>'s leader has left the alliance. His successor, <b>".utf8entities($p['name'])."</b>,";
$s .= " has taken control of the alliance.";
break;
case 15:
$s = "<b>[".utf8entities($this->data['tag'])."]</b>'s leader, <b>".utf8entities($p['name'])."</b>, has left the alliance. Since ";
$s .= "<b>[".utf8entities($this->data['tag'])."]</b> no longer has a leader, all members can now vote to elect his successor.";
break;
case 16:
$s = "<b>".utf8entities($p['name'])."</b> is now running for <b>[".utf8entities($this->data['tag'])."]</b>'s presidency.";
break;
case 17:
$s = "<b>".utf8entities($p['name'])."</b> has cancelled his candidacy to <b>[".utf8entities($this->data['tag'])."]</b>'s presidency.";
break;
case 18:
$s = "You have taken presidency of the <b>[".utf8entities($this->data['tag'])."]</b> alliance.";
break;
case 19:
$s = "<b>".utf8entities($p['name'])."</b> has taken presidency of the <b>[".utf8entities($this->data['tag'])."]</b> alliance.";
break;
case 20:
$s = "New technology trading orders have been issued!<br/>You should check the alliance's <a href='techtrade'>technology trading</a> page to find out how they affect you.";
break;
endswitch;
return $s;
}
}
?>

View file

@ -0,0 +1,51 @@
<?php
class msgformat_alliance {
function msgformat_alliance($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return utf8entities($this->players->call('getName', $this->data['sender']));
}
function getSLink() {
if ($this->data['sender'] == $this->player) {
return "";
}
$pinf = $this->players->call('get', $this->data['sender']);
if (is_null($pinf)) {
return "";
}
return "0,".$this->data['sender'];
}
function getRecipient() {
return "Alliance [".utf8entities($this->data['tag']) . "]";
}
function getRLink() {
if (is_null($this->data['alliance']))
return "";
return "2,".$this->data['alliance'];
}
function getSubject() {
return utf8entities($this->data['subject']);
}
function getReplyLink() {
if ($this->data['sender'] == $this->player || is_null($this->data['alliance'])) {
return "";
}
return "2,".$this->data['alliance'].",".$this->data['id'];
}
function getContents() {
return preg_replace('/\n/', '<br/>', utf8entities($this->data['message']));
}
}
?>

View file

@ -0,0 +1,139 @@
<?php
class msgformat_battle {
var $sfn = array('gaships','fighters','cruisers','bcruisers');
var $sdn = array('GA Ships','Fighters','Cruisers','Battle Cruisers');
function msgformat_battle($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Military Advisor';
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
return "Battle report for " . utf8entities($this->data['planet']);
}
function getReplyLink() {
return "";
}
function getContents() {
$vacation = ($this->data['o_power'] == 0);
$str = 'Sir! ' . ($vacation ? "Forces " : "Our forces ")
. 'have been fighting in orbit around <a href="planet?id='.$this->data['planet_id'].'"><b>'
. utf8entities($this->data['planet']) . "</b></a>. "
. ($this->data['heroic_def'] == -1 ? 'The defending forces, overwhelmed, resisted to the last man. Their heroic actions have caused us unexpected losses. ' : '')
. ($this->data['heroic_def'] == 1 ? 'While our forces were greatly outnumbered, they opposed the attacking forces heroically. ' : '')
. "We have received an update on the latest casualties:</p>"
. "<table class='breport'><tr><th class='sname' rowspan='2'>&nbsp;</th><th colspan='2' class='fown'>Own Troops</th>";
if ($this->data['a_power'] > 0) {
$str .= "<th colspan='2' class='fally'>Allied Troops</th>";
}
$str .= "<th colspan='2' class='fenemy'>Enemy Troops</th></tr><tr><th>Start</th><th>Lost</th><th>Start</th><th>Lost</th>";
if ($this->data['a_power'] > 0) {
$str .= "<th>Start</th><th>Lost</th>";
}
$str .= "</th>";
for ($i=0;$i<4;$i++) {
$n = $this->sfn[$i];
if ($this->data["o_$n"] + $this->data["a_$n"] + $this->data["e_$n"] == 0) {
continue;
}
$str .= "<tr><th class='sname'>" . $this->sdn[$i] . "</th><td>" . number_format($this->data["o_$n"])
. "</td><td>" . number_format($this->data["ol_$n"]) . "</td>";
if ($this->data['a_power'] > 0)
$str .= "<td>" . number_format($this->data["a_$n"]) . "</td><td>" . number_format($this->data["al_$n"]) . "</td>";
$str .= "<td>" . number_format($this->data["e_$n"]) . "</td><td>" . number_format($this->data["el_$n"]) . "</td>";
$str .= "</tr>";
}
$tmode = $this->data['tmode'];
if ($tmode != 0) {
$str .= "<tr><th class='sname'>Turrets</th><td>";
if ($tmode == 1)
$str .= number_format($this->data["turrets"]) . "</td><td>" . number_format($this->data["l_turrets"]);
else
$str .= "-</td><td>-";
$str .= "</td><td>";
if ($tmode == 2)
$str .= number_format($this->data["turrets"]) . "</td><td>" . number_format($this->data["l_turrets"]) . "</td><td>";
elseif ($this->data['a_power'] > 0)
$str .= "-</td><td>-</td><td>";
if ($tmode == 3)
$str .= number_format($this->data["turrets"]) . "</td><td>" . number_format($this->data["l_turrets"]);
else
$str .= "-</td><td>-";
$str .= "</td></tr>";
}
$str .= "<tr><th class='sname'>Fleet Power</th><td>" . number_format($this->data['o_power']) . "</td><td>" . number_format($this->data['ol_power']) . "</td>";
if ($this->data['a_power'] > 0)
$str .= "<td>" . number_format($this->data['a_power']) . "</td><td>" . number_format($this->data['al_power']) . "</td>";
$str .= "<td>" . number_format($this->data['e_power']) . "</td><td>" . number_format($this->data['el_power']) . "</td></tr></table><p>";
$ePower = $this->data['e_power']; $eLoss = $this->data['el_power'];
$aPower = $this->data['a_power'] + $this->data['o_power'];
$aLoss = $this->data['al_power'] + $this->data['ol_power'];
if ($aPower == $aLoss && $ePower == $eLoss) {
$str .= "The fleets annihilated each other.";
} elseif ($ePower == $eLoss) {
$str .= "Victory is ours! The enemy has been annihilated!";
} elseif ($aPower == $aLoss) {
$str .= "Our forces were annihilated!";
} else {
$ePLoss = $eLoss / $ePower;
$aPLoss = $aLoss / $aPower;
if ($ePower - $eLoss > $aPower - $aLoss) {
$ratio = $ePLoss ? ($aPLoss / $ePLoss) : 11;
if ($ratio > 10) {
$str .= "Sir, our forces <i>have</i> to retreat from this losing battle!";
} elseif ($ratio > 3) {
$str .= "We are getting whacked. We need reinforcements!";
} elseif ($ratio > 1.2) {
$str .= "The situation doesn't look too good for us.";
} else {
$str .= "Our forces and the enemy's forces are a close match.";
}
} elseif ($ePower - $eLoss < $aPower - $aLoss) {
$ratio = $aPLoss ? ($ePLoss / $aPLoss) : 11;
if ($ratio > 10) {
$str .= "The enemy will soon be crushed.";
} else if ($ratio > 3) {
$str .= "We are clearly winning this fight.";
} else if ($ratio > 1.2) {
$str .= "The enemy is bound to lose this fight in the long run.";
} else {
$str .= "Our forces and the enemy's forces are a close match.";
}
} else {
$str .= "Our forces and the enemy's forces are a close match.";
}
}
return $str;
}
}
?>

View file

@ -0,0 +1,100 @@
<?php
class msgformat_bid {
function msgformat_bid($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Foreign Minister';
}
function getSLink() {
return "";
}
function getRecipient() {
return utf8entities($this->players->call('getName', $this->player));
}
function getRLink() {
return "";
}
function getSubject() {
$s = $this->data['is_planet'] == 't' ? "planet" : "fleet at";
return "New bid on $s " . utf8entities($this->data['pname']);
}
function getReplyLink() {
return "";
}
function getFleetText() {
$a = array();
$ids = array(
'gas' => "G.A. Ship",
'fighters' => "Fighter",
'cruisers' => "Cruiser",
'bcruisers' => "Battle Cruiser",
);
foreach ($ids as $i => $n) {
if ($this->data["f_$i"] == 0) {
continue;
}
$nb = $this->data["f_$i"];
array_push($a, "<b>$nb</b> $n" . ($nb > 1 ? "s" : ""));
}
return join(', ', $a);
}
function getContents() {
if (is_null($this->data['last_bidder'])) {
$str = "Sir, we had placed a bid on " . ($this->data['is_planet'] == 't' ? "planet" : "a fleet in orbit around") . " ";
if (!is_null($this->data['planet'])) {
$str .= "<a href='planet?id=" . $this->data['planet'] . "'>";
}
$str .= "<b>" . utf8entities($this->data['pname']) . "</b>" . (is_null($this->data['planet']) ? "" : "</a>");
$fs = $this->getFleetText();
if ($this->data['is_planet'] == 'f') {
$str .= " ($fs)";
} elseif ($fs != '') {
$str .= " (along with the following fleet: $fs)";
}
$str .= ".<br/>We have been informed that someone just placed a higher bid. The new price is <b>&euro;";
$str .= number_format($this->data['new_price']) . "</b>.";
if (!is_null($this->data['offer'])) {
$str .= '<br/>We should <a href="market?p=p&po='.$this->data['offer'].'">place a higher bid</a>.';
}
} else {
$str = "Sir, we have received an offer for " . ($this->data['is_planet'] == 't' ? "planet" : "the fleet in orbit around") . " ";
if (!is_null($this->data['planet'])) {
$str .= "<a href='planet?id=" . $this->data['planet'] . "'>";
}
$str .= "<b>" . utf8entities($this->data['pname']) . "</b>" . (is_null($this->data['planet']) ? "" : "</a>");
$fs = $this->getFleetText();
if ($this->data['is_planet'] == 'f') {
$str .= " ($fs)";
} elseif ($fs != '') {
$str .= " (being sold with the following fleet: $fs)";
}
$str .= ".<br/>";
$pinf = $this->players->call('get', $this->data['last_bidder'], true);
if (!$pinf['quit']) {
$str .= '<a href="message?a=c&ct=0&id='.$this->data['last_bidder'].'">';
}
$str .= utf8entities($pinf['name']);
if (!$pinf['quit']) {
$str .= '</a>';
}
$str .= " is offering to buy the " . ($this->data['is_planet'] == 'f' ? "fleet" : "planet") . " for <b>&euro;";
$str .= number_format($this->data['new_price']) . "</b>.";
}
return $str;
}
}
?>

View file

@ -0,0 +1,43 @@
<?php
class msgformat_cash {
function msgformat_cash($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Foreign Minister';
}
function getSLink() {
return "";
}
function getRecipient() {
return utf8entities($this->players->call('getName', $this->player),ENT_COMPAT);
}
function getRLink() {
return "";
}
function getSubject() {
return "Cash donation received!";
}
function getReplyLink() {
return "";
}
function getContents() {
$pinf = $this->players->call('get', $this->data['p_id'], true);
return "Sir! We just received a cash donation amounting to <b>&euro;"
. number_format($this->data['amount']) . "</b> from player "
. ($pinf['quit'] == 1 ? '' : "<a href='message?a=c&ct=0&id={$this->data['p_id']}'>")
. "<b>" . utf8entities($pinf['name'],ENT_COMPAT) . "</b>" . ($pinf['quit'] == 1 ? "" : "</a>") . "!";
}
}
?>

View file

@ -0,0 +1,241 @@
<?php
class msgformat_ctf {
public function __construct($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
$this->alliance = $game->getLib('beta5/alliance');
}
public function getSLink() { return ""; }
public function getRLink() { return ""; }
public function getReplyLink() { return ""; }
public function getSender() { return "LegacyWorlds"; }
public function getRecipient() {
$name = $this->players->call('getName', $this->player);
return utf8entities($name);
}
public function getSubject() {
// Get the team's data if needed
if (!is_null($this->data['team'])) {
$this->team = $this->alliance->call('get', $this->data['team']);
}
// Create the subject
switch ($this->data['msg_type']) :
default:
case 0: $rv = "Welcome!"; break;
case 1: $rv = "A player joined the team"; break;
case 2: $rv = "We are holding the targets"; break;
case 3: $rv = $this->team['name'] . " has the targets!"; break;
case 4: $rv = "Targets lost - we must retake"; break;
case 5:
case 6: $rv = "Targets lost"; break;
case 7: $rv = $this->team['name'] . " could lose the targets"; break;
case 8:
case 9: $rv = $this->team['name'] . " lost the targets"; break;
case 10: $rv = "We are still holding!"; break;
case 11: $rv = $this->team['name'] . " is still holding!"; break;
case 12: $rv = "Victory!... sort of."; break;
case 13: $rv = $this->team['name'] . " owned us"; break;
case 14: $rv = "WE HAVE WON THE GAME!"; break;
case 15: $rv = "We were defeated :'("; break;
endswitch;
return $rv;
}
public function getContents() {
// Get the team's data if needed
if (!is_null($this->data['team']) && is_null($this->team)) {
$this->team = $this->alliance->call('get', $this->data['team']);
}
// Generate the contents
$generators = array(
"Welcome", "Join",
"Hold", "OthersHold",
"LostGrace", "Lost", "GraceExpired",
"OthersLostGrace", "OthersLost", "OthersGraceExpired",
"Half", "OthersHalf",
"Win", "Lose",
"WonGame", "LostGame"
);
$v = "msg" . $generators[$this->data['msg_type']];
ob_start();
$this->$v();
$rv = ob_get_contents();
ob_end_clean();
return $rv;
}
private function msgWelcome() {
$game = $this->players->game;
?>
Welcome to this special <i>King of the Hills</i> LegacyWorlds game!<br/>
<br/>
You have been assigned to <b>[<?=$this->team['tag']?>]</b>, the
<?=strtolower($this->team['name'])?>.<br/>
<br/>
Before you start playing, a few explanations on this special minigame may be required.<br/>
<br/>
Here, the goal is for your team to control special star systems called <i>targets</i> for
<b><?=$game->params['v2time']?> hours</b> in a row. If you succeed, the team will earn
<b><?=$game->params['v2points']?></b> points.<br/>
<?php
if ($game->params['v2grace']) {
?>
<br/>
However, if you lose control on the targets, you will still have
<b><?=$game->params['v2grace']?> hours</b> to recover them without restarting the
countdown to victory. Of course, the time during which your team no longer holds the
targets does not count in the race towards victory.<br/>
<?php
}
?>
<br/>
When a team wins a round, the targets are made neutral again, and their factories and turrets
are reset. All planets which had been destroyed by Wormhole Supernovas are restored, and all
planets a team owns in another team's territory are neutralized. Players who no longer had
planets are respawned at their original location. In addition, fleets are equalized so that
no-one starts the new round with more fleets than the others.<br/>
<br/>
The first team to reach <b>100</b> points will win the game.
<?php
}
private function msgJoin() {
$name = $this->players->call('getName', $this->data['time_stamp']);
?>
A new player, <a href='?a=c&ct=0&id=<?=$this->data['time_stamp']?>'><b><?=utf8entities($name)?></b></a>,
has been assigned to the <?=strtolower($this->team['name'])?>.
<?php
}
private function msgHold() {
?>
Our team is now holding all the targets! We must hold them until
<b><?=gmstrftime("%H:%M", $this->data['time_stamp'] + 60)?></b> (<?=gmstrftime("%d/%m/%Y", $this->data['time_stamp'])?>)
to win this round.
<?php
}
private function msgOthersHold() {
?>
<b><?=$this->team['tag']?></b>, the <?=strtolower($this->team['name'])?>, is now holding all the targets!<br/>
We must retake them at all cost, otherwise the <?=strtolower($this->team['name'])?> will win this round at
<b><?=gmstrftime("%H:%M", $this->data['time_stamp'] + 60)?></b> (<?=gmstrftime("%d/%m/%Y", $this->data['time_stamp'])?>).
<?php
}
private function msgLostGrace() {
?>
Our team is no longer holding the targets... If we do not retake them before
<b><?=gmstrftime("%H:%M", $this->data['time_stamp'] - 60)?></b> (<?=gmstrftime("%d/%m/%Y", $this->data['time_stamp'])?>),
the countdown to victory will be reset and we'll need to do it all over again...
<?php
}
private function msgLost() {
?>
Our team is no longer holding the targets :-(<br/>
The countdown to victory has been reset and we need to start all over again...
<?php
}
private function msgGraceExpired() {
?>
Our team is no longer holding the targets, and we lost our chance to retake them in time...<br/>
The countdown to victory has been reset and we need to start all over again...
<?php
}
private function msgOthersLostGrace() {
?>
<b><?=$this->team['tag']?></b>, the <?=strtolower($this->team['name'])?>, is no longer holding the targets!<br/>
However, if they retake the targets before <b><?=gmstrftime("%H:%M", $this->data['time_stamp'] - 60)?></b>
(<?=gmstrftime("%d/%m/%Y", $this->data['time_stamp'])?>),
the countdown to their victory will start again ... We must prevent them from retaking!
<?php
}
private function msgOthersLost() {
?>
<b><?=$this->team['tag']?></b>, the <?=strtolower($this->team['name'])?>, is no longer holding the targets!
The countdown has been cancelled!
<?php
}
private function msgOthersGraceExpired() {
?>
<b><?=$this->team['tag']?></b>, the <?=strtolower($this->team['name'])?>, is no longer holding the targets and
didn't manage to retake them in time! The countdown has been cancelled!
<?php
}
private function msgHalf() {
?>
Our team is now holding all the targets! We must hold them until
<b><?=gmstrftime("%H:%M", $this->data['time_stamp'] + 60)?></b> (<?=gmstrftime("%d/%m/%Y", $this->data['time_stamp'])?>)
to win this round.
<?php
}
private function msgOthersHalf() {
?>
<b><?=$this->team['tag']?></b>, the <?=strtolower($this->team['name'])?>, is still holding all the targets!<br/>
We must retake them at all cost, otherwise the <?=strtolower($this->team['name'])?> will win this round at
<b><?=gmstrftime("%H:%M", $this->data['time_stamp'] + 60)?></b> (<?=gmstrftime("%d/%m/%Y", $this->data['time_stamp'])?>).
<?php
}
private function msgWin() {
?>
Our team has just won a round of the game!<br/>
<br/>
As a consequence, the map has been reset and everyone has been respawned...<br/>
Keep sharp, the battle isn't over yet.
<?php
}
private function msgLose() {
?>
We just lost a round of the game to <b>[<?=$this->team['tag']?>]</b>, the <?=strtolower($this->team['name'])?>.<br/>
<br/>
As a consequence, the map has been reset and everyone has been respawned...<br/>
We still stand a chance of winning!
<?php
}
private function msgWonGame() {
?>
The game is finished - AND WE WON!
<?php
}
private function msgLostGame() {
?>
The game is finished - but we lost. <b>[<?=$this->team['tag']?>]</b>, the <?=strtolower($this->team['name'])?>,
overpowered us.
<?php
}
}
?>

View file

@ -0,0 +1,104 @@
<?php
class msgformat_detect {
private $contents = array();
public function __construct($game) {
$this->game = $game;
$this->db = $game->db;
$this->players = $game->getLib('beta5/player');
$this->forums = $game->getLib('main/forums');
}
public function getRecipient() {
return utf8entities($this->players->call('getName', $this->player),ENT_COMPAT);
}
public function getSender() {
return ($this->data['is_owner'] == 't' ? 'Military Advisor' : ('Governor of ' . $this->data['p_name']));
}
public function getSLink() { return ""; }
public function getRLink() { return ""; }
public function getReplyLink() { return ""; }
public function getSubject() {
if ($this->data['is_owner'] == 't') {
return "Fleet detected at {$this->data['p_name']}";
}
return "Fleet detected in hyperspace";
}
public function getContents() {
$func = ($this->data['is_owner'] == 't') ? "ownFleet" : "otherFleet";
ob_start();
$this->$func();
$x = ob_get_contents();
ob_end_clean();
return $x;
}
private function ownFleet() {
?>
One of our fleets in Hyperspace stand-by around planet <b><?=utf8entities($this->data['p_name'])?></b>
has been detected by the planet's hyperspace beacon.<br/>
<br/>
<?
switch ($this->data['i_level']) :
case 0:
echo "The beacon didn't manage to gather any information regarding the fleet, tho.";
break;
case 1:
echo "The beacon managed to obtain a very rough estimate of our fleet's size.";
break;
case 2:
echo "The beacon managed to obtain a rough estimate of our fleet's size.";
break;
case 3:
echo "The beacon managed to obtain our fleet's size.";
break;
case 4:
echo "The beacon identified our fleet!";
break;
endswitch;
}
private function otherFleet() {
?>
Our hyperspace beacon around planet <b><?=utf8entities($this->data['p_name'])?></b> has detected a fleet
in Hyperspace.<br/>
<br/>
<?
switch ($this->data['i_level']) :
case 0:
echo "However, no additional information could be gathered due to heavy jamming.";
break;
case 1:
echo "Jamming prevented us from obtaining much information, however the beacon "
. "transmitted a very rough estimate of the fleet's size. Its power is "
. "estimated at <b>" . number_format($this->data['fl_size'])
. "</b> (+/- 25%).";
break;
case 2:
echo "Jamming prevented us from obtaining much information, however the beacon "
. "transmitted a rough estimate of the fleet's size. Its power is "
. "estimated at <b>" . number_format($this->data['fl_size'])
. "</b> (+/- 7.5%).";
break;
case 3:
echo "The beacon was able to compute the fleet's size; its power is <b>"
. number_format($this->data['fl_size']) . "</b>. However, because of jamming, "
. "the beacon could not identify the fleet.";
break;
case 4:
echo "The beacon completely identified the fleet! Its power is <b>"
. number_format($this->data['fl_size']) . "</b>, and it is owned by <b>"
. utf8entities($this->data['flo_name']) . "</b>.";
break;
endswitch;
}
}
?>

View file

@ -0,0 +1,74 @@
<?php
class msgformat_endprotection {
public function __construct($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
public function getSender() {
return 'Peacekeeper Headquarters';
}
public function getSLink() {
return '';
}
public function getRecipient() {
$name = $this->players->call('getName', $this->player);
return utf8entities($name);
}
public function getRLink() {
return '';
}
public function getSubject() {
return 'You are no longer under our protection';
}
public function getReplyLink() {
return '';
}
public function getContents() {
ob_start();
switch ($this->data['end_type']) {
case 'EXP':
?>
The period of 20 days during which we were meant to protect you has expired.<br/>
We are confident that you are now strong enough to survive, and wish you the best of luck.<br/>
<br/>
Kind regards,<br/>
Peacekeeper Commander Dapkor
<?
break;
case 'BRK':
?>
You have decided that you no longer require our services.<br/>
We wish you the best of luck in your future endeavours, and remain at your disposal
should you need our help again.<br/>
<br/>
Kind regards,<br/>
Peacekeeper Commander Multair
<?
break;
case 'ACT':
?>
You have sent a ship outside your system, therefore revoking our agreement.<br/>
We wish you the best of luck in your future endeavours, and remain at your disposal
should you need our services again.<br/>
<br/>
Kind regards,<br/>
Peacekeeper Commander Hestaks
<?
break;
}
$str = ob_get_contents();
ob_end_clean();
return $str;
}
}
?>

View file

@ -0,0 +1,114 @@
<?php
class msgformat_flmove {
var $compn = array('G.A. ship', 'G.A. ships', 'fighter', 'fighters', 'cruiser', 'cruisers', 'batlle cruiser', 'battle cruisers');
var $compi = array('gaships', 'fighters', 'cruisers', 'bcruisers');
var $fmData = null;
var $fmId = null;
function msgformat_flmove($game) {
$this->game = $game;
$this->db = $game->db;
$this->players = $game->getLib('beta5/player');
}
function getMovementData() {
if (!is_null($this->fmData) && $this->fmId == $this->data['id']) {
return;
}
$q = $this->db->query("SELECT * FROM flmove_data WHERE id={$this->data['id']}");
$this->fmData = array();
$isMe = true;
while ($r = dbFetchHash($q)) {
$isMe = $isMe && ($r['f_owner'] == $this->player);
array_push($this->fmData, $r);
}
$this->isOwnArrival = $isMe;
$this->fmId = $this->data['id'];
}
function getSender() {
return 'Military Advisor';
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
$this->getMovementData();
if ($this->isOwnArrival) {
if (count($this->fmData) > 1) {
$str = "Our fleets have";
} else {
$str = "Our fleet has";
}
$str .= " arrived at ";
} else {
$str .= "Fleet movement at ";
}
$str .= utf8entities($this->data['p_name']);
return $str;
}
function getReplyLink() {
return "";
}
function getComposition($r) {
$rv = array();
for ($i=0;$i<4;$i++) {
$n = $r['f_' . $this->compi[$i]];
if ($n == 0) {
continue;
}
array_push($rv, "<b>" . number_format($n) . "</b> " . $this->compn[$i*2 + ($n>1 ? 1 : 0)]);
}
return join(', ', $rv);
}
function getContents() {
$this->getMovementData();
$pl = (count($this->fmData) > 1);
if ($this->isOwnArrival) {
$str = "Sir! The following fleet" . ($pl ? "s have" : " has") . " arrived at " . ($pl ? "their" : "its")
. " destination, <a href='planet?id={$this->data['p_id']}'><b>" . utf8entities($this->data['p_name'])
. "</b></a>:<br/>";
foreach ($this->fmData as $r) {
$str .= "<br/>Fleet <b>" . utf8entities($r['f_name']) . "</b> coming from <a href='planet?id={$r['from_id']}'><b>"
. utf8entities($r['from_name']) . "</b></a> (composition: ";
$str .= $this->getComposition($r);
$str .= "; power: <b>" . number_format($r['f_power']) . "</b>)";
}
} else {
$str = "Sir! The fleets stationed in orbit around <a href='planet?id={$this->data['p_id']}'><b>" . utf8entities($this->data['p_name'])
. "</b></a> report the following event" . ($pl ? "s" : "") . ":<br/>";
foreach ($this->fmData as $r) {
$str .= "<br/>A " . ($r['hostile'] == 'f' ? "friendly" : "hostile") . " fleet, <b>" . utf8entities($r['f_name']) . "</b>, owned by "
. "<a href='message?a=c&ct=0&id={$r['f_owner']}'><b>" . utf8entities($this->players->call('getName', $r['f_owner']))
. "</b></a>, has ";
if ($r['arrived'] == 'f') {
$str .= "left orbit";
} else {
$str .= "entered orbit, coming from <a href='planet?id={$r['from_id']}'><b>" . utf8entities($r['from_name']) . "</b></a>";
}
$str .= " (composition: ";
$str .= $this->getComposition($r);
$str .= "; power: <b>" . number_format($r['f_power']) . "</b>)";
}
}
return $str;
}
}
?>

View file

@ -0,0 +1,53 @@
<?php
class msgformat_flswitch {
function msgformat_flswitch($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Military Advisor';
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
return "Fleets forced to attack on " . utf8entities($this->data['pname']);
}
function getReplyLink() {
return "";
}
function getContents() {
if (!is_null($this->data['planet'])) {
$a1 = '<a href="planet?id='.$this->data['planet'].'"><b>';
$a2 = '</b></a>';
} else {
$a1="<b>";$a2="</b>";
}
$str = "Sir, the owner of planet $a1".utf8entities($this->data['pname'])."$a2 has added us to his enemy list.<br/>";
$str .= "Our fleets have been forced to attack the planet as a consequence and it will not be possible to switch them back ";
$str .= "unless the owner removes us from his enemy list. Our fleets are stuck there until a Battle Tick happens.<br/>";
$nf = $this->data['n_fleets'];
$str .= "<b>$nf</b> of our fleets " . ($nf>1?'are':'is') . " in orbit around the planet, with a total fleet power of <b>";
$str .= number_format($this->data['fpower']) . "</b>.";
return $str;
}
}
?>

View file

@ -0,0 +1,76 @@
<?php
class msgformat_hsloss {
var $compn = array('G.A. ship', 'G.A. ships', 'fighter', 'fighters', 'cruiser', 'cruisers', 'batlle cruiser', 'battle cruisers');
var $compi = array('gaships', 'fighters', 'cruisers', 'bcruisers');
function msgformat_hsloss($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Military Advisor';
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
if (is_array($this->data[0])) {
$data = $this->data[0];
} else {
$data = $this->data;
}
return "Ships lost in Hyperspace around " . utf8entities($data['p_name']);
}
function getReplyLink() {
return "";
}
function getFleetComposition($r) {
$rv = array();
for ($i=0;$i<4;$i++) {
$n = $r[$this->compi[$i]];
if ($n == 0) {
continue;
}
array_push($rv, "<b>" . number_format($n) . "</b> " . $this->compn[$i*2 + ($n>1 ? 1 : 0)]);
}
return join(', ', $rv);
}
function getContents() {
if (is_array($this->data[0])) {
$data = $this->data;
} else {
$data = array($this->data);
}
$str = "Sir! Some of our ships standing by in Hyperspace in the vicinity of <a href='"
. "planet?id={$data['p_id']}'><b>" . utf8entities($data['p_name'])
. "</b></a> were lost; a ceremony will be held today in their honor while these "
. "poor guys drift in Hyperspace until they starve to death.<br/><br/>"
. "The following report indicates the amount of ships lost.<br/>";
foreach ($data as $f) {
$str .= "<br/>Fleet <b>" . utf8entities($f['f_name']) . "</b> lost "
. $this->getFleetComposition($f) . " (lost fleet power: <b>"
. number_format($f['power']) . "</b>)";
}
return $str;
}
}
?>

View file

@ -0,0 +1,67 @@
<?php
class msgformat_kfleet {
function msgformat_kfleet($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Military Advisor';
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
return "Fleets lost due to insufficient funds";
}
function getReplyLink() {
return "";
}
function getContents() {
$str = "Sir! Due to insufficient funds, we have been unable to pay for our fleets' upkeep. ";
$types = array('gaships','fighters','cruisers','bcruisers');
$names = array('G.A. ship', 'fighter', 'cruiser', 'battle cruiser');
$sum = 0;
for ($i=0;$i<4;$i++) {
$sum += $this->data[$types[$i]];
}
$add = 0;
for ($i=0;$i<4;$i++) {
$n = $this->data[$types[$i]];
if ($n == 0) {
continue;
}
$sum -= $n;
if ($sum == 0 && $add != 0) {
$str .= ' and ';
} elseif ($add != 0) {
$str .= ', ';
}
$add += $n;
$str .= "<b>".number_format($n)."</b> " . $names[$i] . ($n > 1 ? 's' : '');
}
$str .= " ha" . ($add > 1 ? "ve" : "s") . " been lost.";
return $str;
}
}
?>

View file

@ -0,0 +1,53 @@
<?php
class msgformat_kimpr {
function msgformat_kimpr($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Civilian Advisor';
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
return "Improvements lost due to insufficient funds";
}
function getReplyLink() {
return "";
}
function getContents() {
$str = "Sir! Due to insufficient funds, we have been unable to pay for our planetary improvements' upkeep. ";
$tl = $this->data['turrets']; $ml = $this->data['factories'];
if ($tl > 0) {
$str .= "<b>".number_format($tl)."</b> turret" . ($tl>1?'s':'');
if ($ml > 0) {
$str .= " and ";
}
}
if ($ml > 0) {
$str .= "<b>".number_format($ml)."</b> military factor" . ($ml>1?"ies":"y");
}
$str .= " ha" . ($ml+$tl>1?"ve":"s") . " been destroyed!";
return $str;
}
}
?>

View file

@ -0,0 +1,78 @@
<?php
class msgformat_leave {
function msgformat_leave($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Legacy Worlds';
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
$pinf = $this->players->call('get', $this->data['player'], true);
$str = utf8entities($pinf['name']) . " has ";
switch ($this->data['reason']) :
case 'QUIT': $str .= "quit the game"; break;
case 'INAC': $str .= "become inactive"; break;
case 'KICK': $str .= 'been kicked from the game'; break;
endswitch;
return $str;
}
function getReplyLink() {
return "";
}
function getContents() {
$pinf = $this->players->call('get', $this->data['player'], true);
$str = "<b>" . utf8entities($pinf['name']) . "</b> ";
switch ($this->data['reason']) :
case 'QUIT': $str .= "has decided he had enough of this world and has just left the game."; break;
case 'INAC': $str .= "has disappeared, it would seem. He hasn't logged on for 30 days."; break;
case 'KICK': $str .= 'probably did something very, very bad and got kicked from the game.'; break;
endswitch;
if (!is_null($this->data['tag']))
$str .= " He has been removed from the members of the <b>" . utf8entities($this->data['tag'])
. "</b> alliance.";
if ($this->data['ally'] == 't')
$str .= " Since you had him in your Trusted Allies list, he has been removed from it.";
$str .= "<br/>";
if ($this->data['sales_from'] + $this->data['sales_to'] > 0) {
$str .= "<br/>";
if ($this->data['sales_from'] > 0)
$str .= "<b>" . number_format($this->data['sales_from']) . "</b> sale"
. ($this->data['sales_from']>1?"s":"") . " from this player ha"
. ($this->data['sales_from']>1?"ve":"s") . " been cancelled.<br/>";
if ($this->data['sales_to'] > 0)
$str .= "<b>" . number_format($this->data['sales_to']) . "</b> sale"
. ($this->data['sales_to']>1?"s":"") . " to this player ha"
. ($this->data['sales_to']>1?"ve":"s") . " been cancelled.<br/>";
}
$str .= "<br/><b>" . utf8entities($pinf['name']) . "</b> will"
. ($this->data['reason'] == 'KICK' ? " <i>NOT</i>" : "")
. " be missed.";
return $str;
}
}
?>

View file

@ -0,0 +1,74 @@
<?php
class msgformat_ownerch {
function msgformat_ownerch($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Military Advisor';
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
switch ($this->data['status']) :
case 'TAKE': $s = "We have taken control of "; break;
case 'LOSE': $s = "We have lost control of "; break;
case 'VIEW': $s = "Owner change on "; break;
endswitch;
$s .= utf8entities($this->data['p_name']);
return $s;
}
function getReplyLink() {
return "";
}
function getContents() {
$planet = '<a href="planet?id='.$this->data['p_id'].'"><b>'.utf8entities($this->data['p_name'])."</b></a>";
switch ($this->data['status']) :
case 'TAKE':
$s = "Sir! We have seized control of planet $planet";
if (!is_null($this->data['owner'])) {
$pid = $this->data['owner'];
$pn = utf8entities($this->players->call('getName', $pid));
$s .= " from the clutches of <a href='message?a=c&ct=0&id=$pid'><b>$pn</b></a>, "
. "its former owner";
} else {
$s .= " from the local (lack of) government.";
}
$s .= ".";
break;
case 'LOSE':
$pid = $this->data['owner'];
$pn = utf8entities($this->players->call('getName', $pid));
$s = "We have lost control of planet $planet, which was taken from us by "
. "<a href='message?a=c&ct=0&id=$pid'><b>$pn</b></a>.";
break;
case 'VIEW':
$pid = $this->data['owner'];
$pn = utf8entities($this->players->call('getName', $pid));
$s = "Sir! Our forces orbitting $planet report that "
. "<a href='message?a=c&ct=0&id=$pid'><b>$pn</b></a> has taken "
. "control of the planet.";
break;
endswitch;
return $s;
}
}
?>

View file

@ -0,0 +1,97 @@
<?php
class msgformat_pkwarning {
public function __construct($game) {
$this->game = $game;
$this->db = $game->getDBAccess();
$this->players = $game->getLib('beta5/player');
}
public function getSender() {
return 'Peacekeeper Headquarters';
}
public function getSLink() {
return '';
}
public function getRecipient() {
$name = $this->players->call('getName', $this->player);
return utf8entities($name);
}
public function getRLink() {
return '';
}
public function getSubject() {
switch ($this->data['msg_type']) {
case 'W':
return 'Your fleets have entered protected territory';
case 'D':
return 'Your fleets will be destroyed';
case 'E':
return 'You have been declared an ennemy of the Peacekeepers';
}
return 'Huh? wrong message type';
}
public function getReplyLink() {
return '';
}
public function getContents() {
$planets = "<ul><li>" . join('</li><li>', $this->getPlanets()) . "</li></ul>";
ob_start();
switch ($this->data['msg_type']) {
case 'W':
?>
This is a warning from Peacekeeper Headquarters. Your fleets have entered Peacekeeper-protected territories. If
you do not retreat before <b><?=gmstrftime("%H:%M", $this->data['delay'])?></b>, we will be forced to take action.<br/>
This warning applies to the following planets:</p>
<?=$planets?>
<p>Best regards,<br/>
Peacekeeper Commander Dapkor
<?
break;
case 'D':
?>
Your hostile actions will not go unpunished! The Peacekeepers will see to it that your fleets are destroyed on the
following planets:</p>
<?=$planets?>
<p>Regards,<br/>
Peacekeeper Commander Multair
<?
break;
case 'E':
?>
Your continued hostile behaviour has forced us to declare you an enemy of the Peacekeepers. Your fleets will be destroyed
on sight whenever you enter protected territory, and we will not protect you if you need it.<br/>
In addition, your fleets will be destroyed on the following planets:
</p>
<?=$planets?>
<p>Sanctions against you will end at <b><?=gmstrftime("%H:%M</b> on <b>%d/%m/%Y", $this->data['delay'])?></b>.
<br/>
Peacekeeper Commander Hestaks
<?
break;
}
$str = ob_get_contents();
ob_end_clean();
return $str;
}
private function getPlanets() {
$q = $this->db->query("SELECT planet, p_name FROM pkwarning_planet WHERE id = {$this->data['id']}");
$planets = array();
while ($r = dbFetchArray($q)) {
array_push($planets, "<a href='planet?id={$r[0]}'>" . utf8entities($r[1]) . "</a>");
}
return $planets;
}
}
?>

View file

@ -0,0 +1,58 @@
<?php
class msgformat_planet {
function msgformat_planet($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
$this->planets = $game->getLib('beta5/planet');
}
function getSender() {
$pinf = $this->players->call('getName', $this->data['sender']);
return utf8entities($pinf);
}
function getSLink() {
if ($this->data['sender'] == $this->player) {
return "";
}
$pinf = $this->players->call('get', $this->data['sender']);
if (is_null($pinf)) {
return "";
}
return "0,".$this->data['sender'];
}
function getRecipient() {
return "Planet ".utf8entities($this->data['pname']);
}
function getRLink() {
if (is_null($this->data['planet'])) {
return "";
}
$pinf = $this->planets->call('byId', $this->data['planet']);
if ($pinf['owner'] == $this->player) {
return "";
}
return "1,".$this->data['planet'];
}
function getSubject() {
return utf8entities($this->data['subject']);
}
function getReplyLink() {
if ( $this->data['sender'] == $this->player || is_null($this->data['planet'])) {
return "";
}
return "0,".$this->data['sender'].",".$this->data['id'];
}
function getContents() {
return preg_replace('/\n/', '<br/>', utf8entities($this->data['message']));
}
}
?>

View file

@ -0,0 +1,49 @@
<?php
class msgformat_plsc {
function msgformat_plsc($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Foreign Minister';
}
function getSLink() {
return "";
}
function getRecipient() {
return utf8entities($this->players->call('getName', $this->player));
}
function getRLink() {
return "";
}
function getSubject() {
return "Transfer of planet " . utf8entities($this->data['p_name']) . " cancelled!";
}
function getReplyLink() {
return "";
}
function getContents() {
$p1 = $this->players->call('get', $this->data['seller'], true);
$p1s = ($p1['quit'] == 0 ? "<a href='message?a=c&ct=0&id={$this->data['seller']}'>" : "")
. "<b>" . utf8entities($p1['name']) . "</b>" . ($p1['quit'] == 0 ? "</a>" : "");
$p2 = $this->players->call('get', $this->data['taker'], true);
$p2s = ($p2['quit'] == 0 ? "<a href='message?a=c&ct=0&id={$this->data['taker']}'>" : "")
. "<b>" . utf8entities($p2['name']) . "</b>" . ($p2['quit'] == 0 ? "</a>" : "");
return "The sale of planet <a href='planet?id={$this->data['p_id']}'><b>"
. utf8entities($this->data['p_name']) . "</b></a> has been cancelled.<br/>"
. "The seller, $p1s, lost the planet to the forces of $p2s.";
}
}
?>

View file

@ -0,0 +1,50 @@
<?php
class msgformat_rename {
function msgformat_rename($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Head of Intelligence';
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf,ENT_COMPAT);
}
function getRLink() {
return "";
}
function getSubject() {
return "Planet " . utf8entities($this->data['old_name'],ENT_COMPAT) . " has been renamed";
}
function getReplyLink() {
return "";
}
function getContents() {
$str = "Sir! A planet we were ";
switch ($this->data['status']) :
case 'ORBIT': $str .= "orbitting"; break;
case 'MOVE': $str .= "moving towards"; break;
case 'PROBE': $str .= "shamelessly spying on with our probes"; break;
endswitch;
$str .= ", <b>" . utf8entities($this->data['old_name'],ENT_COMPAT) . "</b>, has been renamed "
. "by its owner to <a href='planet?id={$this->data['planet']}'><b>"
. utf8entities($this->data['new_name'],ENT_COMPAT) . "</b></a>.";
return $str;
}
}
?>

View file

@ -0,0 +1,76 @@
<?php
class msgformat_resdipl {
function msgformat_resdipl($game) {
$this->game = $game;
$this->db = $game->db;
$this->players = $game->getLib('beta5/player');
}
function getOffer() {
$q = $this->db->query("SELECT * FROM research_assistance WHERE id=".$this->data['offer']);
return dbFetchHash($q);
}
function getSender() {
return "Science Minister";
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
$o = $this->getOffer();
$p1 = $this->players->call('get', $o['player'], true);
$p2 = $this->players->call('get', $o['offer_to'], true);
switch ($this->data['msg_id']) :
case 0:
$s = "Scientific assistance offer from " . utf8entities($p1['name']);
break;
case 1: case 2:
$s = "[UPDATE] Scientific assistance to " . utf8entities($p2['name']);
break;
endswitch;
return $s;
}
function getReplyLink() {
return "";
}
function getContents() {
$o = $this->getOffer();
$p1 = $this->players->call('get', $o['player'], true);
$p2 = $this->players->call('get', $o['offer_to'], true);
switch ($this->data['msg_id']) :
case 0:
$s = "We have received an offer of scientific assistance from <b>" . utf8entities($p1['name']) . "</b>.";
break;
case 1:
$s = "Our offer to <b>" . utf8entities($p2['name']) . "</b> has been accepted";
if ($o['price'] > 0) {
$s .= " and you have therefore received <b>&euro;" . number_format($o['price']) . "</b>";
}
$s .= ".";
break;
case 2:
$s = "Our offer of scientific assistance to <b>" . utf8entities($p2['name']) . "</b> has been declined.";
break;
endswitch;
$s .= " <a href='research?p=d'>More details ...</a>";
return $s;
}
}
?>

View file

@ -0,0 +1,95 @@
<?php
class msgformat_revdmg {
function msgformat_revdmg($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Damage Control Squad';
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
return "Damage to infrastructure due to riots";
}
function getReplyLink() {
return "";
}
function getContents() {
if (is_array($this->data[0])) {
$data = $this->data;
} else {
$data = array($this->data);
}
$str = "Sir! Citizens in the empire are riotting; we have been able to contain most of the acts of "
. "violence. Here is our report.<br/><br/>";
$n = 0;
foreach ($data as $p) {
$str .= 'Planet <a href="planet?id='.$p['planet'].'"><b>'.utf8entities($p['pname'])."</b></a>: ";
if ($p['mfact'] + $p['ifact'] + $p['turrets'] == 0) {
$str .= "no damage reported.";
} else {
$nd = 0;
if ($p['ifact'] != 0) {
$str .= "<b>" . $p['ifact'] . "</b> industrial factor";
if ($p['ifact'] > 1) {
$str .= "ies";
} else {
$str .= "y";
}
$nd += $p['ifact'];
}
if ($p['mfact'] != 0) {
if ($nd) {
if ($p['turrets'] > 0) {
$str .= ", ";
} else {
$str .= " and ";
}
}
$str .= "<b>" . $p['mfact'] . "</b> military factor";
if ($p['mfact'] > 1) {
$str .= "ies";
} else {
$str .= "y";
}
$nd += $p['mfact'];
}
if ($p['turrets'] != 0) {
if ($nd) {
$str .= " and ";
}
$str .= "<b>" . $p['turrets'] . "</b> turret" . ($p['turrets'] > 1 ? "s" : "");
}
$str .= " ha" . ($nd > 1 ? "ve" : "s") . " been destroyed.";
}
$n ++;
if ($n < count($data)) {
$str .= "<br/>";
}
}
return $str;
}
}
?>

View file

@ -0,0 +1,52 @@
<?php
class msgformat_revolt {
function msgformat_revolt($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'Governor of ' . utf8entities($this->data['pname']);
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
if ($this->data['started'] == 't') {
return "Civil unrest on " . utf8entities($this->data['pname']);
}
return "End of the uprising on " . utf8entities($this->data['pname']);
}
function getReplyLink() {
return "";
}
function getContents() {
$planet = '<a href="planet?id='.$this->data['planet'].'"><b>'.utf8entities($this->data['pname'])."</b></a>";
if ($this->data['started'] == 't') {
$str = "Sir! The citizens of $planet are most displeased with their treatment! "
. "They are protesting in the streets at being so unhappy! The riots are intensifying, "
. "and we suspect that they will soon start destroying our infrastructure if no action "
. "is taken!";
} else {
$str = "Sir, the riots on planet $planet have ended.";
}
return $str;
}
}
?>

View file

@ -0,0 +1,85 @@
<?php
class msgformat_sale {
function msgformat_sale($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return "Economic Advisor";
}
function getSLink() {
return "";
}
function getRecipient() {
return utf8entities($this->players->call('getName', $this->player));
}
function getRLink() {
return "";
}
function getSubject() {
$v = ($this->data['is_sale'] == 'f') ? "bought" : "sold";
if (is_null($this->data['p_name'])) {
return "Fleet '" . utf8entities($this->data['f_name']) . " has been $v";
}
return "Planet " . utf8entities($this->data['p_name']) . " has been $v";
}
function getReplyLink() {
return "";
}
function getContents() {
$p = $this->players->call('get', $this->data['pl_id'], true);
$sale = ($this->data['is_sale'] == 'f');
$pq = ($p['quit'] == 0);
$fp = ($this->data['f_power'] != "") ? number_format($this->data['f_power']) : "";
if (is_null($this->data['p_name'])) {
if ($this->data['is_sale'] == 't') {
$s = "We just lost control of our fleet <b>" . utf8entities($this->data['f_name'])
. "</b> (fleet power: <b>$fp</b>).<br/>It has been sold to "
. ($pq ? "<a href='message?a=c&ct=0&id={$this->data['pl_id']}'>" : "")
. "<b>" . utf8entities($this->data['pl_name']) . "</b>" . ($pq?"</a>":"") . ".";
} else {
$s = "We just gained control of the fleet <b>" . utf8entities($this->data['f_name'])
. "</b> (fleet power: <b>$fp</b>).<br/>It has been obtained from "
. ($pq ? "<a href='message?a=c&ct=0&id={$this->data['pl_id']}'>" : "")
. "<b>" . utf8entities($this->data['pl_name']) . "</b>" . ($pq?"</a>":"") . ".";
}
} elseif ($this->data['is_sale'] == 't') {
$s = "We just lost control of our planet <a href='planet?id="
. $this->data['p_id'] . "'><b>" . utf8entities($this->data['p_name'])
. "</b></a>";
if (!is_null($this->data['f_name'])) {
$s .= " along with the <b>" . utf8entities($this->data['f_name'])
. "</b> fleet (power: <b>$fp</b>)";
}
$s .= ".<br/>It has been sold to "
. ($pq ? "<a href='message?a=c&ct=0&id={$this->data['pl_id']}'>" : "")
. "<b>" . utf8entities($this->data['pl_name']) . "</b>" . ($pq?"</a>":"") . ".";
} else {
$s = "We just gained control on planet <a href='planet?id="
. $this->data['p_id'] . "'><b>" . utf8entities($this->data['p_name'])
. "</b></a>";
if (!is_null($this->data['f_name'])) {
$s .= " and on the <b>" . utf8entities($this->data['f_name'])
. "</b> fleet (power: <b>$fp</b>)";
}
$s .= ".<br/>We bought it from "
. ($pq ? "<a href='message?a=c&ct=0&id={$this->data['pl_id']}'>" : "")
. "<b>" . utf8entities($this->data['pl_name']) . "</b>" . ($pq?"</a>":"") . ".";
}
return $s;
}
}
?>

View file

@ -0,0 +1,63 @@
<?php
class msgformat_std {
function msgformat_std($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
$pinf = $this->players->call('get', $this->data['sender'], true);
return utf8entities($pinf['name']);
}
function getSLink() {
if ($this->data['sender'] == $this->player) {
return "";
}
$pinf = $this->players->call('get', $this->data['sender']);
if (is_null($pinf)) {
return "";
}
return "0,".$this->data['sender'];
}
function getRecipient() {
$pinf = $this->players->call('get', $this->data['recipient'], true);
return utf8entities($pinf['name']);
}
function getRLink() {
if ($this->data['recipient'] == $this->player) {
return "";
}
$pinf = $this->players->call('get', $this->data['recipient']);
if (is_null($pinf)) {
return "";
}
return "0,".$this->data['recipient'];
}
function getSubject() {
return utf8entities($this->data['subject']);
}
function getReplyLink() {
if ($this->data['sender'] == $this->player) {
return "";
}
$pinf = $this->players->call('get', $this->data['sender']);
if (is_null($pinf)) {
return "";
}
return "0,".$this->data['sender'].",".$this->data['id'];
}
function getContents() {
return preg_replace('/\n/', '<br/>', utf8entities($this->data['message']));
}
}
?>

View file

@ -0,0 +1,60 @@
<?php
class msgformat_warnname {
function msgformat_warnname($game) {
$this->game = $game;
$this->players = $game->getLib('beta5/player');
}
function getSender() {
return 'LW Moderators';
}
function getSLink() {
return "";
}
function getRecipient() {
return utf8entities($this->players->call('getName', $this->player),ENT_COMPAT);
}
function getRLink() {
return "";
}
function getSubject() {
switch ($this->data['event']) :
case 'WARN ': $s = '/!\\ PLANET NAME WARNING /!\\'; break;
default: $s = '/!\\ PLANET RESET /!\\'; break;
endswitch;
return $s;
}
function getReplyLink() {
return "";
}
function getContents() {
if ($this->data['event'] == 'WARN ') {
$t = "This is an <b>official warning</b> from the Legacy Worlds moderation team.<br/>"
. "One of the planets you own, <a href='planet?id={$this->data['planet']}'><b>"
. utf8entities($this->data['p_name'],ENT_COMPAT) . "</b></a>, has a name that is considered either "
. "vulgar, disrespectful or discriminating (please check the <a target='_blank' href='"
. "manual?p=good_practices'>manual</a> for more details).<br/>"
. "The planet will be made neutral and reset to its initial state (2k population, 3 factories "
. "of each type and 3 turrets) if you don't rename it within 24h or if the new name is "
. "found to be offensive as well.";
} elseif ($this->data['event'] == 'NEUT ') {
$t = "Your planet <b>" . utf8entities($this->data['p_name'],ENT_COMPAT) . "</b> has been neutralized and reset "
. "by the Legacy Worlds moderation team; you had been warned regarding its name and renamed it "
. "to something offensive.";
} else {
$t = "Your planet <b>" . utf8entities($this->data['p_name'],ENT_COMPAT) . "</b> has been automatically neutralized "
. "and reset; you had been warned regarding its name and did not rename it within 24h.";
}
return $t;
}
}
?>

View file

@ -0,0 +1,118 @@
<?php
class msgformat_whsn {
var $compn = array('G.A. ship', 'G.A. ships', 'fighter', 'fighters', 'cruiser', 'cruisers', 'batlle cruiser', 'battle cruisers');
var $compi = array('gaships', 'fighters', 'cruisers', 'bcruisers');
function msgformat_whsn($game) {
$this->game = $game;
$this->db = $game->getDBAccess();
$this->players = $game->getLib('beta5/player');
$this->planets = $game->getLib('beta5/planet');
}
function getSender() {
return 'Military Advisor';
}
function getSLink() {
return "";
}
function getRecipient() {
$pinf = $this->players->call('getName', $this->player);
return utf8entities($pinf);
}
function getRLink() {
return "";
}
function getSubject() {
return "Planet " . utf8entities($this->data['p_name']) . " has been destroyed!";
}
function getReplyLink() {
return "";
}
function getFleetComposition($r) {
$rv = array();
for ($i=0;$i<4;$i++) {
$n = $r[$this->compi[$i]];
if ($n == 0) {
continue;
}
array_push($rv, "<b>" . number_format($n) . "</b> " . $this->compn[$i*2 + ($n>1 ? 1 : 0)]);
}
return join(', ', $rv);
}
function getContents() {
$q = $this->db->query("SELECT * FROM whsn_fleet WHERE id={$this->data['id']}");
$fList = array();
$fPower = 0;
while ($r = dbFetchHash($q)) {
$fPower += $r['power'];
array_push($fList, $r);
}
if ($this->data['was_owner'] == 'f') {
$str = "Sir! A planet we were orbitting, <b>" . utf8entities($this->data['p_name'])
. "</b>, has self-destructed using a wormhole supernova!<br/>";
$ffp = $this->data['f_power']; $efp = $this->data['e_power'];
if ($ffp != 0) {
$str .= "Allied forces lost a total of <b>" . number_format($ffp)
. "</b> fleet power";
if ($efp != 0) {
$str .= ", while enemy forces lost a total of <b>"
. number_format($efp) . "</b> fleet power";
}
$str .= ".";
} else if ($efp != 0) {
$str .= "A total fleet power of <b>" . number_format($efp)
. "</b> was lost by the enemy when the planet exploded.";
}
if (count($fList)) {
$str .= " We lost the following fleet" . ((count($fList)>1) ? "s" : "")
. " (representing a total fleet power of <b>" . number_format($fPower)
. "</b>):<br/><br/>";
}
} else {
$str = "Sir! Our planet <b>" . utf8entities($this->data['p_name'])
. "</b>, has successfully self-destructed using a wormhole supernova!<br/>";
$ffp = $this->data['f_power']; $efp = $this->data['e_power'];
if ($ffp != 0) {
$str .= "Allied forces lost a total of <b>" . number_format($ffp)
. "</b> fleet power";
if ($efp != 0) {
$str .= ", while enemy forces lost a total of <b>" . number_format($efp) . "</b> fleet power";
}
$str .= ".";
} else if ($efp != 0) {
$str .= "A total fleet power of <b>" . number_format($efp) . "</b> was lost by the enemy when the planet exploded.";
}
if (count($fList)) {
$str .= " We lost the following fleet" . ((count($fList)>1) ? "s" : "")
. " (representing a total fleet power of <b>" . number_format($fPower)
. "</b>) during the event:<br/><br/>";
}
}
foreach ($fList as $f) {
$str .= "Fleet <b>" . utf8entities($f['name']) . "</b>: "
. $this->getFleetComposition($f) . "; fleet power: <b>"
. number_format($f['power']) . "</b><br/>";
}
$pinfo = $this->planets->call('byId', $this->data['p_id']);
$str .= "<br/>The remains of the planet have been named <a href='planet?id={$this->data['p_id']}'><b>"
. utf8entities($pinfo['name']) . "</b></a>.";
return $str;
}
}
?>