{ return $item1->getAtkBoost() - $item2->getAtkBoost(); } // display the items used in the battle if (isset($_SESSION['userUsedItems']) && isset($_SESSION['otherUserUsedItems'])) { $userItemObjs = Item::getItems(array_keys($_SESSION['userUsedItems'])); $otherUserItemObjs = Item::getItems(array_keys($_SESSION['otherUserUsedItems'])); // usort returns a bool usort($userItemObjs, "Item::ItemAtkCmp"); usort($otherUserItemObjs, "Item::ItemDefCmp"); echo "Your mob of " . $user->getAgencySize() . " used <br>"; listItems($userItemObjs, $_SESSION['userUsedItems']); $otherUser = User::getUser($_SESSION['otherUserID']); // TODO make this a link to the other user's profile page echo $otherUser->getName() . "'s mob of " . $otherUser->getAgencySize() . " used <br>"; listItems($otherUserItemObjs, $_SESSION['otherUserUsedItems']); unset($_SESSION['userUsedItems']); unset($_SESSION['otherUserUsedItems']); unset($_SESSION['otherUserID']); } if ($user->getType()) { ?> <form action='<?php $_SERVER['DOCUMENT_ROOT']; ?> /battle.php' method='POST'> <input type='hidden' name='battleTab' value='normal' /> <input type='submit' value='Attack an Enemy Agency'/> </form> <form action='<?php $_SERVER['DOCUMENT_ROOT'];
public function loadAPI() { $result = $this->api->xpath("/eveapi/result/rowset/row"); usort($result, "contracts_default_sortfunc"); if ($this->corp) { $filtered = array(); foreach ($result as $entry) { if ($entry["issuerCorpID"] == CORP_ID && $entry["forCorp"] == "1" || $entry["acceptorID"] == CORP_ID || $entry["assigneeID"] == CORP_ID) { // TODO: should not depend on CORP_ID - api should be unaware of audit.php $filtered[] = $entry; } } $result = $filtered; } $result = array_slice($result, $this->start, $this->limit); $idsTR = array(); $locations = array(); $ctrctids = array(); $nonCourierIDs = array(); $this->count = count($result); foreach ($result as $entry) { $ctrctids[] = (double) $entry["contractID"]; if ($entry["type"] != "Courier") { $nonCourierIDs[] = (double) $entry["contractID"]; } } if ($this->getItems && $nonCourierIDs) { $items = $this->fetchItems($nonCourierIDs); } foreach ($result as $entry) { $idsTR[(double) $entry["issuerID"]] = "1"; $idsTR[(double) $entry["issuerCorpID"]] = "1"; if ((double) $entry["assigneeID"] != 0) { $idsTR[(double) $entry["assigneeID"]] = "1"; } if ((double) $entry["acceptorID"] != 0) { $idsTR[(double) $entry["acceptorID"]] = "1"; } if ((string) $entry["type"] == "Auction") { if (!$this->hasAuctions) { $this->fetchBids($ctrctids); if (count($this->bids) > 0) { foreach ($this->bids as $bidset) { foreach ($bidset as $bid) { $idsTR[$bid["bidderID"]] = "1"; } } } } } $locations[locationTranslate((double) $entry["startStationID"])] = "1"; $locations[locationTranslate((double) $entry["endStationID"])] = "1"; } $ids = idlookup($this->Db->link, array_keys($idsTR)); $this->Db->cacheLocationIds(array_keys($locations)); // ensuring only one lookup of each $locations = array(); foreach ($result as $entry) { $locations[$this->Db->getSystemFromStationId(locationTranslate((double) $entry["startStationID"]))] = "1"; $locations[$this->Db->getSystemFromStationId(locationTranslate((double) $entry["endStationID"]))] = "1"; } $this->Db->cacheLocationIds(array_keys($locations)); // system names $entries = array(); foreach ($result as $entry) { $new = array(); foreach ($entry->attributes() as $name => $value) { // copy item attributes $new[(string) $name] = (string) $value; } // todo $cid = (double) $entry["contractID"]; $new["issuer"] = $ids[(double) $entry["issuerID"]]; $new["issuerCorp"] = $ids[(double) $entry["issuerCorpID"]]; $new["assignee"] = (double) $entry["assigneeID"] != 0 ? $ids[(double) $entry["assigneeID"]] : ""; $new["acceptor"] = (double) $entry["acceptorID"] != 0 ? $ids[(double) $entry["acceptorID"]] : ""; $new["startStation"] = $this->Db->getLocationNameFromId(locationTranslate((double) $entry["startStationID"])); $new["endStation"] = $this->Db->getLocationNameFromId(locationTranslate((double) $entry["endStationID"])); $new["startSystemID"] = $this->Db->getSystemFromStationId(locationTranslate((double) $entry["startStationID"])); $new["endSystemID"] = $this->Db->getSystemFromStationId(locationTranslate((double) $entry["endStationID"])); $new["startSystem"] = $this->Db->getLocationNameFromId($new["startSystemID"]); $new["System"] = $new["startSystem"]; $new["endSystem"] = $this->Db->getLocationNameFromId($new["endSystemID"]); if ((string) $new["status"] == "CompletedByContractor") { $new["status"] = "Unclaimed"; } if (!CONTRACT_ACTIVE((string) $entry["status"])) { if ((string) $entry["status"] == "Failed") { $new["dateFinished"] = "FAILED"; } else { $new["dateFinished"] = (string) $entry["dateCompleted"]; } $new["timeRemaining"] = 0; } else { if ((string) $entry["type"] == "Courier" && (string) $entry["status"] == "InProgress") { $new["dateFinished"] = ""; // $entry["dateExpired"]; $new["timeRemaining"] = (int) (string) $entry["numDays"] * 3600 * 24 - (strtotime((string) $this->api->currentTime) - strtotime((string) $entry["dateAccepted"])); } else { $new["timeRemaining"] = strtotime((string) $entry["dateExpired"]) - strtotime((string) $this->api->currentTime); if ($new["timeRemaining"] < 0) { $new["dateFinished"] = (string) $entry["dateExpired"]; $new["timeRemaining"] = 0; $new["status"] = "Expired"; } else { $new["dateFinished"] = ""; } // $entry["dateExpired"]; } } if ($entry["title"] != "") { $new["desc"] = "<b>Title: </b>{$entry['title']}"; } else { $new["desc"] = ""; } if ((string) $entry["type"] == "Courier") { $new["desc"] .= ($new["desc"] = "" ? "<br>" : "") . "<b>Destination: </b>{$new['endStation']}"; if ((double) $entry["collateral"] != 0) { $new["desc"] .= "<br><b>Collateral: <span style=\"color:#aa0;\">" . number_format((double) $entry["collateral"], 2) . " ISK</span></b>"; } if ((double) $entry["acceptorID"] != 0) { $new["desc"] .= "<br><b>Accepted:</b> {$entry['dateAccepted']}</span>"; } } if ((string) $entry["type"] == "ItemExchange") { if ((double) $entry["reward"] > 0) { $new["Type"] = "WTB"; } else { if ((double) $entry["reward"] == (double) $entry["price"]) { $new["Type"] = "Gift"; } else { $new["Type"] = "WTS"; } } } else { $new["Type"] = (string) $entry["type"]; if ((string) $entry["type"] == "Auction") { if (isset($this->bids[$cid])) { $bid = $this->bids[$cid][0]; $new["price"] = $bid["amount"]; $new["desc"] .= "<br><b>Last Bid:</b> " . $bid["bidTime"] . "</span>"; $new["bidder"] = "#" . count($this->bids[$cid]) . ", " . $ids[$bid["bidderID"]]; } else { $new["bidder"] = ""; } } } if ($this->getItems && (string) $entry["type"] != "Courier") { $buying = $items[(double) $entry["contractID"]]["buying"]; $selling = $items[(double) $entry["contractID"]]["selling"]; if (count($buying) > 0 && count($selling) > 0) { $new["Type"] = "Trade"; } $new["buying"] = $buying; $new["selling"] = $selling; } $entries[] = $new; } if ($this->getItems) { if (count($this->typesToCache) > 0) { $types = array_keys($this->typesToCache); $this->Db->cacheItemTypes($types); $groupsToCache = array(); foreach ($types as $typeID) { $type = $this->Db->getTypeFromTypeId($typeID); $groupsToCache[] = $type["groupID"]; } $this->Db->cacheGroupTypes($groupsToCache); $this->Db->cacheMetaLevelsIDs($types); } foreach ($entries as &$entry) { $entry["buyingItems"] = ""; $entry["buyingItemsList"] = ""; $entry["sellingItems"] = ""; $entry["sellingItemsList"] = ""; if (isset($entry["buying"])) { listItems($this->Db, $entry["buying"], $entry["buyingItems"], $entry["buyingItemsList"]); listItems($this->Db, $entry["selling"], $entry["sellingItems"], $entry["sellingItemsList"]); } else { $entry["buying"] = array(); $entry["selling"] = array(); } } } usort($entries, "contracts_default_sortfunc"); $this->entries = $entries; return true; }
usort($otherUserItemObjs, "Item::ItemDefCmp"); //echo "Your mob of " . $user->getAgencySize() . " used <br>"; $yourmobhtml .= '<ul class="weaponsused"> <li><h3>Your mob used:</h3></li>'; if (listItems($userItemObjs, $_SESSION['userUsedItems']) != '') { $yourmobhtml .= listItems($userItemObjs, $_SESSION['userUsedItems']); } else { $yourmobhtml .= '<li>Your opponent use no weapon</li>'; } $yourmobhtml .= ' </ul> '; // TODO make this a link to the other user's profile page //echo $otherUser->getName() . "'s mob of " . $otherUser->getAgencySize() . " used <br>"; $theirmobhtml .= '<ul class="weaponsused"> <li><h3>Their mob used:</h3></li>'; if (listItems($otherUserItemObjs, $_SESSION['otherUserUsedItems']) != '') { $theirmobhtml .= listItems($otherUserItemObjs, $_SESSION['otherUserUsedItems']); } else { $theirmobhtml .= '<li>Your Opponent use no weapon</li>'; } $theirmobhtml .= ' </ul> '; $result_html .= $yourmobhtml . $theirmobhtml . ' <div class="leavecomment"> <textarea placeholder="Leave a comment..." id="toggleSection" maxlength = "250" style="display:none;"></textarea> <a href="#" id="toggleButton" class="blackbutton">Post Comment</a> </div>'; if (isset($_SESSION['bounty'])) { //echo "bountyAmount".$_SESSION['bountyAmount']; unset($_SESSION['bountyAmount']); $bounties = Bounty::getBountiesCountForUser($user->getID()); $numBounties = count($bounties); } else {