Exemplo n.º 1
0
 public function __construct(Player $player, array $skills = [], $job = 0, array $status = [], $mana = -1, $health = -1)
 {
     $this->isArmed = true;
     $this->player = $player;
     $this->job = JobManager::getJob($job);
     $this->status = new PlayerStatus($status, $this);
     $this->armorStatus = new Status([Status::MAX_HP => 0, Status::MAX_MP => 0, Status::STR => 0, Status::INT => 0, Status::DEX => 0, Status::LUK => 0]);
     $this->skillStatus = new Status([Status::MAX_HP => 0, Status::MAX_MP => 0, Status::STR => 0, Status::INT => 0, Status::DEX => 0, Status::LUK => 0]);
     $this->mana = $mana === -1 ? $this->getFinalValue(Status::MAX_MP) : $mana;
     $this->health = $health === -1 ? $this->getFinalValue(Status::MAX_HP) : $health;
     $this->skills = [];
     foreach ($skills as $skillTag) {
         $skillData = explode(";", $skillTag);
         $skill = SkillManager::getSkill($skillData[0]);
         $skill->setPlayer($this);
         if (count($skillData) > 1) {
             $skill->setLevel($skillData[1]);
         }
         $this->skills[$skill->getItem()->getId() . ";" . $skill->getItem()->getDamage()] = $skill;
         $skill->onPassiveInit();
     }
     $this->notifyXP();
     $this->finalUse = 0;
     if (ToAruPG::getConfiguration("remove-hunger", false)) {
         $this->sendAttribute(Attribute::getAttribute(ToAruPG::ATTRIBUTE_HUNGER)->setValue(0)->setMaxValue(0));
     }
 }
Exemplo n.º 2
0
 public function buy(Player $buyer)
 {
     $rpg = ToAruPG::getInstance()->getRPGPlayerByName($buyer);
     $job = JobManager::getJob($this->jobId);
     $rpg->changeJob($job);
     foreach ($job->getSkills() as $skill) {
         $skill = SkillManager::getSkill($skill);
         if (!$skill->canBeAcquired($rpg)) {
             $buyer->sendMessage(TextFormat::RED . ToAruPG::getTranslation("SKILL_COULD_NOT_ACQUIRE", ToAruPG::getTranslation($skill->getName())));
             continue;
         }
         if ($rpg->hasSkill($skill->getId())) {
             $buyer->sendMessage(TextFormat::RED . ToAruPG::getTranslation("ALREADY_HAS_SKILL", ToAruPG::getTranslation($skill->getName())));
             continue;
         }
         $rpg->acquireSkill($skill);
     }
     EconomyAPI::getInstance()->reduceMoney($buyer, $this->cost, true, "To Aru Shop");
     $buyer->sendMessage(TextFormat::AQUA . ToAruPG::getTranslation("BOUGHT"));
 }
Exemplo n.º 3
0
 public function onSignChange(SignChangeEvent $event)
 {
     $text = $event->getLines();
     $prefix = strtoupper($text[0]);
     if ($prefix !== "[ARUSHOP]") {
         return;
     }
     if (!$event->getPlayer()->hasPermission("arushop.create")) {
         $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("NO_PERMISSION"));
         return;
     }
     $cost = $text[2];
     $meta = $text[3];
     $tag = $event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ() . ";" . $event->getBlock()->getLevel()->getFolderName();
     if (!is_numeric($cost) || !is_numeric($meta)) {
         $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("WRONG_SHOP_META"));
         return;
     }
     switch (strtoupper($text[1])) {
         case "JOB":
             if (JobManager::getJob($meta) === null) {
                 $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("WRONG_SHOP_META"));
                 return;
             }
             $this->shops[$tag] = new JobShop($meta, $cost, ToAruPG::getTranslation("TAP_ONE_MORE"));
             $meta = ToAruPG::getTranslation(JobManager::getJob($meta)->getName());
             $name = ToAruPG::getTranslation("JOB_SHOP");
             break;
         case "SKILL":
             if (SkillManager::getSkill($meta) === null) {
                 $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("WRONG_SHOP_META"));
                 return;
             }
             $this->shops[$tag] = new SkillShop($meta, $cost, ToAruPG::getTranslation("TAP_ONE_MORE"));
             $meta = ToAruPG::getTranslation(SkillManager::getSkill($meta)->getName());
             $name = ToAruPG::getTranslation("SKILL_SHOP");
             break;
         case "SET":
             if (JobManager::getJob($meta) === null) {
                 $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("WRONG_SHOP_META"));
                 return;
             }
             $this->shops[$tag] = new SetShop($meta, $cost, ToAruPG::getTranslation("TAP_ONE_MORE"));
             $meta = ToAruPG::getTranslation(JobManager::getJob($meta)->getName());
             $name = ToAruPG::getTranslation("SET_SHOP");
             break;
         default:
             $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("WRONG_SHOP_META"));
             return;
     }
     $this->saveShops();
     $event->setLine(0, $name);
     $event->setLine(1, TextFormat::AQUA . $meta);
     $event->setLine(2, $cost . EconomyAPI::getInstance()->getMonetaryUnit());
     $event->setLine(3, "");
     $event->getPlayer()->sendMessage(TextFormat::AQUA . ToAruPG::getTranslation("SHOP_CREATED"));
 }
Exemplo n.º 4
0
 public function buy(Player $buyer)
 {
     ToAruPG::getInstance()->getRPGPlayerByName($buyer)->changeJob(JobManager::getJob($this->jobId));
     EconomyAPI::getInstance()->reduceMoney($buyer, $this->cost, true, "To Aru Shop");
     $buyer->sendMessage(TextFormat::AQUA . ToAruPG::getTranslation("BOUGHT"));
 }