From 959d7149dbb2c7aaed257704cbb19254a5f63b90 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Thu, 11 Aug 2016 11:00:32 +0300 Subject: [PATCH] potions on the Werewolfs --- games/LoupGarou.php | 98 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 7 deletions(-) diff --git a/games/LoupGarou.php b/games/LoupGarou.php index dfe8a5f..735e784 100644 --- a/games/LoupGarou.php +++ b/games/LoupGarou.php @@ -1,4 +1,11 @@ current = null; $this->killed = null; $this->maire = null; - $this->potions = ["life" => true, "death" => true]; + $this->potions = ["life" => true, "death" => true, "speed" => true, "slow" => true, "regen" => true, "poison" => true]; $this->getServer()->getScheduler()->scheduleRepeatingTask(new FirstDayTask($this), 20); } @@ -194,10 +201,28 @@ class LoupGarou extends Game { case "sorcière": if($event->getDamager() instanceof Player) { if($this->getRole($event->getDamager()) == "Sorcière" and $this->getRole($event->getEntity()) !== "Sorcière") { - if($event->getDamager()->getInventory()->getItemInHand()->getId() == 373 and $event->getDamager()->getInventory()->getItemInHand()->getDamage() == 23) { - $this->killed2 = $event->getEntity(); - $this->potions["death"] = false; - $this->task->turn = 390; + if($event->getDamager()->getInventory()->getItemInHand()->getId() == 373) { + if($event->getDamager()->getInventory()->getItemInHand()->getDamage() == 23) { + $this->killed2 = $event->getEntity(); + $this->potions["death"] = false; + $this->task->turn = 390; + } elseif($event->getDamager()->getInventory()->getItemInHand()->getDamage() == 14) { + $this->speed = $event->getEntity(); + $this->potions["speed"] = false; + $this->task->turn = 390; + } elseif($event->getDamager()->getInventory()->getItemInHand()->getDamage() == 17) { + $this->slow = $event->getEntity(); + $this->potions["slowness"] = false; + $this->task->turn = 390; + } elseif($event->getDamager()->getInventory()->getItemInHand()->getDamage() == 28) { + $this->regen = $event->getEntity(); + $this->potions["regen"] = false; + $this->task->turn = 390; + } elseif($event->getDamager()->getInventory()->getItemInHand()->getDamage() == 25) { + $this->poison = $event->getEntity(); + $this->potions["poison"] = false; + $this->task->turn = 390; + } } } } @@ -779,13 +804,44 @@ class DayTask extends \pocketmine\scheduler\PluginTask { if(isset($this->main->Sorcière)) { $this->main->broadcastMessage("La sorcière se réveille !"); $this->main->Sorcière->removeEffectByName("BLINDNESS"); + $r = rand(0, 40); + if($r <= 3) { + if($r == 0) { + $this->main->potions["speed"] = true; + $this->main->Sorcière->sendMessage("Vous avez concocté une potion de speed !"); + } + if($r == 1) { + $this->main->potions["slowness"] = true; + $this->main->Sorcière->sendMessage("Vous avez concocté une potion de lenteur !"); + } + if($r == 2) { + $this->main->potions["regen"] = true; + $this->main->Sorcière->sendMessage("Vous avez concocté une potion de regeneration !"); + } + if($r == 3) { + $this->main->potions["poison"] = true; + $this->main->Sorcière->sendMessage("Vous avez concocté une potion de poison !"); + } + } $this->main->Sorcière->sendMessage($this->main->killed->getName() . " a été tué cette nuit ! Souaitez vous le resuciter (boire la potion de vie), ou tuer une autre personne (la taper avec la potion de mort). Faites attention, ces potions n'ont qu'un seul usage dans la partie."); - if($this->potions["life"]) { + if($this->main->potions["life"]) { $this->main->Sorcière->getInventory()->addItem(Item::get(Item::POTION, 21, 1)->setCompoundTag(\pocketmine\nbt\NBT::parseJSON("{display:{Name:'Potion de vie\\n \\n \\n \\n'},Unbreakable:1}"))); } - if($this->potions["death"]) { + if($this->main->potions["death"]) { $this->main->Sorcière->getInventory()->addItem(Item::get(Item::POTION, 23, 1)->setCompoundTag(\pocketmine\nbt\NBT::parseJSON("{display:{Name:'Potion de mort\\n \\n \\n \\n'},Unbreakable:1}"))); } + if($this->main->potions["speed"]) { + $this->main->Sorcière->getInventory()->addItem(Item::get(Item::POTION, 23, 1)->setCompoundTag(\pocketmine\nbt\NBT::parseJSON("{display:{Name:'Potion de speed\\n \\n \\n \\n'},Unbreakable:1}"))); + } + if($this->main->potions["slowness"]) { + $this->main->Sorcière->getInventory()->addItem(Item::get(Item::POTION, 23, 1)->setCompoundTag(\pocketmine\nbt\NBT::parseJSON("{display:{Name:'Potion de lenteur\\n \\n \\n \\n'},Unbreakable:1}"))); + } + if($this->main->potions["poison"]) { + $this->main->Sorcière->getInventory()->addItem(Item::get(Item::POTION, 23, 1)->setCompoundTag(\pocketmine\nbt\NBT::parseJSON("{display:{Name:'Potion de poison\\n \\n \\n \\n'},Unbreakable:1}"))); + } + if($this->main->potions["regen"]) { + $this->main->Sorcière->getInventory()->addItem(Item::get(Item::POTION, 23, 1)->setCompoundTag(\pocketmine\nbt\NBT::parseJSON("{display:{Name:'Potion de regen\\n \\n \\n \\n'},Unbreakable:1}"))); + } $this->main->current = "sorcière"; } else { $this->turn = 395; @@ -897,6 +953,34 @@ class DayTask extends \pocketmine\scheduler\PluginTask { $this->turn = 0; break; } + if(isset($this->speed)) { + $e = \pocketmine\entity\Effect::getEffect(1); + $e->setAmplifier(2); + $e->setVisible(false); + $e->setDuration(40); + $this->speed->addEffect($e); + } + if(isset($this->slow)) { + $e = \pocketmine\entity\Effect::getEffect(2); + $e->setAmplifier(2); + $e->setVisible(false); + $e->setDuration(40); + $this->slow->addEffect($e); + } + if(isset($this->poison)) { + $e = \pocketmine\entity\Effect::getEffectByName("POISON"); + $e->setAmplifier(2); + $e->setVisible(false); + $e->setDuration(40); + $this->poison->addEffect($e); + } + if(isset($this->regen)) { + $e = \pocketmine\entity\Effect::getEffect(10); + $e->setAmplifier(2); + $e->setVisible(false); + $e->setDuration(40); + $this->regen->addEffect($e); + } $this->turn++; } } \ No newline at end of file