コード例 #1
0
 protected function run(array $args, Session $sender)
 {
     $lbl = func_get_arg(2);
     if (is_string($lbl) and $lbl !== "cg") {
         $sender->send(Phrases::CMD_GRIND_COIN_ADVICE);
     }
     if (!$sender->canStartGrind()) {
         return $sender->translate(Phrases::CMD_GRIND_COIN_CANNOT_START, ["time" => MUtils::time_secsToString($sender->getGrindWaitTime())]);
     }
     if (!$sender->confirmGrind) {
         $sender->confirmGrind = true;
         return $sender->translate(Phrases::CMD_GRIND_COIN_REQUEST_CONFIRM, ["length" => MUtils::time_secsToString(Settings::getGrindLength($sender->getRank())), "amplitude" => Settings::getGrindFactor($sender->getRank())]);
     }
     $sender->confirmGrind = false;
     $sender->startGrinding();
     return $sender->translate(Phrases::CMD_GRIND_COIN_STARTED);
 }
コード例 #2
0
 public function grantCoins($coins, $ignoreGrind = false, $effects = true)
 {
     if (!$ignoreGrind and $this->isGrinding()) {
         $coins *= Settings::getGrindFactor($this->getRank());
     }
     if ($effects) {
         $this->getPlayer()->getLevel()->addSound(new FizzSound($this->getPlayer()), [$this->getPlayer()]);
         $random = new Random(time() + $coins);
         $player = $this->getPlayer();
         $particle = new TerrainParticle($player, Block::get(Block::GOLD_BLOCK));
         $level = $player->getLevel();
         $recipients = [$player];
         for ($i = 0; $i < 50; $i++) {
             $x = $random->nextSignedFloat();
             $y = $random->nextSignedFloat() * $player->eyeHeight / 2;
             $z = $random->nextSignedFloat();
             $particle->setComponents($player->x + $x, $player->y + $player->eyeHeight / 2 + $y, $player->z + $z);
             $level->addParticle($particle, $recipients);
         }
     }
     $this->setCoins($out = $this->getCoins() + $coins);
     return [$coins, $out];
 }
コード例 #3
0
 public function grantCoins($coins, $ignoreGrind = false, $effects = true, $bonus = true)
 {
     if (!$ignoreGrind and $this->isGrinding()) {
         $coins *= Settings::getGrindFactor($this->getRank());
     }
     if ($effects) {
         $this->getPlayer()->getLevel()->addSound(new FizzSound($this->getPlayer()), [$this->getPlayer()]);
         $random = new Random(time() + $coins);
         $player = $this->getPlayer();
         $particle = new TerrainParticle($player, Block::get(Block::GOLD_BLOCK));
         $level = $player->getLevel();
         $recipients = [$player];
         for ($i = 0; $i < 500; $i++) {
             $x = $random->nextSignedFloat();
             $y = $random->nextSignedFloat();
             $z = $random->nextSignedFloat();
             $particle->setComponents($player->x + $x, $player->y + $y, $player->z + $z);
             $level->addParticle($particle, $recipients);
         }
     }
     $this->setCoins($out = $this->getCoins() + $coins);
     if ($bonus) {
         if (mt_rand(0, 99) === 0) {
             $add = mt_rand(25, 50);
         } elseif (mt_rand(0, 499) === 0) {
             $add = mt_rand(150, 300);
         } elseif (mt_rand(0, 749) === 0) {
             $add = mt_rand(300, 500);
         }
         if (isset($add)) {
             $this->grantCoins($add, false, true, false);
         }
     }
     return [$coins, $out];
 }