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, "" . number_format($n) . " " . $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, " . utf8entities($this->data['p_name']) . ":
"; foreach ($this->fmData as $r) { $str .= "
Fleet " . utf8entities($r['f_name']) . " coming from " . utf8entities($r['from_name']) . " (composition: "; $str .= $this->getComposition($r); $str .= "; power: " . number_format($r['f_power']) . ")"; } } else { $str = "Sir! The fleets stationed in orbit around " . utf8entities($this->data['p_name']) . " report the following event" . ($pl ? "s" : "") . ":
"; foreach ($this->fmData as $r) { $str .= "
A " . ($r['hostile'] == 'f' ? "friendly" : "hostile") . " fleet, " . utf8entities($r['f_name']) . ", owned by " . "" . utf8entities($this->players->call('getName', $r['f_owner'])) . ", has "; if ($r['arrived'] == 'f') { $str .= "left orbit"; } else { $str .= "entered orbit, coming from " . utf8entities($r['from_name']) . ""; } $str .= " (composition: "; $str .= $this->getComposition($r); $str .= "; power: " . number_format($r['f_power']) . ")"; } } return $str; } } ?>