示例#1
0
 public function getSectorLink($x, $y, &$i)
 {
     if (isset($this->data[$i]) && $this->data[$i]['x'] == $x && $this->data[$i]['y'] == $y) {
         if ($this->data[$i]['type'] != 2) {
             $output = 'href="javascript: fetch(\'getGrid.php\', \'x=' . $x . '&y=' . $y . '\')" onMouseOver="setSectorData(labels[' . $this->data[$i]['type'] . '], \'-\', \'-\')" onMouseOut="setSectorData(\'-\', \'-\', \'-\')"';
         } else {
             $node = new node();
             $node->get('id', $this->data[$i]['id']);
             $user = new user();
             $user->get('id', $node->data['user']);
             $alliancename = '-';
             if ($user->data['alliance']) {
                 $alliance = new alliance();
                 $alliance->get('user', $user->data['id']);
                 $alliancename = $alliance->data['name'];
             }
             $output = 'href="javascript: fetch(\'getGrid.php\', \'x=' . $x . '&y=' . $y . '\')" onMouseOver="setSectorData(\'' . $node->data['name'] . '\', \'' . $user->data['name'] . '\', \'' . $alliancename . '\')" onMouseOut="setSectorData(\'-\', \'-\', \'-\')"';
         }
         if ($i < count($this->data) - 1) {
             $i++;
         }
     } else {
         $output = 'href="javascript: fetch(\'getGrid.php\', \'x=' . $x . '&y=' . $y . '\')"';
     }
     return $output;
 }
示例#2
0
             $nr = count($_POST[$key]);
             for ($i = 0; $i < $nr; $i++) {
                 $_POST[$key][$i] = misc::clean($_POST[$key][$i], 'numeric');
             }
         } else {
             $_POST[$key] = misc::clean($value);
         }
     }
 }
 $target = new node();
 if ($target->get('name', $_POST['name']) == 'done') {
     $targetUser = new user();
     if ($targetUser->get('id', $target->data['user']) == 'done') {
         $alliance = new alliance();
         $targetAlliance = new alliance();
         if ($targetAlliance->get('id', $targetUser->data['alliance']) == 'done' && $alliance->get('id', $_SESSION[$shortTitle . 'User']['alliance']) == 'done') {
             $war = $alliance->getWar($targetAlliance->data['id']);
             if (isset($war['type'])) {
                 $gotStatic = false;
                 $data = array();
                 $data['input']['attacker']['focus'] = $_POST['attackerFocus'];
                 $data['input']['attacker']['faction'] = $node->data['faction'];
                 foreach ($_POST['attackerGroupUnitIds'] as $key => $unitId) {
                     $data['input']['attacker']['groups'][$key] = array('unitId' => $unitId, 'quantity' => $_POST['attackerGroups'][$key]);
                     if (!$game['units'][$node->data['faction']][$unitId]['speed']) {
                         $gotStatic = true;
                     }
                 }
                 if (!$gotStatic) {
                     $status = $node->addCombat($target->data['id'], $data);
                 } else {
示例#3
0
             } else {
                 $message = $ui['accessDenied'];
             }
         } else {
             $message = $ui['noAlliance'];
         }
     } else {
         $message = $ui['insufficientData'];
     }
     break;
 case 'acceptPeace':
     if (isset($_GET['sender'], $_GET['recipient'])) {
         if ($status == 'done') {
             if ($alliance->data['user'] == $_SESSION[$shortTitle . 'User']['id'] && $alliance->data['id'] == $_GET['recipient']) {
                 $senderAlliance = new alliance();
                 if ($senderAlliance->get('id', $_GET['sender']) == 'done') {
                     $status = $alliance->acceptPeace($senderAlliance->data['id']);
                     if ($status == 'done') {
                         $user = new user();
                         if ($user->get('id', $senderAlliance->data['user']) == 'done') {
                             $user->getPreferences('name');
                             if ($user->preferences['allianceReports']) {
                                 $msg = new message();
                                 $msg->data['sender'] = $_SESSION[$shortTitle . 'User']['name'];
                                 $msg->data['recipient'] = $user->data['name'];
                                 $msg->data['subject'] = $ui['peaceAccepted'];
                                 $msg->data['body'] = $ui['sender'] . ': ' . $alliance->data['name'] . ' ' . $ui['alliance'];
                                 $msg->data['viewed'] = 0;
                                 $status = $msg->add();
                                 if ($status == 'done') {
                                     header('Location: alliance.php?action=get');
示例#4
0
                 $removeLabel = $ui['decline'];
             }
             echo '<div class="right"> ' . $user->data['name'] . ' | ' . $accept . '<a class="link" href="?action=removeInvitation&alliance=' . $invitation['alliance'] . '&user='******'user'] . '">' . $removeLabel . '</a></div>';
         }
     }
     if ($alliance->data['user'] == $_SESSION[$shortTitle . 'User']['id']) {
         echo '<div class="section" style="margin-top: 5px;"> -> ' . $ui['wars'] . ' | <a class="link" href="?action=addWar">' . $ui['goToWar'] . '</a></div>';
     }
     foreach ($alliance->wars as $war) {
         $otherAlliance = new alliance();
         if ($alliance->data['id'] == $war['sender']) {
             $otherAllianceId = $war['recipient'];
         } else {
             $otherAllianceId = $war['sender'];
         }
         if ($otherAlliance->get('id', $otherAllianceId) == 'done') {
             if ($war['type']) {
                 echo '<div class="right">' . $otherAlliance->data['name'] . ' | <a class="link" href="?action=proposePeace&recipient=' . $otherAlliance->data['id'] . '">' . $ui['peace'] . '</a></div>';
             } else {
                 if ($alliance->data['id'] == $war['recipient']) {
                     $ad = '<a class="link" href="?action=acceptPeace&sender=' . $war['sender'] . '&recipient=' . $war['recipient'] . '">' . $ui['accept'] . '</a> / <a class="link" href="?action=removePeace&recipient=' . $otherAlliance->data['id'] . '">' . $ui['decline'] . '</a>';
                 } else {
                     $ad = '<a class="link" href="?action=removePeace&recipient=' . $otherAlliance->data['id'] . '">x</a>';
                 }
                 echo '<div class="right">' . $otherAlliance->data['name'] . ' ' . $ui['peace'] . ' | ' . $ad . '</div>';
             }
         }
     }
 } else {
     echo '<div class="section"><a class="link" href="?action=add">' . $ui['add'] . '</a></div>';
     if ($invitations) {
示例#5
0
 public function acceptPeace($allianceId)
 {
     global $db;
     $alliance = new alliance();
     if ($alliance->get('id', $allianceId) == 'done') {
         $result = $db->query('select count(*) as count from wars where type=0 and sender="' . $alliance->data['id'] . '" and recipient="' . $this->data['id'] . '"');
         $row = db::fetch($result);
         if ($row['count']) {
             $ok = 1;
             $db->query('delete from wars where type=1 and ((sender="' . $this->data['id'] . '" and recipient="' . $alliance->data['id'] . '") or (sender="' . $alliance->data['id'] . '" and recipient="' . $this->data['id'] . '"))');
             if ($db->affected_rows() == -1) {
                 $ok = 0;
             }
             $db->query('delete from wars where type=0 and sender="' . $alliance->data['id'] . '" and recipient="' . $this->data['id'] . '"');
             if ($db->affected_rows() == -1) {
                 $ok = 0;
             }
             if ($ok) {
                 $status = 'done';
             } else {
                 $status = 'error';
             }
         } else {
             $status = 'noPeace';
         }
     } else {
         $status = 'noAlliance';
     }
     return $status;
 }