Skip to content

Commit

Permalink
style: format code with PHP CS Fixer
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in c96f5a0 according to the output
from PHP CS Fixer.

Details: #1563
  • Loading branch information
deepsource-autofix[bot] authored Oct 7, 2023
1 parent c96f5a0 commit 151fd62
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions deploy/lib/control/NpcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NpcController extends AbstractController
/**
* Inject different seed when non-randomness is needed (for testing)
*/
public function __construct($options=[])
public function __construct($options = [])
{
if (isset($options['randomness']) && is_callable($options['randomness'])) {
$this->randomness = $options['randomness'];
Expand Down Expand Up @@ -77,7 +77,7 @@ private function randomEncounter(Player $player)
$item = Item::findByIdentity('dimmak');
$quantity = 1;
$inventory->add($item->identity(), $quantity);
} elseif ($player->turns > floor(self::HIGH_TURNS/2) && rand()&1) {
} elseif ($player->turns > floor(self::HIGH_TURNS / 2) && rand() & 1) {
// If your turns are somewhat high/you have some energy, 50/50 chance you can kill them.
$oni_killed = true;
$item = Item::findByIdentity('ginsengroot');
Expand Down Expand Up @@ -144,7 +144,7 @@ private function calcReceivedGold(Npc $npco, $reward_item)
$divisor = self::ITEM_DECREASES_GOLD_DIVISOR;
}

return rand($npco->minGold(), floor($npco->gold()/$divisor));
return rand($npco->minGold(), floor($npco->gold() / $divisor));
}

/**
Expand Down Expand Up @@ -342,7 +342,7 @@ public function attack(Container $p_dependencies)
// Check the counter to see whether they've attacked a thief multiple times in a row.
$counter = $this->getThiefCounter($p_dependencies);

$this->setThiefCounter($counter+1, $p_dependencies); // Incremement the current state of the counter.
$this->setThiefCounter($counter + 1, $p_dependencies); // Incremement the current state of the counter.

if ($counter > 20 && rand(1, 3) == 3) {
// Only after many attacks do you have the chance to be attacked back by the group of thieves.
Expand Down
10 changes: 5 additions & 5 deletions deploy/lib/data/Npc.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public function shortDesc()
*
* @return int
*/
public function maxDamage(Character $enemy=null): int
public function maxDamage(Character $enemy = null): int
{
$dam = ((1+ ($this->strength * 2)) + $this->damage);
$dam = ((1 + ($this->strength * 2)) + $this->damage);
// Mirror some of their enemy's strength
if ($this->hasTrait('partial_match_strength') && $enemy instanceof Character) {
$add = max(0, floor($enemy->getStrength() / 3)); // Enemy str/3 or at minimum 0
Expand All @@ -100,7 +100,7 @@ public function damage(Character $char = null)
{
// Horned enemies do a little extra damage
return rand(0, $this->maxDamage($char))
+ ($this->hasTrait('horned') ? (int) max(0, floor($this->getStrength()/8)) : 0);
+ ($this->hasTrait('horned') ? (int) max(0, floor($this->getStrength() / 8)) : 0);
}

/**
Expand Down Expand Up @@ -221,7 +221,7 @@ public function inventory()
{
if (!isset($this->inventory) && isset($this->inventory_chances) && $this->inventory_chances) {
$inv = [];
foreach ($this->inventory_chances as $item=>$chance) {
foreach ($this->inventory_chances as $item => $chance) {
if ($this->inventory_present($chance)) { // Calculate success from a decimal/float.
// Add the item.
$inv[$item] = true;
Expand Down Expand Up @@ -283,7 +283,7 @@ public function gold()
*/
public function minGold()
{
return (int) ($this->hasTrait('rich') ? floor($this->gold()/self::RICH_MIN_GOLD_DIVISOR) : self::MIN_GOLD);
return (int) ($this->hasTrait('rich') ? floor($this->gold() / self::RICH_MIN_GOLD_DIVISOR) : self::MIN_GOLD);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions deploy/lib/data/NpcFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static function fleshOutFromData($data, $npc)
*
* @return Npc[]
*/
public static function npcs($sort=null)
public static function npcs($sort = null)
{
$npcs_data = self::npcsData();
$npcs = [];
Expand Down Expand Up @@ -176,11 +176,11 @@ public static function npcsData()
public static function customNpcs()
{
return [
['name'=>'Peasant', 'identity'=>'peasant', 'image'=>'fighter.png'],
['name'=>'Thief', 'identity'=>'thief', 'image'=>'thief.png'],
['name'=>'Merchant', 'identity'=>'merchant', 'image'=>'merchant.png'],
['name'=>'Guard', 'identity'=>'guard', 'image'=>'guard.png'],
['name'=>'Samurai', 'identity'=>'samurai', 'image'=>'samurai.png'],
['name' => 'Peasant', 'identity' => 'peasant', 'image' => 'fighter.png'],
['name' => 'Thief', 'identity' => 'thief', 'image' => 'thief.png'],
['name' => 'Merchant', 'identity' => 'merchant', 'image' => 'merchant.png'],
['name' => 'Guard', 'identity' => 'guard', 'image' => 'guard.png'],
['name' => 'Samurai', 'identity' => 'samurai', 'image' => 'samurai.png'],
];
}
}

0 comments on commit 151fd62

Please sign in to comment.