コード例 #1
0
ファイル: Loan.php プロジェクト: MCPEGamerJPatGitHub/xEcon
 /**
  * @param Account $creditor
  * @param $amount
  * @param Entity $owner
  * @param $due
  * @param $increasePerHour
  * @param bool $name
  * @param bool $creation
  * @param bool $originalAmount
  * @param bool $lastInterestUpdate
  */
 public function __construct(Account $creditor, $amount, $owner, $due, $increasePerHour, $name = false, $creation = false, $originalAmount = false, $lastInterestUpdate = false)
 {
     // setting defaults
     if (!$creditor->getName() instanceof Service and !$creditor->getEntity() instanceof PlayerEnt) {
         throw new \InvalidArgumentException("Loan must be provided by a player or a service");
     }
     if ($creation === false) {
         $creation = time();
     }
     if (!is_string($name)) {
         $name = sprintf("Loan from {$creditor->getUniqueName()}");
     }
     $oname = $name;
     for ($i = 2; $owner->getAccount($name) instanceof Account; $i++) {
         $name = "{$oname} ({$i})";
     }
     if (!is_numeric($originalAmount)) {
         $originalAmount = $amount;
     }
     if (!is_int($lastInterestUpdate)) {
         $lastInterestUpdate = time();
     }
     // saving fields
     $this->name = strtolower($name);
     $this->creditor = $creditor;
     $this->amount = $amount;
     $this->owner = $owner;
     $this->due = $due;
     $this->increasePerHour = $increasePerHour;
     $this->creation = $creation;
     $this->originalAmount = $originalAmount;
     $this->lastInterestUpdate = $lastInterestUpdate;
 }
コード例 #2
0
 /**
  * @param \xecon\entity\Entity $entity
  * @return string
  */
 public function getPath($entity)
 {
     $path = str_replace(["<type>", "<name>"], [$entity->getAbsolutePrefix(), $entity->getName()], $this->path);
     @mkdir(dirname($path), 0777, true);
     return $path;
 }
コード例 #3
0
ファイル: XEcon.php プロジェクト: MCPEGamerJPatGitHub/xEcon
 /**
  * @param Entity $entity
  */
 public function addEntity($entity)
 {
     $this->ents[strtolower($entity->getUniqueName())] = new \WeakRef($entity);
 }
コード例 #4
0
ファイル: Account.php プロジェクト: MCPEGamerJPatGitHub/xEcon
 public function getUniqueName()
 {
     return implode("/", [$this->entity->getAbsolutePrefix(), $this->entity->getName(), $this->getName()]);
 }