Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Failed Conditions
Pull Request — master (#1062)
by Dan
04:48
created

DummyPlayer::increaseHOF()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 3
dl 0
loc 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
class DummyPlayer extends AbstractSmrPlayer {
4
5
	public function __construct(string $playerName, int $experience = 1000, int $shipTypeID = 60) {
6
		$this->playerName = $playerName;
7
		$this->experience = $experience;
8
		$this->shipID = $shipTypeID;
9
		$this->setConstantProperties();
10
	}
11
12
	/**
13
	 * Sets properties that are needed for combat, but do not need to
14
	 * be stored in the database.
15
	 */
16
	protected function setConstantProperties() : void {
17
		$this->gameID = 0;
18
		$this->accountID = 0;
19
		$this->playerID = 0;
20
		$this->alignment = 0;
21
		$this->underAttack = false;
22
		$this->npc = true;
23
		$this->dead = false;
24
	}
25
26
	public function __sleep() {
27
		return ['playerName', 'experience', 'shipID'];
28
	}
29
30
	public function __wakeup() {
31
		$this->setConstantProperties();
32
	}
33
34
	public function increaseHOF(float $amount, array $typeList, string $visibility) : void {}
35
36
	public function killPlayerByPlayer(AbstractSmrPlayer $killer) : array {
37
		$this->dead = true;
38
		return ['DeadExp' => 0, 'KillerCredits' => 0, 'KillerExp' => 0];
39
	}
40
41
	public function getShip(bool $forceUpdate = false) : AbstractSmrShip {
42
		return DummyShip::getCachedDummyShip($this);
43
	}
44
45
	public function cacheDummyPlayer() : void {
46
		$this->getShip()->cacheDummyShip();
0 ignored issues
show
Bug introduced by
The method cacheDummyShip() does not exist on AbstractSmrShip. It seems like you code against a sub-type of AbstractSmrShip such as DummyShip. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
		$this->getShip()->/** @scrutinizer ignore-call */ cacheDummyShip();
Loading history...
47
		$db = Smr\Database::getInstance();
48
		$db->query('REPLACE INTO cached_dummys ' .
49
					'(type, id, info) ' .
50
					'VALUES (\'DummyPlayer\', ' . $db->escapeString($this->getPlayerName()) . ', ' . $db->escapeObject($this) . ')');
51
	}
52
53
	public static function getCachedDummyPlayer(string $name) : self {
54
		$db = Smr\Database::getInstance();
55
		$db->query('SELECT info FROM cached_dummys
56
					WHERE type = \'DummyPlayer\'
57
						AND id = ' . $db->escapeString($name) . ' LIMIT 1');
58
		if ($db->nextRecord()) {
59
			return $db->getObject('info');
60
		} else {
61
			return new DummyPlayer($name);
62
		}
63
	}
64
65
	public static function getDummyPlayerNames() : array {
66
		$db = Smr\Database::getInstance();
67
		$db->query('SELECT id FROM cached_dummys
68
					WHERE type = \'DummyPlayer\'');
69
		$dummyNames = array();
70
		while ($db->nextRecord()) {
71
			$dummyNames[] = $db->getField('id');
72
		}
73
		return $dummyNames;
74
	}
75
76
}
77