Ejemplo n.º 1
0
 public function AddAbilityItem($AbilityId, $Quantity = 1)
 {
     if (AbilityItem::GetType($AbilityId) !== Enums\EAbilityType::Item) {
         $Upgrade = $this->GetUpgradeByAbility($AbilityId);
         if ($Upgrade !== null && $Upgrade->GetLevel() === 0) {
             $Upgrade->IncreaseLevel();
         }
         $this->UnlockAbility($AbilityId);
         return;
     }
     if (!isset($this->AbilityItems[$AbilityId])) {
         $this->AbilityItems[$AbilityId] = ['ability' => $AbilityId, 'quantity' => 1];
     } else {
         $this->AbilityItems[$AbilityId]['quantity']++;
     }
 }
Ejemplo n.º 2
0
 public function UseAbility($Game, $Ability)
 {
     // If player doesn't have this ability, don't do anything
     if (!$this->GetTechTree()->HasAbilityItem($Ability)) {
         return false;
     } else {
         if ($this->HasActiveAbility($Ability) && !$this->GetActiveAbility($Ability)->IsCooledDown($Game->Time)) {
             return false;
         }
     }
     $Lane = $Game->GetLane($this->GetCurrentLane());
     $ActiveAbility = new ActiveAbility($Game->Time, $Ability, $this->PlayerName, $Lane->HasActivePlayerAbilityDecreaseCooldowns());
     if (AbilityItem::HandleAbility($Game, $Lane, $this, $ActiveAbility)) {
         // Ability executed succesfully!
         $this->AddActiveAbility($Ability, $ActiveAbility);
         $this->GetTechTree()->RemoveAbilityItem($Ability);
         $Game->NumAbilitiesActivated++;
         if (AbilityItem::GetType($Ability) === Enums\EAbilityType::Item) {
             $Game->NumAbilityItemsActivated++;
         }
         // Add wormhole in all three lanes
         if ($Ability === Enums\EAbility::Item_SkipLevels) {
             foreach ($Game->Lanes as $Lane) {
                 $Lane->AddActivePlayerAbility($ActiveAbility);
             }
         } else {
             if ($Ability !== Enums\EAbility::Item_IncreaseCritPercentagePermanently && $Ability !== Enums\EAbility::Item_IncreaseHPPermanently && $Ability !== Enums\EAbility::Item_GiveGold) {
                 $Lane->AddActivePlayerAbility($ActiveAbility);
             }
         }
         return true;
     }
     unset($ActiveAbility);
     return false;
 }