Пример #1
0
 public function testAccountCanSaveNewOauthIdAfterHavingItAdded()
 {
     $account = AccountFactory::make($this->testAccountId);
     $oauth_id = 88888888888888;
     $account->setOauthId($oauth_id, 'facebook');
     AccountFactory::save($account);
     $account_dupe = AccountFactory::make($this->testAccountId);
     $this->assertEquals($oauth_id, $account_dupe->getOauthId());
 }
Пример #2
0
 /**
  * Leveling up Function
  *
  * @return boolean
  */
 public function levelUp()
 {
     $health_to_add = 100;
     $turns_to_give = 50;
     $ki_to_give = 50;
     $stat_value_to_add = 5;
     $karma_to_give = 1;
     if ($this->isAdmin()) {
         // If the character is an admin, do not auto-level
         return false;
     } else {
         // For normal characters, do auto-level
         // Have to be under the max level and have enough kills.
         $level_up_possible = $this->level + 1 <= MAX_PLAYER_LEVEL && $this->kills >= $this->killsRequiredForNextLevel();
         if ($level_up_possible) {
             // Perform the level up actions
             $this->set_health($this->health() + $health_to_add);
             $this->set_turns($this->turns() + $turns_to_give);
             $this->set_ki($this->ki() + $ki_to_give);
             // Must read from VO for these as accessors return modified values
             $this->setStamina($this->vo->stamina + $stat_value_to_add);
             $this->setStrength($this->vo->strength + $stat_value_to_add);
             $this->setSpeed($this->vo->speed + $stat_value_to_add);
             // no mutator for these yet
             $this->vo->kills = max(0, $this->kills - $this->killsRequiredForNextLevel());
             $this->vo->karma = $this->karma + $karma_to_give;
             $this->vo->level = $this->level + 1;
             $this->save();
             GameLog::recordLevelUp($this->id());
             $account = AccountFactory::findByChar($this);
             $account->setKarmaTotal($account->getKarmaTotal() + $karma_to_give);
             AccountFactory::save($account);
             // Send a level-up message, for those times when auto-levelling happens.
             send_event($this->id(), $this->id(), "You levelled up! Your strength raised by {$stat_value_to_add}, speed by {$stat_value_to_add}, stamina by {$stat_value_to_add}, Karma by {$karma_to_give}, and your Ki raised {$ki_to_give}! You gained some health and turns, as well! You are now a level {$this->level} ninja! Go kill some stuff.");
             return true;
         } else {
             return false;
         }
     }
 }