예제 #1
0
 /**
  * Command for the current user to offer their money as bounty on another player
  *
  * @param target String The username of the player to offer a bounty on
  * @param amount int The amount of gold to spend on offering the bounty
  * @return Array
  *
  * @TODO simplify the conditional branching
  */
 public function offerBounty()
 {
     $target = in('target');
     $target_id = get_char_id($target);
     // Will be the enemy to put the bounty on.
     $amount = intval(in('amount'));
     $amount_in = $amount;
     $error = 0;
     $quickstat = false;
     $success = false;
     if (!$target_id) {
         $error = 1;
     } else {
         // Target existed.
         $target_bounty = getBounty($target_id);
         if ($target_bounty < 5000) {
             if ($amount > 0) {
                 if ($target_bounty + $amount > 5000) {
                     $amount = 5000 - $target_bounty;
                 }
                 if (get_gold($this->sessionData['char_id']) >= $amount) {
                     addBounty($target_id, $amount);
                     // Add the bounty to the person being bountied upon.  How the hell did this break?
                     subtract_gold($this->sessionData['char_id'], $amount);
                     send_event($this->sessionData['char_id'], get_char_id($target), $this->sessionData['username'] . " has offered {$amount} gold in reward for your head!");
                     $success = true;
                     $quickstat = 'player';
                 } else {
                     $error = 2;
                 }
             } else {
                 $error = 3;
             }
         } else {
             $error = 4;
         }
     }
     return $this->render(['error' => $error, 'success' => $success, 'quickstat' => $quickstat, 'amount_in' => $amount_in, 'amount' => $amount, 'command' => 'offer', 'location' => 0, 'target' => $target]);
 }
예제 #2
0
     $guard_attack = rand(1, $attacker_str + 10);
     // *** Guard Damage ***
     if (!subtractHealth($username, $guard_attack)) {
         echo "The Guard has slain you!<br>\n";
         echo "Go to the <a href=\"shrine.php\">shrine</a> to resurrect.<br>\n";
     } else {
         $guard_gold = rand(1, $attacker_str + 40);
         // *** Guard Gold ***
         addGold($username, $guard_gold);
         echo "The guard is defeated!<br>\n";
         echo "Guard does {$guard_attack} points of damage.<br>\n";
         echo "You have gained {$guard_gold} gold.<br>\n";
         if (getLevel($username) > 15) {
             $added_bounty = floor((getLevel($username) - 10) / 5);
             echo "You have slain a member of the military!  A bounty of " . $added_bounty * 10 . " gold has been placed on your head!<br>\n";
             addBounty($username, $added_bounty * 10);
         }
     }
 } else {
     if ($victim == "thief") {
         // Check the counter to see whether they've attacked a thief multiple times in a row.
         if (SESSION::is_set('counter')) {
             $counter = SESSION::get('counter');
         } else {
             $counter = 1;
         }
         $counter = $counter + 1;
         SESSION::set('counter', $counter);
         // Save the current state of the counter.
         if ($counter > 20 && rand(1, 3) == 3) {
             // Only after many attacks do you have the chance to be attacked back by the group of theives.
예제 #3
0
파일: npc.php 프로젝트: reillo/ninjawars
     $npc_template = 'npc.merchant.tpl';
     $combat_data = array('attack' => $merchant_attack, 'gold' => $merchant_gold, 'bounty' => $added_bounty, 'victory' => $victory);
 } else {
     if ($victim == 'guard') {
         // *** The Player attacks the guard ***
         $guard_attack = rand(1, $attacker_str + 10);
         // *** Guard Damage ***
         $herb = false;
         $added_bounty = 0;
         if ($player->vo->health = $victory = subtractHealth($char_id, $guard_attack)) {
             $guard_gold = rand(1, $attacker_str + 40);
             // *** Guard Gold ***
             add_gold($char_id, $guard_gold);
             if ($player->vo->level > 15) {
                 $added_bounty = 10 * floor(($player->vo->level - 10) / 5);
                 addBounty($char_id, $added_bounty);
             }
             if (rand(1, 9) == 9) {
                 // *** 1/9 chance of getting an herb for Kampo ***
                 $herb = true;
                 add_item($char_id, 'ginsengroot', 1);
             } else {
                 $herb = false;
             }
         } else {
             // *** The Guard kills the player ***
             $guard_attack = $guard_gold = $added_bounty = 0;
         }
         $npc_template = 'npc.guard.tpl';
         $combat_data = array('attack' => $guard_attack, 'gold' => $guard_gold, 'bounty' => $added_bounty, 'victory' => $victory, 'herb' => $herb);
     } else {
예제 #4
0
$location = "Doshin Office";
$description = "You walk up to the Doshin Office to find the door locked. " . "The Doshin are busy protecting the borders of the village from thieves.\n" . "<br><br>\n" . "Nailed to the door is an official roster of wanted criminals and the bounties offered for their heads.\n" . "A few men that do seem to be associated with the doshin doze near the entrance.  Every so often someone approaches and slips them something that clinks and jingles.";
$target = in('target');
$command = in('command');
$amount = intval(in('amount'));
$bribe = intval(in('bribe'));
if ($command == "Offer Bounty") {
    $target_bounty = getBounty($target);
    if ($target_bounty < 5000) {
        if ($amount > 0) {
            if ($target_bounty + $amount > 5000) {
                $amount = 5000 - $target_bounty;
                echo "The doshin will only accept {$amount} gold towards {$target}'s bounty.<br>\n";
            }
            if (getGold($username) >= $amount) {
                addBounty($target, $amount);
                subtractGold($username, $amount);
                sendMessage($username, $target, "{$username} has offered {$amount} gold in reward for your head!");
                echo "You have offered {$amount} towards bringing {$target} to justice.<br>\n";
                $quickstat = "player";
            } else {
                echo "You do not have that much gold.<br>\n";
            }
        } else {
            echo "You did not offer a valid amount of gold.<br>\n";
        }
    } else {
        echo "The bounty on {$target} may go no higher.<br>\n";
    }
} else {
    if ($command == "Bribe") {
예제 #5
0
         }
     }
 }
 echo $result;
 if (!$victim_alive) {
     if ($target != $username) {
         $gold_mod = 0.15;
         $loot = round($gold_mod * getGold($target));
         subtractGold($target, $loot);
         addGold($username, $loot);
         addKills($username, 1);
         echo "You have killed {$target} with {$command}!<br>\n";
         echo "You receive {$loot} gold from {$target}.<br>\n";
         $added_bounty = floor($level_check / 5);
         if ($added_bounty > 0) {
             addBounty($username, $added_bounty * 25);
             echo "Your victim was much weaker than you. The townsfolk are angered. A bounty of " . $added_bounty * 25 . " gold has been placed on your head!<br>\n";
         } else {
             if ($bounty = rewardBounty($username, $target)) {
                 echo "You have received the {$bounty} gold bounty on {$target}'s head for your deeds!<br>\n";
                 $bounty_msg = "You have valiantly slain the wanted criminal, {$target}! For your efforts, you have been awarded {$bounty} gold!";
                 sendMessage("Village Doshin", $username, $bounty_msg);
             }
         }
         $target_message = "{$attacker_id} has killed you with {$command} on {$today} and taken {$loot} gold.";
         sendMessage($attacker_id, $target, $target_message);
         $attacker_message = "You have killed {$target} with {$command} on {$today} and taken {$loot} gold.";
         sendMessage($target, $username, $target_message);
     } else {
         $loot = 0;
         echo "You have comitted suicide!<br>\n";
예제 #6
0
     // Someone died.
     if ($target->player_id == $player->player_id) {
         // Attacker killed themself.
         $loot = 0;
         $suicided = true;
     } else {
         // Attacker killed someone else.
         $killed_target = true;
         $gold_mod = 0.15;
         $loot = round($gold_mod * get_gold($target->id()));
         subtract_gold($target->id(), $loot);
         add_gold($char_id, $loot);
         addKills($char_id, 1);
         $added_bounty = floor($level_check / 5);
         if ($added_bounty > 0) {
             addBounty($char_id, $added_bounty * 25);
         } else {
             // Can only receive bounty if you're not getting it on your own head.
             if ($bounty = rewardBounty($char_id, $target->vo->player_id)) {
                 $bounty_msg = "You have valiantly slain the wanted criminal, {$target}! For your efforts, you have been awarded {$bounty} gold!";
                 sendMessage('Village Doshin', $username, $bounty_msg);
             }
         }
         $target_message = "{$attacker_id} has killed you with {$command} and taken {$loot} gold.";
         send_event($attacker_char_id, $target->id(), $target_message);
         $attacker_message = "You have killed {$target} with {$command} and taken {$loot} gold.";
         sendMessage($target->vo->uname, $username, $attacker_message);
     }
 }
 $turns_to_take = $turns_to_take - $turn_cost;
 if (!$covert && $player->hasStatus(STEALTH)) {
예제 #7
0
function runBountyExchange($username, $defender)
{
    //  Bounty Increase equation: attacker'slevel-defender'slevel/5,roundeddown,times25goldperpoint
    $levelRatio = floor((getLevel($username) - getLevel($defender)) / 5);
    if ($levelRatio > 0) {
        $bountyIncrease = $levelRatio * 25;
    } else {
        $bountyIncrease = 0;
    }
    $bountyForAttacker = rewardBounty($username, $defender);
    //returns a value if bounty rewarded.
    if ($bountyForAttacker) {
        echo "You have received the {$bountyForAttacker} gold bounty on {$defender}'s head for your deeds!<br>\n";
        $bounty_msg = "You have valiantly slain the wanted criminal, {$defender}! For your efforts, you have been awarded {$bountyForAttacker} gold!";
        sendMessage("Village Doshin", $username, $bounty_msg);
    } else {
        if ($bountyIncrease > 0) {
            addBounty($username, $bountyIncrease);
            echo "Your victim was much weaker than you. The townsfolk are angered. A bounty of " . $bountyIncrease . " gold has been placed on your head!<br>\n";
        }
    }
}
예제 #8
0
function runBountyExchange($username, $defender)
{
    //  *** BOUNTY EQUATION ***
    $user_id = get_user_id($username);
    $defender_id = get_user_id($defender);
    // *** Bounty Increase equation: (attacker's level - defender's level) / an increment, rounded down ***
    $levelRatio = floor((getLevel($user_id) - getLevel($defender_id)) / 10);
    $bountyIncrease = min(25, max($levelRatio * 25, 0));
    //Avoids negative increases, max of 30 gold, min of 0
    $bountyForAttacker = rewardBounty($user_id, $defender_id);
    //returns a value if bounty rewarded.
    if ($bountyForAttacker) {
        // *** Reward bounty whenever available. ***
        return "You have received the {$bountyForAttacker} gold bounty on {$defender}'s head for your deeds!";
        $bounty_msg = "You have valiantly slain the wanted criminal, {$defender}! For your efforts, you have been awarded {$bountyForAttacker} gold!";
        sendMessage("Village Doshin", $username, $bounty_msg);
    } else {
        if ($bountyIncrease > 0) {
            // *** If Defender has no bounty and there was a level difference. ***
            addBounty($user_id, $bountyIncrease);
            return "Your victim was much weaker than you. The townsfolk are angered. A bounty of {$bountyIncrease} gold has been placed on your head!";
        } else {
            return null;
        }
    }
}