Beispiel #1
0
                                                    echo "You have gained {$thief_gold} gold.<br> You have found a Shuriken on the thief!\n";
                                                    addGold($username, $thief_gold);
                                                    addItem($username, 'Shuriken', $quantity = 1);
                                                }
                                            }
                                            echo "<br>\n";
                                            echo "Beware the Ninja Thieves, they have entered this world to steal from all!<br>\n";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (getHealth($username) <= 0) {
            sendMessage("SysMsg", $username, "DEATH: You have been killed by a non-player character at {$today}");
            echo "<p>Go to the <a href=\"shrine.php\">shrine</a> to resurrect.</p>";
        }
        subtractTurns($username, $turn_cost);
        if ($victim && !$random_encounter) {
            echo "<a href=\"attack_npc.php?attacked=1&amp;victim={$victim}\">Attack {$victim} again</a>\n";
            echo "<br>\n";
        }
        echo "<a href=\"attack_player.php\">Return to Combat</a>\n";
    }
} else {
    echo "You have no turns left today. Buy a speed scroll or wait for your turns to replenish.\n";
}
include SERVER_ROOT . "interface/footer.php";
Beispiel #2
0
            $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 ***
    }
    if (!$duel && getHealth($username) > 0 && getHealth($attackee) > 0) {
        // *** After any partial attack. ***
        echo "<a href=\"attack_mod.php?attacked=1&amp;attackee={$attackee}\">Attack Again?</a><br>\n";
    }
}
// *** Take away at least one turn even on attacks that fail. ***
if ($turns_to_take < 1) {
    $turns_to_take = 1;
}
$ending_turns = subtractTurns($username, $turns_to_take);
assert($ending_turns < $starting_turns || $starting_turns == 0);
//  ***  START ACTION OVER AGAIN SECTION ***
echo "<hr>\n";
if (isset($attackee)) {
    echo "Return to <a href=\"player.php?player=" . urlencode($attackee) . "\">Player Detail</a><br>Or \n";
}
echo "Start your combat <a href=\"list_all_players.php\"> from the player list.</a>\n<br>\n";
echo "<hr><br>\n";
include SERVER_ROOT . "interface/footer.php";
Beispiel #3
0
 /**
  * End-user resurrect operation, incurs costs and revives the dead player
  *
  * @param p_player Player the player to resurrect
  * @return int The value of the resurrect cost type
  * @throws RuntimeException Player is not dead
  *
  * @par Side Effects:
  * The health attribute of $p_player is changed in memory and database
  *
  * @par Preconditions:
  * Player must be dead to resurrect
  *
  * @note
  * If the Player qualifies for enhanced resurrection effects, enhancedResurrect will be called
  *
  * @see enhancedResurrect
  */
 private function _resurrect($p_player)
 {
     if ($p_player->health() <= 0) {
         $costType = $this->calculateResurrectionCost($p_player);
         if ($costType === self::RES_COST_TYPE_KILL) {
             $this->enhancedResurrect($p_player);
         } else {
             $p_player->death();
             $p_player->heal($this->calculateResurrectionHP($p_player));
         }
         if ($costType === self::RES_COST_TYPE_KILL) {
             $p_player->vo->kills = subtractKills($p_player->id(), ShrineController::RES_COST_KILLS);
         } else {
             if ($costType === self::RES_COST_TYPE_TURN) {
                 $p_player->vo->turns = subtractTurns($p_player->id(), min(ShrineController::RES_COST_TURNS, $p_player->turns));
             }
         }
         return $costType;
     } else {
         throw new \RuntimeException('You are not dead.');
     }
 }
Beispiel #4
0
                                            subtract_gold($char_id, $thief_gold);
                                        } else {
                                            if ($thief_attack < 30) {
                                                add_gold($char_id, $thief_gold);
                                                add_item($char_id, 'shuriken', $quantity = 1);
                                            }
                                        }
                                    } else {
                                        $thief_gold = 0;
                                    }
                                    $npc_template = 'npc.thief.tpl';
                                    $combat_data = array('attack' => $thief_attack, 'gold' => $thief_gold, 'victory' => $victory);
                                }
                            }
                        }
                    }
                }
            }
        }
        // ************ End of specific npc logic *******************
        // ************ FINAL CHECK FOR DEATH ***********************
        if ($player->health() <= 0) {
            $health = false;
            sendMessage("SysMsg", $username, "DEATH: You have been killed by a " . $victim . " on {$today}");
        }
        // Subtract the turn cost for attacking an npc, almost always going to be 1 apart from perhaps oni or group-of-thieves
        subtractTurns($char_id, $turn_cost);
    }
    // Add the combat_data into the standard stuff.
    display_page('npc.tpl', 'Battle', array('npc_template' => $npc_template, 'attacked' => 1, 'turns' => $turns, 'random_encounter' => $random_encounter, 'health' => $health) + $combat_data, array('quickstat' => 'player'));
}
Beispiel #5
0
                            //non-covert acts
                            $player->subtractStatus(STEALTH);
                            $stealthLost = true;
                        } else {
                            $stealthLost = false;
                        }
                    }
                }
                $targetName = $targetObj->vo->uname;
                $targetHealth = $targetObj->vo->health;
                $targetHealthPercent = $targetObj->health_percent();
                $turns_to_take = 1;
                if ($item_used) {
                    // *** remove Item ***
                    removeItem($user_id, $item->getName(), 1);
                    // *** Decreases the item amount by 1.
                }
                if ($victim_alive && $using_item) {
                    $repeat = true;
                }
            }
        }
    }
    // *** Take away at least one turn even on attacks that fail to prevent page reload spamming ***
    if ($turns_to_take < 1) {
        $turns_to_take = 1;
    }
    $ending_turns = subtractTurns($user_id, $turns_to_take);
    assert($item->hasEffect('speed') || $ending_turns < $starting_turns || $starting_turns == 0);
    display_page('inventory_mod.tpl', 'Item Usage', get_defined_vars(), array('quickstat' => 'player'));
}
Beispiel #6
0
         $msg = "Ice bolt cast on you by {$attacker_id} at {$today}, your turns have been reduced by {$turns_decrease}.";
         sendMessage($attacker_id, $target, $msg);
         $result = "{$target}'s turns reduced by {$turns_decrease}!<br>\n";
     } else {
         $turn_cost = 0;
         echo "You do not have enough turns to cast {$command}.\n";
     }
 } else {
     if ($command == "Cold Steal") {
         if ($starting_turns >= $turn_cost) {
             $critical_failure = rand(1, 100);
             if ($critical_failure > 7) {
                 // *** If the critical failure rate wasn't hit.
                 if ($target_turns >= 5) {
                     $turns_decrease = rand(2, 5);
                     subtractTurns($target, $turns_decrease);
                     addTurns($username, $turns_decrease);
                     $msg = "You have had Cold Steal cast on you for {$turns_decrease} by {$attacker_id} at {$today}";
                     sendMessage($attacker_id, $target, $msg);
                     $result = "You cast Cold Steal on {$target} and take {$turns_decrease} of his turns.<br>\n";
                 } else {
                     $turn_cost = 0;
                     $result = "The victim did not have enough turns to give you.<br>\n";
                 }
             } else {
                 // *** CRITICAL FAILURE !!
                 addStatus($username, FROZEN);
                 $unfreeze_time = date("F j, Y, g:i a", mktime(date("G") + 1, 0, 0, date("m"), date("d"), date("Y")));
                 $failure_msg = "You have experienced a critical failure while using Cold Steal on {$today}. You will be unfrozen on {$unfreeze_time}";
                 sendMessage("SysMsg", $username, $failure_msg);
                 $result = "Cold Steal has backfired! You have lost 3 turns and are now frozen until {$unfreeze_time}!<br>\n";
Beispiel #7
0
            }
            setHealth($username, 100);
            subtractStatus($username, STEALTH + POISON + FROZEN + CLASS_STATE);
            // *** FREE STEALTHING FOR BLACK CLASS UPON NON-FREE RESURRECTION
            if ($players_class == "Black" && !$freeResurrection) {
                addStatus($username, STEALTH);
            }
            echo "What once was dead shall rise again.<br>\n";
            echo "Current Kills: " . $startingKills . "<br>\n";
            echo "Adjusted Kills after returning to life: " . getKills($username) . "<br>\n";
        } elseif ($startingTurns > 0) {
            echo "What once was dead shall rise again.<br>\n";
            if ($startingTurns < $lostTurns && $startingTurns > 0) {
                $lostTurns = $startingTurns;
            }
            subtractTurns($username, $lostTurns);
            // *** Takes away necessary turns.
            setHealth($username, 100);
            subtractStatus($username, STEALTH + POISON + FROZEN + CLASS_STATE);
            echo "Since you have no kills, your resurrection will cost you part of your life time.";
            echo "Current Turns: " . $startingTurns . "<br>\n";
            echo "Adjusted Turns after returning to life: " . getTurns($username) . "<br>\n";
        } else {
            echo "You must wait for time to pass before you can return to life.";
            echo "Current Turns: " . $startingTurns . "<br>\n";
        }
    }
}
// *** end of resurrection ***
if ($healed == 1 || $max_heal == 1) {
    //If the user tried to heal themselves.
Beispiel #8
0
             $turn_cost = 0;
             $generic_skill_result_message = "__TARGET__ does not have enough turns for you to take.";
         }
     } else {
         $turn_cost = 0;
         $generic_skill_result_message = '__TARGET__ is already iced.';
     }
 } else {
     if ($command == 'Cold Steal') {
         if (!$target->hasStatus(SLOW)) {
             $critical_failure = rand(1, 100);
             if ($critical_failure > 7) {
                 // *** If the critical failure rate wasn't hit.
                 if ($target->vo->turns >= 10) {
                     $turns_decrease = rand(2, 7);
                     subtractTurns($target->vo->player_id, $turns_decrease);
                     $target->addStatus(SLOW);
                     addTurns($char_id, $turns_decrease);
                     $msg = "You have had Cold Steal cast on you for {$turns_decrease} by {$attacker_id}";
                     send_event($attacker_char_id, $target->id(), $msg);
                     $generic_skill_result_message = "You cast Cold Steal on __TARGET__ and take {$turns_decrease} turns.";
                 } else {
                     $turn_cost = 0;
                     $generic_skill_result_message = '__TARGET__ did not have enough turns to give you.';
                 }
             } else {
                 // *** CRITICAL FAILURE !!
                 $player->addStatus(FROZEN);
                 $unfreeze_time = date('F j, Y, g:i a', mktime(date('G') + 1, 0, 0, date('m'), date('d'), date('Y')));
                 $failure_msg = "You have experienced a critical failure while using Cold Steal. You will be unfrozen on {$unfreeze_time}";
                 sendMessage("SysMsg", $username, $failure_msg);
Beispiel #9
0
    $work_multiplier = 30;
    $worked = $new_gold = $not_enough_energy = $use_second_description = null;
    $is_logged_in = is_logged_in();
    $worked = intval(in('worked'));
    $recommended_to_work = 10;
    // Store or retrieve the last value of turns worked.
    if ($worked && is_numeric($worked)) {
        set_setting('turns_worked', $worked);
        $recommended_to_work = $worked;
    } else {
        $last_worked = get_setting('turns_worked');
        $recommended_to_work = $last_worked ? $last_worked : 10;
    }
    // Work only if the work was requested, not just if the setting was set.
    if ($worked > 0) {
        $turns = get_turns($char_id);
        if ($worked > $turns) {
            $not_enough_energy = true;
        } else {
            $new_gold = $worked * $work_multiplier;
            // *** calc amount worked ***
            add_gold($char_id, $new_gold);
            $turns = subtractTurns($char_id, $worked);
            $use_second_description = true;
        }
    }
    $gold = get_gold($char_id);
    // Get the current/final gold.
    $gold_display = number_format($gold);
    display_page('work.tpl', 'Working in the Village', get_certain_vars(get_defined_vars(), array()), array('quickstat' => 'player'));
}
Beispiel #10
0
<?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";
echo "Work in the Village?<br>\n";
echo "<form id=\"work\" action=\"work.php\" method=\"post\" name=\"work\">\n";
echo "<div>\n";
echo "<input id=\"worked\" type=\"text\" size=\"3\" maxlength=\"3\" name=\"worked\" class=\"textField\">\n";
echo "<input id=\"workButton\" type=\"submit\" value=\"Turns\" name=\"workButton\" class=\"formButton\">\n";
echo "</div>\n";
echo "</form>\n";
Beispiel #11
0
    }
    if ($loot) {
        add_gold(get_char_id($victor), $loot);
        subtract_gold(get_char_id($loser), $loot);
    }
    if ($rounds > 4) {
        // Even matched battle!  Reward some ki to the attacker, even if they die.
        change_ki($attacker_id, 1);
        // Award Ki.
        $rewarded_ki = 1;
    }
}
// *** Take away at least one turn even on attacks that fail. ***
if ($turns_to_take < 1) {
    $turns_to_take = 1;
}
$ending_turns = subtractTurns($attacker_id, $turns_to_take);
//  ***  START ACTION OVER AGAIN SECTION ***
$attack_again = false;
if (isset($target)) {
    $attacker_health_snapshot = getHealth($attacker_id);
    $defender_health_snapshot = getHealth($target_id);
    if ($AttackLegal && $attacker_health_snapshot > 0 && $defender_health_snapshot > 0) {
        // *** After any partial attack. ***
        $attack_again = true;
    }
}
$target_ending_health = $target_player->health();
$target_ending_health_percent = $target_player->health_percent();
$target_name = $target_player->name();
display_page('attack_mod.tpl', 'Battle Status', get_defined_vars());