BetterGen/src/Ad5001/BetterGen/populator/AmountPopulator.php

72 lines
1.8 KiB
PHP
Raw Normal View History

2017-04-23 14:42:51 +00:00
<?php
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
2017-05-14 18:13:15 +00:00
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
* @link https://github.com/Ad5001/BetterGen
2017-05-14 18:13:15 +00:00
* @version 1.1
2017-04-23 14:42:51 +00:00
*/
namespace Ad5001\BetterGen\populator;
use pocketmine\level\generator\populator\Populator;
2017-05-11 12:07:26 +00:00
use pocketmine\utils\Random;
2017-04-23 14:42:51 +00:00
abstract class AmountPopulator extends Populator {
protected $baseAmount = 0;
protected $randomAmount = 0;
2017-05-14 19:03:47 +00:00
/**
2017-04-23 14:42:51 +00:00
* Crosssoftware class for random amount
*/
2017-05-14 19:03:47 +00:00
/**
2017-04-23 14:42:51 +00:00
* Sets the random addition amount
* @param $amount int
*/
public function setRandomAmount(int $amount) {
$this->randomAmount = $amount;
}
2017-05-14 19:03:47 +00:00
/**
2017-04-23 14:42:51 +00:00
* Sets the base addition amount
* @param $amount int
*/
public function setBaseAmount(int $amount) {
$this->baseAmount = $amount;
}
2017-05-14 19:03:47 +00:00
/**
2017-04-23 14:42:51 +00:00
* Returns the amount based on random
2017-05-14 19:03:47 +00:00
*
* @param Random $random
* @return int
2017-04-23 14:42:51 +00:00
*/
public function getAmount(Random $random) {
2017-04-29 09:59:44 +00:00
return $this->baseAmount + $random->nextRange(0, $this->randomAmount + 1);
2017-04-23 14:42:51 +00:00
}
2017-05-14 19:03:47 +00:00
/**
* Returns base amount
*
2017-04-23 14:42:51 +00:00
* @return int
*/
public function getBaseAmount(): int {
return $this->baseAmount;
}
2017-05-14 19:03:47 +00:00
/**
2017-04-23 14:42:51 +00:00
* Returns the random additional amount
2017-05-14 19:03:47 +00:00
*
2017-04-23 14:42:51 +00:00
* @return int
*/
public function getRandomAmount(): int {
return $this->randomAmount;
}
}