Example #1
0
 }
 if ($attackerHealthRemaining < 1) {
     // *** DEFENDER KILLS ATTACKER! ***
     $defenderKillpoints = 1;
     if ($duel) {
         // *** if they were dueling when they died ***
         $duel_log_msg = "{$username} has dueled {$attackee} and lost at {$today}.";
         sendMessage("SysMsg", "SysMsg", $duel_log_msg);
         sendLogOfDuel($username, $attackee, 0, $killpoints);
         // *** Makes a loss in the duel log. ***
     }
     addKills($attackee, $defenderKillpoints);
     // *** Adds a kill for the defender. ***
     subtractStatus($username, STEALTH + POISON + FROZEN + CLASS_STATE);
     if (!$simultaneousKill) {
         $loot = round($gold_mod * getGold($username));
         //Loot for defender if he lives.
         addGold($attackee, $loot);
         subtractGold($username, $loot);
     }
     $attackee_msg = "<div class='ninja-notice'>\n\t\t\t\tYou have killed {$username} in combat and taken {$loot} gold on {$today}.\n\t\t\t\t</div>";
     $attacker_msg = "DEATH: You have been killed by {$attackee} in combat and lost {$loot} gold on {$today}!";
     sendMessage($username, $attackee, $attackee_msg);
     sendMessage($attackee, $username, $attacker_msg);
     echo "<div class='ninja-error'>{$attackee} has killed you!</div>\n";
     echo "<div class='ninja-notice'>\n\t\t\t\tYou have been slain!  Go to the <a href=\"shrine.php\">Shrine</a> to return to the living.<br>\n\t\t\t\t</div>\n";
     if (!$simultaneousKill) {
         echo "{$attackee} has taken {$loot} gold from you.<br>\n";
     }
 }
 // *** END MAIN ATTACK AND DUELING SECTION ***
Example #2
0
<?php 
$turn_cost = 1;
$attacked = in('attacked');
$victim = in('victim');
$random_encounter = rand(1, 200) == 200;
if (getTurns($username) > 0) {
    if ($attacked == 1) {
        // *** Bit to expect that it comes from the form. ***
        echo "Commencing Attack<br><br>\n";
        if (getStatus($username) && $status_array['Stealth']) {
            subtractStatus($username, STEALTH);
        }
        $attacker_str = getStrength($username);
        $attacker_health = getHealth($username);
        $attacker_gold = getGold($username);
        if ($random_encounter == true) {
            // *** ONI, M********a! ***
            // **********************************************************
            // *** Oni attack! Yay!                                   ***
            // *** They take turns and a kill and do a little damage. ***
            // **********************************************************
            $victim = "Oni";
            $oni_turn_loss = 10;
            $oni_health_loss = rand(1, 20);
            $oni_kill_loss = 1;
            $player_turns = subtractTurns($username, $oni_turn_loss);
            $attacker_health = subtractHealth($username, $oni_health_loss);
            $attacker_kills = subtractKills($username, $oni_kill_loss);
            $oni_killed = false;
            if ($player_turns > 50 && $attacker_health > 0) {
Example #3
0
         } else {
             if ($turns_change > 0) {
                 echo "{$target}'s turns increased by {$turns_change}.<br>\n";
             }
         }
     }
 }
 if (!$victim_alive) {
     // Target was killed by the item.
     if (getStatus($username) && $target != $username) {
         // *** SUCCESSFUL KILL ***
         $attacker_id = $status_array['Stealth'] ? "A Stealthed Ninja" : $username;
         if (!$gold_mod) {
             $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 {$article} {$item->getName()}!<br>\n";
         echo "You receive {$loot} gold from {$target}.<br>\n";
         runBountyExchange($username, $target);
         //Rewards or increases bounty.
     } else {
         $loot = 0;
         echo "You have comitted suicide!<br>\n";
     }
     send_kill_mails($username, $target, $attacker_id, $article, $item->getName(), $today, $loot);
 } else {
     $attacker_id = $username;
 }
Example #4
0
    if ($command == "Bribe") {
        switch (true) {
            case $bribe <= getGold($username) && $bribe > 0:
                subtractGold($username, $bribe);
                subtractBounty($username, $bribe / 2);
                $location = "Behind the Doshin Office";
                $description = "\"We'll see what we can do,\" one of the Doshin tells you as you hand off your gold. He then directs you out through a back alley.\n" . "<br><br>\n" . "You find yourself in a dark alley. A rat scurries by. To your left lies the main street of the village.\n";
                $quickstat = "player";
                break;
            case $bribe < 0:
                // A negative bribe was put in, which on the 21st of March, 2007, was a road to instant wealth, as a bribe of -456345 would increase both your bounty and your gold by 456345, so this will flag players as bugabusers until it becomes a standard-use thing.
                if (getGold($username) > 1000) {
                    $bountyGoesToNearlyZero = getBounty($username) * 0.7;
                    subtractBounty($username, $bountyGoesToNearlyZero);
                }
                subtractGold($username, floor(getGold($username) * 0.8));
                //Takes away 80% of the players gold.
                $location = "The Rat-infested Alley behind the Doshin Office";
                $description = "\"Trying to steal from the Doshin, eh!\" one of the men growls.<br>Where before there were only relaxing men idly ignoring their duties there are now unsheathed katanas and glaring eyes.<br>A group of the Doshin advance on you before you can escape and proceed to rough you up with fists and the hilts of their katana.  Finally, they take most of your gold and toss you into the alley behind the building.\n" . "<br><br>\n" . "Bruised and battered, you find yourself in a dark alley. A rat scurries by. To your left lies the main street of the village.\n";
                $quickstat = "player";
                break;
            default:
                echo "The Doshin ignore your ill-funded attempt to bribe them.\n";
                break;
        }
    }
}
echo "<div class=\"brownTitle\">{$location}</div>\n";
echo "<div class=\"description\">\n";
echo $description;
echo "</div>\n";
Example #5
0
                echo "</a>";
            }
            echo ":\n  </td>\n";
            echo "  <td>\n";
            echo $amount . "\n";
            echo "  </td>\n";
            echo "</tr>\n";
        }
    }
    echo "</table>\n";
}
?>
  <br><br>
  <a href="list_all_players.php?hide=dead">Use an Item on a ninja?</a>
  <form id="player_search" action="list_all_players.php" method="get" name="player_search">
    <div>
      <input id="searched" type="text" maxlength="50" name="searched" class="textField">
      <input id="hide" type="hidden" name="hide" value="dead">
      <input type="submit" value="Search for Ninja" class="formButton">
    </div>
  </form>

  <br>
  Current gold: <?php 
echo getGold($username);
?>

</p>

<?php 
include SERVER_ROOT . "interface/footer.php";
Example #6
0
$bet = intval(in('bet'));
$reward = "Fire Scroll";
echo "Welcome to the Casino, {$username}!<br>\n";
echo "<form id=\"coin_flip\" action=\"casino.php\" method=\"post\" name=\"coin_flip\">\n";
if ($bet >= 5 && $bet <= 1000) {
    if ($bet <= getGold($username)) {
        $answer = rand(1, 2);
        if ($answer == 1) {
            echo "<div class='ninja-notice'>You win!</div>\n";
            addGold($username, $bet);
            if ($bet == 1000) {
                addItem($username, $reward, 1);
            }
        } else {
            if ($answer == 2) {
                echo "<div class='ninja-notice'>You lose!</div>\n";
                subtractGold($username, $bet);
            }
        }
        echo "<br><a href=\"casino.php\">Try Again?</a><br>\n";
    } else {
        echo "You do not have that much gold.<br>\n";
    }
} else {
    echo "The minimum bet at this table is 5 gold.<br>\n";
    echo "The maximum bet at this table is 1,000 gold.<br>\n";
}
echo "Bet: <input id=\"bet\" type=\"text\" size=\"3\" maxlength=\"4\" name=\"bet\" class=\"textField\">\n";
echo "&nbsp;&nbsp;<input type=\"submit\" value=\"Place bet\" class=\"formButton\"><br>\n";
echo "Current Gold: " . getGold($username) . "<br>\n";
include SERVER_ROOT . "interface/footer.php";
Example #7
0
<?php

$alive = false;
$private = false;
$quickstat = "viewinv";
$page_title = "Shop";
include SERVER_ROOT . "interface/header.php";
$description = "";
$in_purchase = in('purchase');
$in_quantity = in('quantity');
$item = in('item');
$grammar = "";
$username = get_username();
$gold = either(getGold($username), 0);
$current_item_cost = 0;
$quantity = intval($in_quantity);
if (!$quantity || $quantity < 1) {
    $quantity = 1;
} else {
    if ($quantity > 1 && $item != "Shuriken") {
        $grammar = "s";
    }
}
$item_costs = array("Speed Scroll" => 225, "Fire Scroll" => 175, "Stealth Scroll" => 150, "Ice Scroll" => 125, "Shuriken" => 50);
if ($in_purchase == 1) {
    $current_item_cost = either($item_costs[$item], 0);
    $current_item_cost *= $quantity;
    if ($current_item_cost > $gold) {
        // Not enough gold.
        $description .= "<p>\"The total comes to {$current_item_cost} gold,\" the shopkeeper tells you.</p>";
        $description .= "<p>Unfortunately, you do not have that much gold.</p>";
Example #8
0
function doAction($params = NULL)
{
    global $ikariam, $island_names, $debug;
    //Make sure the simple dom parser is loaded
    if (!function_exists('str_get_html')) {
        die("str_get_html() does not exist.");
    }
    //Set some variables
    $url = $ikariam['session']['base_url'];
    $cookie = $ikariam['session']['cookie'];
    //Add the action request in get requests
    if (isset($params['get']['actionRequest']) && $params['get']['actionRequest'] === TRUE) {
        $params['get']['actionRequest'] = $ikariam['hidden_inputs']['actionRequest'];
    }
    //Add the action request in post requests
    if (isset($params['post'])) {
        if (!isset($ikariam['hidden_inputs']['actionRequest'])) {
            return false;
        }
        $params['post']['actionRequest'] = $ikariam['hidden_inputs']['actionRequest'];
    }
    if ($debug) {
        echo "<pre>";
    }
    if ($debug) {
        print_r($params);
    }
    //Perform the page fetch
    $response = fetchPage($url, $cookie, $params);
    //Make sure cookie's valid
    if (!checkCookie($response['header'])) {
        die("Cookie expired!");
    }
    if ($debug > 1) {
        echo "<pre>";
        print_r($response['body']);
    }
    //Get the html object for the response
    $html_obj = str_get_html($response['body']);
    //Check for errors
    if (checkResponseForErrors($html_obj)) {
        if ($debug) {
            echo "<pre>";
            print_r(debug_backtrace());
            foreach ($ikariam['errors']['messages'] as $error) {
                echo $error . "<br />\n";
            }
            die;
        } else {
            return $html_obj;
        }
    }
    //Update the hidden input variables
    $ikariam['hidden_inputs'] = getHiddenInputs($html_obj);
    //Get the city names
    $ikariam['cities']['names'] = getCityNames($html_obj);
    //Get the current city name and id
    $ikariam['current_city_id'] = getCurrentCityID($html_obj);
    $ikariam['current_city'] = $ikariam['cities']['names'][$ikariam['current_city_id']];
    $ikariam['current_island_id'] = getCurrentIslandID($html_obj);
    $ikariam['current_island'] = $island_names[$ikariam['current_island_id']];
    //Get the global resources
    $ikariam['cities']['global']['resources']['ships'] = getShips($html_obj);
    //Get ships
    $ikariam['cities']['global']['resources']['ambrosia'] = getAmbrosia($html_obj);
    //Get the ambrosia
    $ikariam['cities']['global']['resources']['gold'] = getGold($html_obj);
    //Get the gold
    //Fetch the current resources if they exist
    $current_city_resources = getCityInfo($html_obj);
    if ($current_city_resources != NULL && $current_city_resources != FALSE) {
        $ikariam['cities'][$ikariam['current_city_id']] = $current_city_resources;
    }
    setIkariamFile();
    //Return
    return $html_obj;
}
Example #9
0
 /**
  * Command for a user to reduce their bounty by paying their own gold
  *
  * @param bribe int The amount to spend on reducing bounty
  * @return Array
  */
 public function bribe()
 {
     $bribe = intval(in('bribe'));
     $error = 0;
     $quickstat = false;
     if ($bribe <= get_gold($this->sessionData['char_id']) && $bribe > 0) {
         subtract_gold($this->sessionData['char_id'], $bribe);
         subtractBounty($this->sessionData['char_id'], $bribe / 2);
         $location = 1;
         $quickstat = 'player';
     } else {
         if ($bribe < 0) {
             // Was a bug, now the doshin beats you up!  Yay!
             if (get_gold($this->sessionData['char_id']) > 1000) {
                 //  *** If they have more than 1000 gold, their bounty will be mostly removed by this event.
                 $bountyReduction = getBounty($this->sessionData['char_id']) * 0.7;
                 subtractBounty($this->sessionData['char_id'], $bountyReduction);
             }
             subtractGold($this->sessionData['username'], floor(getGold($this->sessionData['username']) * 0.8));
             //Takes away 80% of the players gold.
             $location = 2;
             $quickstat = 'player';
         } else {
             $location = 0;
             $error = 5;
         }
     }
     return $this->render(['error' => $error, 'quickstat' => $quickstat, 'location' => $location, 'command' => 'bribe']);
 }
Example #10
0
<hr>

<br>

<div id='heal-result'>

<?php 
$healed = in('healed');
$poisoned = in('poisoned');
$restore = in('restore');
$max_heal = in('max_heal');
$heal_and_resurrect = in('heal_and_resurrect');
$userLevel = getLevel($username);
$startingHealth = getHealth($username);
$startingGold = getGold($username);
$startingKills = getKills($username);
$startingTurns = getTurns($username);
$level = getLevel($username);
$heal_points = in('heal_points') ? intval(in('heal_points')) : null;
// The pointwise healing method.
$freeResLevelLimit = 6;
$freeResKillLimit = 25;
$lostTurns = 10;
// *** Default turns lost when the player has no kills.
$has_chi = $skillsListObj->hasSkill('Chi');
// Extra healing benefits from chi, by level.
// *** A True or False as to whether resurrection will be free.
$freeResurrection = $userLevel < $freeResLevelLimit && $startingKills < $freeResKillLimit;
if ($heal_and_resurrect) {
    // Set resurrect if needed.
Example #11
0
function takeGold($from, $to, $mod)
{
    global $sql;
    $victim_gold = getGold($from);
    $gold_change = round($victim_gold * $mod);
    $gold_change = $gold_change < 0 ? 0 : $gold_change;
    addGold($to, $gold_change);
    subtractGold($from, $gold_change);
    echo "{$to} has acquired {$gold_change} gold from {$from}.<br>\n";
    return $gold_change;
}
Example #12
0
$quickstat = "player";
$page_title = "Working in the Village";
include SERVER_ROOT . "interface/header.php";
?>

<div class="brownTitle">Working in the Village</div>

<?php 
$work_multiplier = 30;
$description2 = "<div class=\"description\">\n" . "On your way back from the fields, you pass by a few young children " . "chasing grasshoppers in the tall grass.\n" . "<br><br>\n" . "The foreman hands you a small pouch of gold as he says " . "\"Care to put a little more work in? I'll keep paying you.\"\n" . "</div>\n";
$description1 = "<div class=\"description\">\n" . "On your way to the foreman's office, you pass by several workers " . "drenched in sweat from working in the heat all day.\n" . "<br><br>\n" . "The foreman barely looks up at you as he busies himself with paperwork " . "and a cigarette. \"So, how much work can we expect from you?\"\n" . "</div>\n";
$description = $description1;
$worked = intval(in('worked'));
if ($worked > 0) {
    $turns = getTurns($username);
    $gold = getGold($username);
    if ($worked > $turns) {
        $description .= "You have chosen to do more work than turns you have.<br>\n";
    } else {
        $new_gold = $worked * $work_multiplier;
        // *** calc amount worked ***
        $gold = addGold($username, $new_gold);
        $turns = subtractTurns($username, $worked);
        $description = $description2 . "You have worked for {$worked} turns and earned {$new_gold} gold.<br><br>\n";
    }
}
echo $description;
echo "<p>";
echo "You can earn money by working in the Village<br>\n";
echo "Village work will exchange turns for gold.<br>\n";
echo "The current work exchange rate: 1 Turn = " . $work_multiplier . " Gold.<br>\n";