X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=application%2Fship-simu%2Fmain%2Fuser%2Fclass_ShipSimuBaseUser.php;h=61feb281fb6c692228661361bf7414db6f56a4a6;hp=911e91eab370a57f27f497bda8da9854042339af;hb=4c853fd49e21d5d3ae7a3c0c2822c788643375c7;hpb=e2846002167edccccb1240437f40ee057075d0d9 diff --git a/application/ship-simu/main/user/class_ShipSimuBaseUser.php b/application/ship-simu/main/user/class_ShipSimuBaseUser.php index 911e91e..61feb28 100644 --- a/application/ship-simu/main/user/class_ShipSimuBaseUser.php +++ b/application/ship-simu/main/user/class_ShipSimuBaseUser.php @@ -42,14 +42,14 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { // Get max allowed companies to found $maxFound = $this->getConfigInstance()->readConfig('max_allowed_companies_found'); - // Get a company wrapper - $wrapperInstance = ObjectFactory::createObjectByConfiguredName('company_db_wrapper_class'); - // Now get a search criteria and set the user's name as criteria $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); $criteriaInstance->setLimit($maxFound); + // Get a company wrapper + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('company_db_wrapper_class'); + // Do the count-select by criteria $totalRows = $wrapperInstance->doSelectCountByCriteria($criteriaInstance); @@ -83,20 +83,51 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { } // END - if // Just forward this request to the user points class - $hasRequired = $pointsInstance->ifUserHasRequiredPoints ($action); + $hasRequired = $pointsInstance->ifUserHasRequiredPoints($action); // Return the result return $hasRequired; } + /** + * Determines if the goverment can still pay a "virtual training course" in general + * + * @return $ifGovHelps Wether if the goverment helps the user with a virtual training course + */ + public function ifGovermentPaysTraining () { + // By default they want to help. + $ifGovHelps = true; + + // First get a goverment instance from registry + $govermentInstance = Registry::getRegistry()->getInstance('goverment'); + + // Is it there? + if (is_null($govermentInstance)) { + // Then create a new one + $govermentInstance = ObjectFactory::createObjectByConfiguredName('goverment_class', array($this)); + + // Store it in registry + Registry::getRegistry()->addInstance('goverment', $govermentInstance); + } // END - if + + // Then ask the goverment if they want to pay a "startup help" to the user + if ($govermentInstance->ifGovermentAlreadyPayedTraining()) { + // Training already given! + $ifGovHelps = false; + } // END - if + + // Return result here + return $ifGovHelps; + } + /** * Determines if the goverment can still pay a "startup help" to the user * - * @return $ifGovHelped Wether if the goverment has helped the user with startup + * @return $ifGovHelps Wether if the goverment helps the user with some startup money */ public function ifGovermentPaysStartupHelp () { - // By default they have not payed, which is indeed good. ;-) - $ifGovHelped = false; + // By default they want to help. + $ifGovHelps = true; // First get a goverment instance from registry $govermentInstance = Registry::getRegistry()->getInstance('goverment'); @@ -111,21 +142,22 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { } // END - if // Then ask the goverment if they want to pay a "startup help" to the user - if ($govermentInstance->ifGovermentAlreadyPayedStartupHelp()) { + if ($govermentInstance->ifGovermentPayedMaxmimumStartupHelp()) { // They can't pay anymore to the user (excited amount) - $ifGovHelped = true; + $ifGovHelps = false; } // END - if // Return result here - return $ifGovHelped; + return $ifGovHelps; } /** * Checks wether the user can take points from the money bank * * @return $bankLends Wether the money bank is able to lend money + * @todo Need to implement MoneyBank::ifBankLendsMoreMoney() */ - public function ifUserAllowTakeCreditsFromMoneyBank () { + public function ifUserAllowedTakeCreditsFromMoneyBank () { // Per default the money bank cannot pay $bankLends = false; @@ -142,10 +174,12 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { } // END - if // Does the money bank lend more money? + /* UNFINISED: if ($bankInstance->ifBankLendsMoreMoney()) { // Okay, that they will do $bankLends = true; } // END - if + */ // Return result return $bankLends; @@ -157,6 +191,7 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { * credits from the bank. * * @return $hasMaxCredits Wether the user has maximum credits with the bank + * @todo Need to check the bank if they can lend more money */ public function ifUserHasMaximumCreditsWithMoneyBank () { // For default he can still get money @@ -175,10 +210,12 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { } // END - if // Now check if the user has maximum credits + /** UNFINISHED PART! if ($bankInstance->ifUserHasMaxCredits()) { // Yes, he does! $hasMaxCredits = true; } // END - if + */ // Return the result return $hasMaxCredits;