LOUP GAROU
This commit is contained in:
parent
b5330c7048
commit
12fac16eda
5 changed files with 430 additions and 27 deletions
|
@ -19,4 +19,5 @@ InGame4: "> > > CLICK TO SPECTATE < < <"
|
|||
# Example:
|
||||
redstone: Example
|
||||
spleef: Spleef
|
||||
world: LoupGarou
|
||||
...
|
|
@ -32,15 +32,16 @@ class LoupGarou extends Game {
|
|||
}
|
||||
$this->amoureux = [];
|
||||
$this->voted = [];
|
||||
$this->hasvoted = [];
|
||||
$this->current = null;
|
||||
$this->killed = null;
|
||||
$this->maire = null;
|
||||
$this->potions = ["life" => true, "death" => true];
|
||||
$this->getServer()->getScheduler()->scheduleRepeatingTask();
|
||||
$this->getServer()->getScheduler()->scheduleRepeatingTask(new FirstDayTask($this), 20);
|
||||
}
|
||||
|
||||
|
||||
public function onGameStop() {
|
||||
$this->getLogger()->info("Game stoped");
|
||||
foreach($this->getLevel()->getPlayers() as $p) {
|
||||
$p->setGamemode(0);
|
||||
$p->teleport($this->getServer()->getDefaultLevel()->getSafeSpawn());
|
||||
|
@ -51,7 +52,7 @@ class LoupGarou extends Game {
|
|||
public function onJoin(Player $player) {
|
||||
if($this->main->getInGamePlayers($this->getLevel()) + 1 >= $this->getMinPlayers() and !$this->isStarted()) {
|
||||
$this->getLogger()->info("Started !");
|
||||
$h = $this->getServer()->getScheduler()->scheduleRepeatingTask($t = new StartTask($this), 20);
|
||||
$h = $this->getServer()->getScheduler()->scheduleRepeatingTask($t = new StartLGTask($this), 20);
|
||||
$t->setHandler($h);
|
||||
if(isset($this->task)) {
|
||||
$this->getServer()->getScheduler()->cancelTask($this->task->getTaskId());
|
||||
|
@ -77,21 +78,50 @@ class LoupGarou extends Game {
|
|||
if($player->isSurvival() or $player->isAdventure()) {
|
||||
if($this->isStarted()) {
|
||||
foreach($this->getLevel()->getPlayers() as $p) {
|
||||
$p ->sendMessage(\pocketmine\utils\TextFormat::YELLOW . $player->getName() . " a quitté le loup garou. Il reste {$this->getPlugin()->getInGamePlayers($this->getLevel())} joueurs !", [$this->getLevel()->getPlayers()]);
|
||||
$p ->sendMessage(\pocketmine\utils\TextFormat::YELLOW . $player->getName() . " a quitté le loup garou. Il reste " . $this->getMinPlayers() - $this->getPlugin()->getInGamePlayers($this->getLevel()) . " joueurs !", [$this->getLevel()->getPlayers()]);
|
||||
}
|
||||
$player->sendMessage(\pocketmine\utils\TextFormat::YELLOW . "Vous avez quitté le loup garou. Il reste " . ($this->getMinPlayers() - $this->getPlugin()->getInGamePlayers($this->getLevel())) ." joueurs !");
|
||||
} else {
|
||||
foreach($this->getLevel()->getPlayers() as $p) {
|
||||
$p ->sendMessage(\pocketmine\utils\TextFormat::YELLOW . $player->getName() . " a quitté le loup garou. Il reste {$this->getPlugin()->getInGamePlayers($this->getLevel())} joueurs avant de demarer la partie !", [$this->getLevel()->getPlayers()]);
|
||||
$p ->sendMessage(\pocketmine\utils\TextFormat::YELLOW . $player->getName() . " a quitté le loup garou. Il reste " . $this->getMinPlayers() - $this->getPlugin()->getInGamePlayers($this->getLevel()) . "joueurs avant de demarer la partie !", [$this->getLevel()->getPlayers()]);
|
||||
}
|
||||
$player->sendMessage(\pocketmine\utils\TextFormat::YELLOW . "Vous avez quitté le loup garou. Il reste " . ($this->getMinPlayers() - $this->getPlugin()->getInGamePlayers($this->getLevel())) ." joueurs avant de demarer la partie !");
|
||||
$player->sendMessage(\pocketmine\utils\TextFormat::YELLOW . "Vous avez quitté le loup garou. Il reste " . ($this->getMinPlayers() - $this->getPlugin()->getInGamePlayers($this->getLevel())) ." joueurs avant de demarer la partie !");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function onPlayerDeath(\pocketmine\event\player\PlayerDeathEvent $event) {
|
||||
$event->setDeathMessage("");
|
||||
$this->broadcastMessage($event->getPlayer()->getName() . " est mort ! C'était un " . $this->getRole($player));
|
||||
$this->eliminate($event->getPlayer());
|
||||
}
|
||||
|
||||
|
||||
public function finish(bool $b) {
|
||||
if($b) {
|
||||
$l = $this->LoupGarou[count($this->LoupGarou) - 1];
|
||||
unset($this->LoupGarou[count($this->LoupGarou) - 1]);
|
||||
$n = [];
|
||||
foreach($this->LoupGarou as $lg) {
|
||||
$n[] = $lg->getName();
|
||||
}
|
||||
foreach($this->getLevel()->getPlayers() as $p) {
|
||||
$p->sendTip("§l" . (count($this->LoupGarou) == 0 ? implode(", ", $n) . " et " . $l->getName() : $l->getName()) . " (Loups Garous) ont gagnés la partie car tout les villageois sont mort ! \n\n\n§rRetour au lobby dans 30 secondes...");
|
||||
}
|
||||
} else {
|
||||
$v = $this->main->getInGamePlayers($this->getLevel());
|
||||
$l = $v[count($v) - 1];
|
||||
unset($v[count($v) - 1]);
|
||||
$n = [];
|
||||
foreach($v as $lg) {
|
||||
$n[] = $v->getName();
|
||||
}
|
||||
foreach($this->getLevel()->getPlayers() as $p) {
|
||||
$p->sendTip("§l" . (count($v) == 0 ? implode(", ", $n) . " et " . $l->getName() : $l->getName()) . " (Villageois) ont gagnés la partie car tout les loups garous sont mort ! \n\n\n§rRetour au lobby dans 30 secondes...");
|
||||
}
|
||||
}
|
||||
$this->getServer()->getScheduler()->scheduleDelayedTask(new FinishLGTask($this), 600);
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,12 +196,67 @@ class LoupGarou extends Game {
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
$event->setCancelled();
|
||||
break;
|
||||
case "meurtrier":
|
||||
if($event->getDamager() instanceof Player) {
|
||||
if($this->getRole($event->getDamager()) == "Meurtrier") {
|
||||
$this->broadcastMessage($event->getEntity()->getName() . " a été éliminé et c'etait un " . $this->getRole($event->getEntity()));
|
||||
$this->eliminate($event->getEntity());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "maire":
|
||||
if(!in_array($event->getDamager(), $this->hasvoted)) {
|
||||
$this->hasvoted[] = $event->getDamager();
|
||||
if(isset($this->voted[$event->getEntity()->getName()])) {
|
||||
$this->voted[$event->getEntity()->getName()]++;
|
||||
} else {
|
||||
$this->voted[$event->getEntity()->getName()] = 1;
|
||||
}
|
||||
if(count($this->hasvoted) == count($this->getLevel()->getPlayers())) {
|
||||
$this->task->turn = 525;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "vote":
|
||||
$this->hasvoted = [];
|
||||
$this->voted = [];
|
||||
if(!in_array($event->getDamager(), $this->hasvoted)) {
|
||||
$this->hasvoted[] = $event->getDamager();
|
||||
$votec = 1;
|
||||
if($event->getDamager() == $this->maire) {
|
||||
$votec = 1.5;
|
||||
}
|
||||
if(isset($this->voted[$event->getEntity()->getName()])) {
|
||||
$this->voted[$event->getEntity()->getName()] += $votec;
|
||||
} else {
|
||||
$this->voted[$event->getEntity()->getName()] = $votec;
|
||||
}
|
||||
if(count($this->hasvoted) == count($this->getLevel()->getPlayers())) {
|
||||
$this->task->turn = 590;
|
||||
}
|
||||
}
|
||||
$event->setCancelled();
|
||||
break;
|
||||
case "kill":
|
||||
if($this->mort !== $event->getDamager() or $this->mort !== $event->getEntity()) {
|
||||
$event->setCancelled();
|
||||
}
|
||||
break;
|
||||
case "successeur":
|
||||
if($event->getDamager() == $this->maire) {
|
||||
$this->maire = $event->getEntity();
|
||||
$this->broadcastMessage("Le nouveau maire est " . $event->getEntity()->getName() . " !");
|
||||
$this->eliminate($event->getDamager());
|
||||
$this->task->turn = 465;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$event->setCancelled();
|
||||
break;
|
||||
|
@ -182,6 +267,25 @@ class LoupGarou extends Game {
|
|||
|
||||
|
||||
public function eliminate(Player $player) {
|
||||
if($this->current == "kill") {
|
||||
$this->task->turn = 650;
|
||||
}
|
||||
if($player == $this->amoureux[0] and !isset($this->killedAm)) {
|
||||
$this->broadcastMessage("Mais " . $this->amoureux[1]->getName() . " était amoureux de " . $this->amoureux[0]->getName() . " et se suicida par chagrin d'amour...");
|
||||
$this->killedAm = true;
|
||||
$this->eliminate($this->amoureux[1]);
|
||||
}
|
||||
if($player == $this->amoureux[1] and !isset($this->killedAm)) {
|
||||
$this->broadcastMessage("Mais " . $this->amoureux[0]->getName() . " était amoureux de " . $this->amoureux[1]->getName() . " et se suicida par chagrin d'amour...");
|
||||
$this->killedAm = true;
|
||||
$this->eliminate($this->amoureux[0]);
|
||||
}
|
||||
if($this->maire == $player) {
|
||||
$this->oldMaire = $player;
|
||||
$this->current = "successeur";
|
||||
$this-broadcastMessage("Le maire est mort ! Il va désigner son successeur !");
|
||||
return true;
|
||||
}
|
||||
$player->setGamemode(3);
|
||||
switch($this->getRole($player)) {
|
||||
case "LoupGarou":
|
||||
|
@ -203,6 +307,21 @@ class LoupGarou extends Game {
|
|||
unset($this->{$this->getRole($player)});
|
||||
break;
|
||||
}
|
||||
$lg = [];
|
||||
$v = [];
|
||||
foreach($this->getLevel()->getPlayers() as $p) {
|
||||
if($this->getRole($player) == "LoupGarou") {
|
||||
array_push($lg, $player);
|
||||
} else {
|
||||
array_push($v, $player);
|
||||
}
|
||||
}
|
||||
if(count($v) == 0) { // Les loups garous ont gagnés
|
||||
$this->finish(true);
|
||||
}
|
||||
if(count($lg) == 0) { // Les villageois ont gagné
|
||||
$this->finish(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -243,11 +362,12 @@ class LoupGarou extends Game {
|
|||
public function onInteract(\pocketmine\event\player\PlayerInteractEvent $event) {
|
||||
if($event->getPlayer()->getInventory()->getItemInHand()->getId() == 373) {
|
||||
if($event->getPlayer()->getInventory()->getItemInHand()->getDamage() == 21) {
|
||||
$this->killed = null;
|
||||
$this->task->turn = 390;
|
||||
foreach($this->getLevel()->getPlayers() as $p) {
|
||||
$p->showPlayer($this->killed);
|
||||
}
|
||||
$this->killed = null;
|
||||
$this->potions["life"] = false;
|
||||
}
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
@ -271,7 +391,23 @@ class LoupGarou extends Game {
|
|||
}
|
||||
|
||||
|
||||
class StartTask extends \pocketmine\scheduler\PluginTask {
|
||||
class FinishLGTask extends \pocketmine\scheduler\PluginTask {
|
||||
|
||||
public function __construct(LoupGarou $main) {
|
||||
parent::__construct($main->getPlugin());
|
||||
$this->main = $main;
|
||||
}
|
||||
|
||||
|
||||
public function onRun($tick) {
|
||||
$this->main->stop();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class StartLGTask extends \pocketmine\scheduler\PluginTask {
|
||||
|
||||
public function __construct(LoupGarou $main) {
|
||||
parent::__construct($main->getPlugin());
|
||||
|
@ -308,7 +444,7 @@ class StartTask extends \pocketmine\scheduler\PluginTask {
|
|||
}
|
||||
}
|
||||
|
||||
class DayTask extends \pocketmine\scheduler\PluginTask {
|
||||
class FirstDayTask extends \pocketmine\scheduler\PluginTask {
|
||||
|
||||
public function __construct(LoupGarou $main) {
|
||||
parent::__construct($main->getPlugin());
|
||||
|
@ -420,7 +556,7 @@ class DayTask extends \pocketmine\scheduler\PluginTask {
|
|||
case 330:
|
||||
$this->main->broadcastMessage("La sorcière se réveille !");
|
||||
$this->main->Sorcière->removeEffectByName("BLINDNESS");
|
||||
$this->main->Sorcière->sendMessage($this->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.");
|
||||
$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"]) {
|
||||
$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}")));
|
||||
}
|
||||
|
@ -446,16 +582,16 @@ class DayTask extends \pocketmine\scheduler\PluginTask {
|
|||
break;
|
||||
case 400:
|
||||
$this->main->getLevel()->setTime(0);
|
||||
if(isset($this->killed) and isset($this->killed2)) {
|
||||
$this->main->broadcastMessage("Cette nuit, 2 personnes sont morte. Le " . $this->getRole($this->killed) . " et le " . $this->getRole($this->killed2) . " !");
|
||||
switch($this->getRole($this->killed)) {
|
||||
if(isset($this->main->killed) and isset($this->main->killed2)) {
|
||||
$this->main->broadcastMessage("Cette nuit, 2 personnes sont morte. Le " . $this->getRole($this->main->killed) . " et le " . $this->getRole($this->main->killed2) . " !");
|
||||
switch($this->getRole($this->main->killed)) {
|
||||
case "Meutrier":
|
||||
$this->main->broadcastMessage("Mais le meutrier, dans sa chute, a tué une autre personne.");
|
||||
$this->main->Meurtier->sendMessage("Choisissez une persone à tuer en la tapant.");
|
||||
$m = true;
|
||||
break;
|
||||
}
|
||||
switch($this->getRole($this->killed2)) {
|
||||
switch($this->getRole($this->main->killed2)) {
|
||||
case "Meutrier":
|
||||
$this->main->broadcastMessage("Mais le meutrier, dans sa chute, a tué une autre personne.");
|
||||
$this->main->Meurtier->sendMessage("Choisissez une persone à tuer en la tapant.");
|
||||
|
@ -463,9 +599,9 @@ class DayTask extends \pocketmine\scheduler\PluginTask {
|
|||
break;
|
||||
if(!isset($m)) $this->turn = 465; else $this->main->current = "meutrier";
|
||||
}
|
||||
} elseif(isset($this->killed)) {
|
||||
$this->main->broadcastMessage("Cette nuit, 1 personne est morte. Le " . $this->getRole($this->killed) . " !");
|
||||
switch($this->getRole($this->killed)) {
|
||||
} elseif(isset($this->main->killed)) {
|
||||
$this->main->broadcastMessage("Cette nuit, 1 personne est morte. Le " . $this->getRole($this->main->killed) . " !");
|
||||
switch($this->getRole($this->main->killed)) {
|
||||
case "Meutrier":
|
||||
$this->main->broadcastMessage("Mais le meutrier, dans sa chute, a tué une autre personne.");
|
||||
$this->main->Meurtier->sendMessage("Choisissez une persone à tuer en la tapant.");
|
||||
|
@ -475,9 +611,9 @@ class DayTask extends \pocketmine\scheduler\PluginTask {
|
|||
$this->turn = 465;
|
||||
break;
|
||||
}
|
||||
} elseif(isset($this->killed2)) {
|
||||
$this->main->broadcastMessage("Cette nuit, 1 personne est morte. Le " . $this->getRole($this->killed2) . " !");
|
||||
switch($this->getRole($this->killed)) {
|
||||
} elseif(isset($this->main->killed2)) {
|
||||
$this->main->broadcastMessage("Cette nuit, 1 personne est morte. Le " . $this->getRole($this->main->killed2) . " !");
|
||||
switch($this->getRole($this->main->killed2)) {
|
||||
case "Meutrier":
|
||||
$this->main->broadcastMessage("Mais le meutrier, dans sa chute, a tué une autre personne.");
|
||||
$this->main->Meurtier->sendMessage("Choisissez une persone à tuer en la tapant.");
|
||||
|
@ -492,7 +628,273 @@ class DayTask extends \pocketmine\scheduler\PluginTask {
|
|||
}
|
||||
break;
|
||||
case 465:
|
||||
$this->main->broadcastMessage("Il va faloir élire un maire !");
|
||||
$this->main->broadcastMessage("Il va faloir élire un maire ! Votez pour qu'un joueur soit maire en lui tapant dessus. Le maire tranche si il y a un debat au moment de tuer un suspect (chaque jour)");
|
||||
$this->main->current = "maire";
|
||||
break;
|
||||
case 525:
|
||||
$uppestVote = 0;
|
||||
foreach($this->main->voted as $running) {
|
||||
if($running > $uppestVote) {
|
||||
$uppestVote = $running;
|
||||
}
|
||||
}
|
||||
$runnings = [];
|
||||
foreach($this->main->voted as $name => $running) {
|
||||
if($running == $uppestVote) {
|
||||
$runnings[] = $name;
|
||||
}
|
||||
}
|
||||
if(count($runnings) > 1) {
|
||||
$last = $runnings[count($runnings) - 1];
|
||||
unset($runnings[count($runnings) - 1]);
|
||||
$this->main->broadcastMessage(implode(", " . $runnings . " et $last ont le même resultat ! Le maire sera séléctionné parmis ceux ci aux hasard."));
|
||||
$this->main->maire = $this->main->getServer()->getPlayer($runnings(rand(0, count($runnings))));
|
||||
$this->main->broadcastMessage("Le nouveau maire est : {$this->main->maire->getName()} !");
|
||||
}
|
||||
break;
|
||||
case 530:
|
||||
$this->main->broadcastMessage("Maintenant, nous devons choisir un personne qui doit mourir. Tapez la personne que vous trouvez la plus suspecte !");
|
||||
$this->main->current = "vote";
|
||||
break;
|
||||
case 590:
|
||||
$uppestVote = 0;
|
||||
foreach($this->main->voted as $running) {
|
||||
if($running > $uppestVote) {
|
||||
$uppestVote = $running;
|
||||
}
|
||||
}
|
||||
$runnings = [];
|
||||
foreach($this->main->voted as $name => $running) {
|
||||
if($running == $uppestVote) {
|
||||
$runnings[] = $name;
|
||||
}
|
||||
}
|
||||
if(count($runnings) > 1) {
|
||||
$last = $runnings[count($runnings) - 1];
|
||||
unset($runnings[count($runnings) - 1]);
|
||||
$this->main->broadcastMessage(implode(", " . $runnings) . " et $last ont le même resultat ! Vous pourez tuer celui qui sera tiré au hasard sur ceux ci.");
|
||||
$this->main->mort = $this->main->getServer()->getPlayer($runnings(rand(0, count($runnings))));
|
||||
$this->main->broadcastMessage("La personne mise à mort est {$this->main->mort->getName()} ! Tuez la !");
|
||||
foreach($this->main->getLevel()->getPlayers() as $p) {
|
||||
$p->addItem(Item::get(Item::IRON_SWORD)->setCompoundTag(\pocketmine\nbt\NBT::parseJSON("{Unbreakable:1}")));
|
||||
}
|
||||
$this->main->mort->sendMessage("Ils veulent votre mort ! Fuyez ou tuez vos enemies !");
|
||||
$this->main->current = "kill";
|
||||
}
|
||||
break;
|
||||
case 650:
|
||||
foreach($this->main->getLevel()->getPlayers() as $p) {
|
||||
$p->getInventory()->clearAll();
|
||||
}
|
||||
$this->main->task = new DayTask($this->main);
|
||||
$h = $this->main->getServer()->getScheduler()->scheduleRepeatingTask($this->main->task, 20);
|
||||
$this->main->task->setHandler($h);
|
||||
$this->main->getServer()->getScheduler()->cancelTask($this->getTaskId());
|
||||
break;
|
||||
}
|
||||
$this->turn++;
|
||||
}
|
||||
}
|
||||
|
||||
class DayTask extends \pocketmine\scheduler\PluginTask {
|
||||
|
||||
public function __construct(LoupGarou $main) {
|
||||
parent::__construct($main->getPlugin());
|
||||
$this->turn = 0;
|
||||
$this->main = $main;
|
||||
}
|
||||
|
||||
|
||||
public function onRun($tick) {
|
||||
switch($this->turn) {
|
||||
case 1:
|
||||
$this->main->broadcastMessage("Après une longe journée de travail dure, les villageois partent dormir...");
|
||||
break;
|
||||
case 5:
|
||||
$this->main->broadcastMessage("La nuit tombe sur le petit village de Thiercelieux...");
|
||||
$this->main->getLevel()->setTime(9000);
|
||||
break;
|
||||
case 7:
|
||||
$this->main->getLevel()->setTime(14000);
|
||||
$this->main->broadcastMessage("Tout les villageois s'endorment...");
|
||||
$e = \pocketmine\entity\Effect::getEffectByName("BLINDNESS");
|
||||
$e->setDuration(9999999);
|
||||
$e->setAmbient();
|
||||
$e->setVisible(false);
|
||||
$e->setAmplifier(3);
|
||||
foreach($this->getInGamePlayers() as $p) {
|
||||
$p->addEffect($e);
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
$this->turn = 140; // Skip parts of the night so I do not have to rewrite the entitydamage to be 2 times different.
|
||||
break;
|
||||
case 140:
|
||||
if(isset($this->main->Voyante)) {
|
||||
$this->main->broadcastMessage("La voyante se réveille !");
|
||||
$this->main->Voyante->removeEffectByName("BLINDNESS");
|
||||
$this->main->current = "voyante";
|
||||
$this->main->Voyante->sendMessage("Touchez le joueur dont vous voulez rendre villageois connaitre l'identité. Vous avez une minute donc decidez vous vite !");
|
||||
} else {
|
||||
$this->turn = 205;
|
||||
}
|
||||
break;
|
||||
case 200:
|
||||
$e = \pocketmine\entity\Effect::getEffectByName("BLINDNESS");
|
||||
$e->setDuration(9999999);
|
||||
$e->setAmbient();
|
||||
$e->setVisible(false);
|
||||
$e->setAmplifier(3);
|
||||
foreach($this->main->getInGamePlayers() as $p) {
|
||||
$p->addEffect($e);
|
||||
}
|
||||
$this->main->broadcastMessage("La voyante se rendort...");
|
||||
break;
|
||||
case 205:
|
||||
$this->main->broadcastMessage("Les loups garous se réveillent !");
|
||||
foreach($this->main->LoupGarou as $lg) {
|
||||
$lg->removeEffectByName("BLINDNESS");
|
||||
$lg->sendMessage("Tuez un joueur pour le tuer dans le jeu !");
|
||||
$lg->getInventory()->addItem(Item::get(Item::DIAMOND_SWORD, 0, 1)->setCompoundTag(\pocketmine\nbt\NBT::parseJSON("{display:{Name:'Dent de loup garou'},Unbreakable:1}")));
|
||||
}
|
||||
$this->main->Courageuse->removeEffectByName("BLINDNESS");
|
||||
$this->main->Courageuse->sendMessage("Les loups garous vont faire une nouvelle victime ! Soyez discret(e), espionnez les et tapez les pour les ralentir !");
|
||||
$this->main->current = "lg";
|
||||
break;
|
||||
case 325:
|
||||
$e = \pocketmine\entity\Effect::getEffectByName("BLINDNESS");
|
||||
$e->setDuration(9999999);
|
||||
$e->setAmbient();
|
||||
$e->setVisible(false);
|
||||
$e->setAmplifier(3);
|
||||
foreach($this->main->LoupGarou as $lg) {
|
||||
$lg->getInventory()->clearAll();
|
||||
}
|
||||
foreach($this->main->getInGamePlayers() as $p) {
|
||||
$p->addEffect($e);
|
||||
}
|
||||
$this->main->broadcastMessage("Les loups garou se rendorment...");
|
||||
break;
|
||||
case 330:
|
||||
if(isset($this->main->Sorcière)) {
|
||||
$this->main->broadcastMessage("La sorcière se réveille !");
|
||||
$this->main->Sorcière->removeEffectByName("BLINDNESS");
|
||||
$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"]) {
|
||||
$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"]) {
|
||||
$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}")));
|
||||
}
|
||||
$this->main->current = "sorcière";
|
||||
} else {
|
||||
$this->turn = 395;
|
||||
}
|
||||
break;
|
||||
case 390:
|
||||
$e = \pocketmine\entity\Effect::getEffectByName("BLINDNESS");
|
||||
$e->setDuration(9999999);
|
||||
$e->setAmbient();
|
||||
$e->setVisible(false);
|
||||
$e->setAmplifier(3);
|
||||
foreach($this->main->getInGamePlayers() as $p) {
|
||||
$p->addEffect($e);
|
||||
}
|
||||
$this->main->broadcastMessage("La sorcière se rendort...");
|
||||
break;
|
||||
case 395:
|
||||
$this->main->broadcastMessage("Le village se reveille...");
|
||||
$this->main->getLevel()->setTime(23000);
|
||||
break;
|
||||
case 400:
|
||||
$this->main->getLevel()->setTime(0);
|
||||
if(isset($this->main->killed) and isset($this->main->killed2)) {
|
||||
$this->main->broadcastMessage("Cette nuit, 2 personnes sont morte. Le " . $this->getRole($this->main->killed) . " et le " . $this->getRole($this->main->killed2) . " !");
|
||||
if($this->getRole($this->main->killed2) == "Meurtrier") {
|
||||
$this->main->broadcastMessage("Mais le meutrier, dans sa chute, a tué une autre personne.");
|
||||
$this->main->Meurtier->sendMessage("Choisissez une persone à tuer en la tapant.");
|
||||
$this->main->current = "meurtrier";
|
||||
} else {
|
||||
$this->main->eliminate($this->main->killed2);
|
||||
$this->turn = 465;
|
||||
}
|
||||
if($this->getRole($this->main->killed) == "Meurtrier") {
|
||||
$this->main->broadcastMessage("Mais le meutrier, dans sa chute, a tué une autre personne.");
|
||||
$this->main->Meurtier->sendMessage("Choisissez une persone à tuer en la tapant.");
|
||||
$this->main->current = "meurtrier";
|
||||
} else {
|
||||
$this->main->eliminate($this->main->killed);
|
||||
$this->turn = 465;
|
||||
}
|
||||
if(!isset($m)) $this->turn = 465; else $this->main->current = "meutrier";
|
||||
} elseif(isset($this->main->killed)) {
|
||||
$this->main->broadcastMessage("Cette nuit, 1 personne est morte. Le " . $this->getRole($this->main->killed) . " !");
|
||||
if($this->getRole($this->main->killed) == "Meurtrier") {
|
||||
$this->main->broadcastMessage("Mais le meutrier, dans sa chute, a tué une autre personne.");
|
||||
$this->main->Meurtier->sendMessage("Choisissez une persone à tuer en la tapant.");
|
||||
$this->main->current = "meurtrier";
|
||||
} else {
|
||||
$this->main->eliminate($this->main->killed);
|
||||
$this->turn = 465;
|
||||
}
|
||||
} elseif(isset($this->main->killed2)) {
|
||||
$this->main->broadcastMessage("Cette nuit, 1 personne est morte. Le " . $this->getRole($this->main->killed2) . " !");
|
||||
if($this->getRole($this->main->killed2) == "Meurtrier") {
|
||||
$this->main->broadcastMessage("Mais le meutrier, dans sa chute, a tué une autre personne.");
|
||||
$this->main->Meurtier->sendMessage("Choisissez une persone à tuer en la tapant.");
|
||||
$this->main->current = "meurtrier";
|
||||
} else {
|
||||
$this->main->eliminate($this->main->killed2);
|
||||
$this->turn = 465;
|
||||
}
|
||||
} else {
|
||||
$this->main->broadcastMessage("Cette nuit, Personne n'est mort ! C'est un miracle !");
|
||||
}
|
||||
break;
|
||||
case 465:
|
||||
if(isset($this->main->oldMaire)){
|
||||
if($this->main->oldMaire == $this->main->maire) {
|
||||
$this->main->maire = $this->main->getLevel()->getPlayers(rand(0, count($this->getLevel()->getPlayers())));
|
||||
$this->main->broadcastMessage("Le nouveau maire est " . $this->main->maire->getName() . " !");
|
||||
}
|
||||
}
|
||||
$this->turn = 530; // Also to not have to rechoose the mayor one more time.
|
||||
break;
|
||||
case 530:
|
||||
$this->main->broadcastMessage("Maintenant, nous devons choisir un personne qui doit mourir. Tapez la personne que vous trouvez la plus suspecte !");
|
||||
$this->main->current = "vote";
|
||||
break;
|
||||
case 590:
|
||||
$uppestVote = 0;
|
||||
foreach($this->main->voted as $running) {
|
||||
if($running > $uppestVote) {
|
||||
$uppestVote = $running;
|
||||
}
|
||||
}
|
||||
$runnings = [];
|
||||
foreach($this->main->voted as $name => $running) {
|
||||
if($running == $uppestVote) {
|
||||
$runnings[] = $name;
|
||||
}
|
||||
}
|
||||
if(count($runnings) > 1) {
|
||||
$last = $runnings[count($runnings) - 1];
|
||||
unset($runnings[count($runnings) - 1]);
|
||||
$this->main->broadcastMessage(implode(", " . $runnings) . " et $last ont le même resultat ! Vous pourez tuer celui qui sera tiré au hasard sur ceux ci.");
|
||||
$this->main->mort = $this->main->getServer()->getPlayer($runnings(rand(0, count($runnings))));
|
||||
$this->main->broadcastMessage("La personne mise à mort est {$this->main->mort->getName()} ! Tuez la !");
|
||||
foreach($this->main->getLevel()->getPlayers() as $p) {
|
||||
$p->addItem(Item::get(Item::IRON_SWORD)->setCompoundTag(\pocketmine\nbt\NBT::parseJSON("{Unbreakable:1}")));
|
||||
}
|
||||
$this->main->mort->sendMessage("Ils veulent votre mort ! Fuyez ou tuez vos enemies !");
|
||||
$this->main->current = "kill";
|
||||
}
|
||||
break;
|
||||
case 650:
|
||||
foreach($this->main->getLevel()->getPlayers() as $p) {
|
||||
$p->getInventory()->clearAll();
|
||||
}
|
||||
$this->turn = 0;
|
||||
break;
|
||||
}
|
||||
$this->turn++;
|
||||
|
|
|
@ -147,7 +147,7 @@ abstract class Game {
|
|||
public function onEntityDamage(\pocketmine\event\entity\EntityDamageEvent $event) {}
|
||||
|
||||
|
||||
public function onProjectileLauch(\pocketmine\event\entity\ProjectileLauchEvent $event) {}
|
||||
public function onProjectileLaunch(\pocketmine\event\entity\ProjectileLauchEvent $event) {}
|
||||
|
||||
|
||||
public function onProjectileHit(\pocketmine\event\entity\ProjectileHitEvent $event) {}
|
||||
|
|
|
@ -63,10 +63,10 @@ class GameManager {
|
|||
if(isset($this->games[$game])) {
|
||||
$this->levels[$level->getName()] = new $this->games[$game]($game, $level);
|
||||
} else {
|
||||
$this->main->getLogger()->warn("No game found with name $game");
|
||||
$this->main->getLogger()->warning("No game found with name $game");
|
||||
}
|
||||
} else {
|
||||
$this->main->getLogger()->warn("{$level->getName()} is already registered.");
|
||||
$this->main->getLogger()->warning("{$level->getName()} is already registered.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -284,9 +284,9 @@ public function onInteract(PlayerInteractEvent $event) {
|
|||
}
|
||||
|
||||
|
||||
public function onProjectileLauch(\pocketmine\event\entity\ProjectileLauchEvent $event) {
|
||||
public function onProjectileLaunch(\pocketmine\event\entity\ProjectileLaunchEvent $event) {
|
||||
if(isset($this->manager->getLevels()[$event->getEntity()->getLevel()->getName()])) {
|
||||
$this->manager->getLevels()[$event->getEntity()->getLevel()->getName()]->onProjectileLauch($event);
|
||||
$this->manager->getLevels()[$event->getEntity()->getLevel()->getName()]->onProjectileLaunch($event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue