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

Passed
Push — master ( ba9687...5bb441 )
by Dan
03:44
created

DummyPlayer   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 63
dl 0
loc 104
rs 10
c 1
b 0
f 0
wmc 17

14 Methods

Rating   Name   Duplication   Size   Complexity  
A killPlayerByPlayer() 0 2 1
A killPlayerByPlanet() 0 1 1
A getShip() 0 2 1
A getCachedDummyPlayer() 0 12 2
A setAllianceID() 0 4 2
A getDummyPlayerNames() 0 9 2
A getBountiesData() 0 1 1
A killPlayerByForces() 0 1 1
A getHOFData() 0 1 1
A cacheDummyPlayer() 0 8 1
A killPlayerByPort() 0 1 1
A __construct() 0 29 1
A killPlayer() 0 4 1
A getPersonalRelationsData() 0 1 1
1
<?php declare(strict_types=1);
2
3
class DummyPlayer extends AbstractSmrPlayer {
4
	public function __construct($gameID=0,$playerName='Dummy',$raceID=1,$experience=1000,$alignment=100,$allianceID=0,$shipTypeID=60) {
5
		$this->accountID				= 0;
6
		$this->gameID					= (int) $gameID;
7
		$this->playerName				= (string) $playerName;
8
		$this->playerID					= 0;
9
		$this->sectorID					= 0;
10
		$this->lastSectorID				= 0;
11
		$this->turns					= 1000;
12
		$this->newbieTurns				= 0;
13
		$this->lastNewsUpdate			= 0;
14
		$this->dead						= false;
15
		$this->landedOnPlanet			= false;
16
		$this->lastActive				= 0;
17
		$this->lastCPLAction			= 0;
18
		$this->raceID					= (int) $raceID;
19
		$this->credits					= 0;
20
		$this->experience				= (int) $experience;
21
		$this->alignment				= (int) $alignment;
22
		$this->militaryPayment			= 0;
23
		$this->allianceID				= (int) $allianceID;
24
		$this->shipID					= (int) $shipTypeID;
25
		$this->kills					= 0;
26
		$this->deaths					= 0;
27
		$this->lastPort					= 0;
28
		$this->bank						= 0;
29
		$this->zoom						= 0;
30
		
31
		$this->personalRelations = array();
32
		$this->bounties = array();
33
	}
34
	
35
	protected function getPersonalRelationsData() {
36
	}
37
	
38
	protected function getHOFData() {
39
	}
40
	
41
	protected function getBountiesData() {
42
	}
43
	
44
	public function killPlayer($sectorID) {
45
		$this->setSectorID(1);
46
		$this->setDead(true);
47
		$this->getShip()->getPod();
48
	}
49
	
50
	public function setAllianceID($ID) {
51
		if($this->allianceID == $ID)
52
			return;
53
		$this->allianceID=$ID;
54
	}
55
	
56
	public function &killPlayerByPlayer(AbstractSmrPlayer $killer) {
57
		$this->killPlayer($this->getSectorID());
58
	}
59
	
60
	public function &killPlayerByForces(SmrForce $forces) {
61
	}
62
	
63
	public function &killPlayerByPort(SmrPort $port) {
64
	}
65
	
66
	public function &killPlayerByPlanet(SmrPlanet $planet) {
67
	}
68
	
69
	public function getShip() {
70
		return DummyShip::getCachedDummyShip($this);
71
	}
72
	
73
	public function cacheDummyPlayer() {
74
		$this->getShip()->cacheDummyShip();
75
		$cache = serialize($this);
76
		$db = new SmrMySqlDatabase();
77
		$db->query('REPLACE INTO cached_dummys ' .
78
					'(type, id, info) ' .
79
					'VALUES (\'DummyPlayer\', '.$db->escapeString($this->getPlayerName()).', '.$db->escapeString($cache).')');	
80
		 unserialize($cache);
81
	}
82
	
83
	public static function &getCachedDummyPlayer($name) {
84
		$db = new SmrMySqlDatabase();
85
		$db->query('SELECT info FROM cached_dummys
86
					WHERE type = \'DummyPlayer\'
87
						AND id = ' . $db->escapeString($name) . ' LIMIT 1');
88
		if($db->nextRecord()) {
89
			$return = unserialize($db->getField('info'));
90
			return $return;
91
		}
92
		else {
93
			$return = new DummyPlayer();
94
			return $return;
95
		}
96
	}
97
	
98
	public static function getDummyPlayerNames() {
99
		$db = new SmrMySqlDatabase();
100
		$db->query('SELECT id FROM cached_dummys
101
					WHERE type = \'DummyPlayer\'');
102
		$dummyNames = array();
103
		while($db->nextRecord()) {
104
			$dummyNames[] = $db->getField('id');
105
		}
106
		return $dummyNames;
107
	}
108
}
109