コード例 #1
0
ファイル: hero.php プロジェクト: kroony/squealing-funicular
 function loadHeroFromObject($obj)
 {
     $returnHero = new Hero();
     $returnHero->ID = $obj->ID;
     $returnHero->OwnerID = $obj->OwnerID;
     $returnHero->PartyID = $obj->PartyID;
     $returnHero->Race = Race::loadRace($obj->Race);
     $returnHero->Name = $obj->Name;
     $returnHero->HeroClass = HeroClass::loadHeroClass($obj->Class);
     $returnHero->MaxHP = $obj->MaxHP;
     $returnHero->CurrentHP = floor($obj->CurrentHP);
     $returnHero->Level = $obj->Level;
     $returnHero->CurrentXP = $obj->CurrentXP;
     $returnHero->LevelUpXP = $obj->LevelUpXP;
     $returnHero->Str = $obj->Str;
     $returnHero->Dex = $obj->Dex;
     $returnHero->Con = $obj->Con;
     $returnHero->Intel = $obj->Intel;
     $returnHero->Wis = $obj->Wis;
     $returnHero->Cha = $obj->Cha;
     $returnHero->Fte = $obj->Fte;
     $returnHero->Weapon = Weapon::loadWeapon($obj->WeaponID);
     $returnHero->Kills = $obj->Kills;
     $returnHero->Status = $obj->Status;
     $returnHero->StatusTime = new DateTime($obj->StatusTime);
     $returnHero->DateOfBirth = new DateTime($obj->DateOfBirth);
     $now = new DateTime('now');
     $returnHero->Age = $returnHero->DateOfBirth->diff($now)->format('%a');
     $returnHero->StatusETA = $returnHero->StatusTime->diff($now)->format('%R%a days, %H:%I:%S');
     if (substr($returnHero->StatusETA, 0, 1) == '+') {
         $returnHero->StatusETA = "None";
     }
     return $returnHero;
 }
コード例 #2
0
ファイル: sale.php プロジェクト: kroony/squealing-funicular
 function loadSaleFromObject($obj)
 {
     $returnSale = new Sale();
     $returnSale->ID = $obj->ID;
     $returnSale->SellerID = $obj->SellerID;
     $returnSale->ItemType = $obj->ItemType;
     $returnSale->ItemID = $obj->ItemID;
     $returnSale->Price = $obj->Price;
     $returnSale->Created = new DateTime($obj->Created);
     //load the actual object for sale
     if ($returnSale->ItemType == "Weapon") {
         $returnSale->Item = Weapon::loadWeapon($returnSale->ItemID);
     }
     return $returnSale;
 }
コード例 #3
0
 } else {
     if ($_REQUEST['action'] == "changeWeapon") {
         $weapon = Weapon::loadWeapon($_REQUEST['WeaponID']);
         // @TODO also check that weapon is currently unassigned,
         // so people like me cannot cheat and assign a weapon twice
         if ($weapon->UserID == $currentUID) {
             $hero->Weapon = $weapon;
             $hero->SaveHero();
             $smarty->assign("hero", $hero);
             $smarty->assign("message", $hero->Name . " has equipped " . $weapon->Name);
         } else {
             $smarty->assign("error", "That does not belong to you.");
         }
     } else {
         if ($_REQUEST['action'] == "editWeaponName") {
             $weapon = Weapon::loadWeapon($_REQUEST['WeaponID']);
             if ($weapon->UserID == $currentUID) {
                 $oldName = $weapon->Name;
                 $weapon->Name = $_REQUEST['weaponName'];
                 $weapon->save();
                 $smarty->assign("message", $oldName . " was renamed to " . $weapon->Name);
                 $hero->Weapon = $weapon;
                 $smarty->assign("hero", $hero);
             } else {
                 $smarty->assign("error", "You can't rename what does not belong to you.");
             }
         } else {
             if ($_REQUEST['action'] == "levelUp") {
                 if ($hero->canLevelUp()) {
                     if ($hero->Status == "") {
                         $hero->Status = "Level Up";
コード例 #4
0
ファイル: hero.php プロジェクト: ndroo/squealing-funicular
 function GenerateHero($level)
 {
     //Race
     $this->Race = $this->GenerateRace();
     echo "Race: " . $this->Race->Name . "<br />";
     //Name
     $this->Name = $this->Race->generateHeroName();
     echo "Name: " . $this->Name . "<br />";
     //Attributes
     echo "Str ";
     $this->Str = $this->GenerateAtribute($this->Race->StrBon);
     //include bonuses argument and level argument
     echo "Dex ";
     $this->Dex = $this->GenerateAtribute($this->Race->DexBon);
     echo "Con ";
     $this->Con = $this->GenerateAtribute($this->Race->ConBon);
     echo "Int ";
     $this->Intel = $this->GenerateAtribute($this->Race->IntelBon);
     echo "Wis ";
     $this->Wis = $this->GenerateAtribute($this->Race->WisBon);
     echo "Cha ";
     $this->Cha = $this->GenerateAtribute($this->Race->ChaBon);
     echo "Fte ";
     $this->Fte = $this->GenerateAtribute($this->Race->FteBon);
     //Class
     $this->HeroClass = $this->GenerateHeroClass();
     echo "<br />Class: " . $this->HeroClass->Name . " HD: D" . $this->HeroClass->HD . "<br />";
     //HP
     $this->MaxHP = $this->HeroClass->HD + $this->calculateAttributeBonus($this->Con);
     //base the multiplyer on HD and con
     $this->CurrentHP = $this->MaxHP;
     echo "Hit Points: " . $this->CurrentHP . "/" . $this->MaxHP . "<br />";
     //Level
     $this->Level = 1;
     echo "Level:" . $this->Level . "<br />";
     //XP
     $XPBonus = rand(0, $this->Fte);
     $this->CurrentXP = 0;
     $this->LevelUpXP = 100 - $XPBonus;
     echo "XP: " . $this->CurrentXP . "/" . $this->LevelUpXP . " Luck Bonus: " . $XPBonus . "<br />";
     //check for levelup
     if ($level > 1) {
         $i = 0;
         while ($i < $level - 1) {
             if ($this->forceLevelUP()) {
                 $i++;
             } else {
                 break;
             }
         }
     }
     //generate weapon
     $this->Weapon = Weapon::loadWeapon(rand(1, 9));
 }
コード例 #5
0
$user = new User();
$user = $user->load($currentUID);
$heroController = new heroController();
$userChaBonus = $heroController->getChaModForUser($currentUID);
$smarty->assign("userChaBonus", $userChaBonus);
//html header
$smarty->display("css/css.tpl");
$weaponController = new weaponController();
//menu
$smarty->assign("currentpage", "inventory");
$smarty->assign("help", "This page displays all the weapon you have. Weapons can be scrapped if not required, so long as they are not currently equipped.\n\t\t\t\t\t  Clicking the Weapon Name will allow you to upgrade and rename the weapon. \n\t\t\t\t\t  Clicking a heroes name will show more detailed information about that hero.");
$smarty->assign("helpTitle", "Weapons Page Help");
include_once "menu.php";
if (isset($_REQUEST['action'])) {
    if ($_REQUEST['action'] == "scrap") {
        $scrapWeapon = Weapon::loadWeapon($_REQUEST['ID']);
        if ($scrapWeapon->UserID == $currentUID) {
            if (!is_numeric($scrapWeapon->GetHeroIDFromWeapon())) {
                $user->gold += $scrapWeapon->getScrapValue($userChaBonus);
                $user->Save();
                $scrapWeapon->delete();
                $smarty->assign("message", $scrapWeapon->Name . " has been scrapped for " . $scrapWeapon->getScrapValue($userChaBonus) . "gp");
            } else {
                $smarty->assign("error", "Can not scrap equipped weapons");
            }
        } else {
            $smarty->assign("error", "This is not your weapon to scrap");
        }
    }
}
$tmpHero = new Hero();