Beispiel #1
0
function displayBountyAttack($user)
{
    $bounties = Bounty::getBountiesForUser($user->getID());
    $numBounties = count($bounties);
    if ($numBounties <= 0) {
        print "There are currently no bounties. Sorry!";
    } else {
        foreach ($bounties as $bounty) {
            $id = $bounty->getTargetID();
            //is this safe..
            $userName = $bounty->name;
            $bountyAmount = $bounty->getPayment();
            ?>
			
			Mercenary: <a href='<?php 
            $_SERVER['DOCUMENT_ROOT'];
            ?>
/externalplayerprofile.php?userID=<?php 
            echo $id;
            ?>
'><?php 
            echo $userName;
            ?>
</a> Bounty: <?php 
            echo $bountyAmount;
            ?>
			<!-- Implement the attacking button and functionality -->
			<form action="<?php 
            $_SERVER['DOCUMENT_ROOT'];
            ?>
/backend/attackplayer.php" method="POST">
			<input type='hidden' name='userID' value='<?php 
            echo $id;
            ?>
' />
			<input type='submit' value='Attack'/>
			</form>
			<?php 
        }
    }
}
<?php

include_once $_SERVER['DOCUMENT_ROOT'] . "/properties/serverproperties.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/classes/Bounty.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/classes/User.php";
session_start();
$userID = $_SESSION['userID'];
$user = User::getUser($userID);
$payment = $_GET['bountyAmount'];
if ($payment > $user->getCash()) {
    $_SESSION['notEnoughCashForBounty'] = true;
    header("Location: {$serverRoot}/addplayertobounty.php");
} else {
    $targetID = $_GET['targetID'];
    $bounty = Bounty::createBounty($userID, $targetID, $payment);
    if (!$bounty) {
        header("Location: {$serverRoot}/errorpage.html");
        exit;
    }
    if (!$user->updateUserCash($payment * -1)) {
        header("Location: {$serverRoot}/errorpage.html");
        exit;
    }
    $_SESSION['battleTab'] = 'bounty';
    header("Location: {$serverRoot}/battle.php");
}
exit;
Beispiel #3
0
function displayBountyAttack($user, $serverRoot)
{
    $bounties = Bounty::getBountiesForUser($user->getID());
    $numBounties = count($bounties);
    $enemy_html = '';
    if ($numBounties > 0) {
        $enemy_html = '<div id="two">
		<table class="pvp hitlist">
		<tr>
			<th>Opponent</th>
			<th class="armysize">Bounty</th>
			<th></th>
		</tr>';
        foreach ($bounties as $bounty) {
            $id = $bounty->getTargetID();
            //is this safe..
            $userName = $bounty->name;
            $bountyAmount = $bounty->bounty;
            if ($user->checkSameUsersInAgency($_SESSION['userID'], $id) == false && $_SESSION['userID'] != $id) {
                $enemy_html .= '<tr>
                <td class="oppname">
                    <h5><a  onclick="playSound(' . SOUND_CLICK . ')"  href="' . $serverRoot . 'externalplayerprofile.php?userID=' . $id . '">' . $userName . '</a></h5>
					<p>LVL ' . $bounty->level . ' ' . getPlayerTypeFromTypeID($bounty->type) . '</p>

			    </td>
                <td class="oppsize"><p>$' . $bountyAmount . '</p></td>
                <td class="oppattack"><a  href="javascript:" onclick="playAndRedirect(\'\',\'' . $serverRoot . 'backend/attackplayer.php?userID=' . $id . '&attack_type=bounty&bountyAmount=' . $bountyAmount . '\')" class="blackbutton">Attack</a></td>
            </tr>';
            }
            //$_SESSION['bountyAmount'] = $bountyAmount;
        }
        $enemy_html .= '</table></div>';
    }
    echo $enemy_html;
}
Beispiel #4
0
 public static function accept($data)
 {
     $out = array();
     if (!MyUser::isloggedin()) {
         throw new APIException("User ist nicht angemeldet.", 100);
     }
     if (!isset($data["answer"])) {
         throw new APIException("Benötigter Parameter fehlt (answer).", 50);
     }
     $db = new SQL(0);
     $info = $db->cmdrow(0, 'SELECT * FROM answers WHERE id={0} LIMIT 0,1', array($data["answer"] + 0));
     if (!isset($info["id"])) {
         throw new APIException("Diese Antwort existiert nicht (mehr)", 300);
     }
     if ($info["right_answer"] == "1") {
         throw new APIException("Dies ist bereits die beste Antwort", 330);
     }
     $qinfo = $db->cmdrow(0, 'SELECT * FROM questions WHERE id={0} LIMIT 0,1', array($info["question"] + 0));
     if (!isset($qinfo["id"])) {
         throw new APIException("Diese Frage existiert nicht (mehr)", 300);
     }
     if ($qinfo["is_closed"] == "1") {
         throw new APIException("Diese Frage ist bereits geschlossen", 310);
     }
     if ($qinfo["author"] != MyUser::id()) {
         throw new APIException("Dies ist nicht ihre Frage", 320);
     }
     if ($info["author"] == MyUser::id() and MyUser::getKarmaPoints() < 50) {
         throw new APIException("Deine eigene Antwort darf erst ab 50 Karma Punkten die beste Antwort sein", 210);
     }
     $db->cmd(0, 'UPDATE answers SET right_answer = "1" WHERE id={0} LIMIT 1', true, array($info["id"]));
     $db->cmd(0, 'UPDATE questions SET is_answered = "1" WHERE id={0} LIMIT 1', true, array($info["question"]));
     if (MyUser::id() != $info["author"]) {
         Karma::RuleAction("ACCEPT_ANSWER", array("user" => $info["author"], "question" => $info["question"], "answer" => $info["id"]));
     }
     if (MyUser::id() != $info["author"] && $info["is_bounty"] == "1") {
         Bounty::Release($info["question"], $info["author"]);
     }
     //Gib dem Autor die Bounty
     return true;
 }