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

Issues (412)

src/lib/Default/missions.inc.php (1 issue)

Severity
1
<?php declare(strict_types=1);
2
3
use Smr\BarDrink;
4
use Smr\PlotGroup;
5
6
const MISSION_ACTIONS = [
7
	'LeaveSector',
8
	'EnterSector',
9
	'WalkSector',
10
	'JoinAlliance',
11
	'LeaveAlliance',
12
	'DisbandAlliance',
13
	'KickPlayer',
14
	'PlayerKicked',
15
	'BuyDrink',
16
];
17
18
//REQUIREMENTS
19
//if you use an array as a requirement and the requirement name represents an array, it will check every value and all must pass
20
//if you use an array as a requirement and the requirement name is not an array, only one of the checks must pass
21
//ie 'Completed Missions' => array(2,3) means the player must have completed BOTH missions
22
//ie 'Ship ID' => array(1,2) means the player must be in EITHER ship id 1 or 2
23
//STEPS
24
/*key types:
25
*'KillName' - kill 'Detail' Player/NPC
26
*'KillNPCs' - kill 'Detail' NPCs
27
*'KillPlayers' - kill 'Detail' Players
28
*'KillSpawn' - Spawn 'Detail' Type NPC and kill it, DB field Progress with then be NPC_ID, also requires a 'Level' element, use -1 for normal
29
'Trade' -
30
^'Visit' - Examine 'Detail' location
31
*'DrinkAmount' - Buy 'Detail' drinks at a bar
32
*'Drink' - Buy 'Detail' drink name at a bar
33
*'Move' - Move 'Detail' sectors anywhere
34
*'MoveSector' - Move to 'Detail' sector
35
*'MoveRacial' - Move to galaxy containing 'Detail' race HQ (use racial id)
36
*'MoveGal' - Move to 'Detail' galaxy
37
'ClearNPC' - Clear 'Detail' stacks of NPC forces in sector (use MoveSector) command to tell them which sector, also stored as mission_sector in DB
38
*'StartPortRaid' - start raiding 'detail' ports
39
*'RaidPort' - raid 'detail' ports
40
'Bring' - bring 'detail' to starting sector
41
42
Replacements:
43
<Race> - Current race name
44
<Starting Sector> - Sector where mission was accepted
45
<Sector> - Random sector for mission.
46
47
* = implemented
48
^ = partial implementaion
49
	Visit - done for 'Bar'
50
*/
51
52
// NOTE: Array keys are the mission ID and should not be changed!
53
const MISSIONS = [
54
	0 => [
55
		'Name' => 'Drunk Guy',
56
		'Offerer' => 'Drunk',
57
		'Time Limit' => 0,
58
		'HasX' => [
59
			'Type' => PlotGroup::Locations,
60
			'X' => 'Bar',
61
		],
62
		'Steps' => [
63
			[
64
				'Step' => 'EnterSector',
65
				'PickSector' => [
66
					'Type' => PlotGroup::Locations,
67
					'X' => RACE_SALVENE + LOCATION_GROUP_RACIAL_HQS,
68
				],
69
				'Detail' => [
70
					'SectorID' => '<Sector>',
71
				],
72
				'Text' => '*Hiccup* Hey! I need you to...*Hiccup* do me a favor. All the ' . BarDrink::SALVENE_SWAMP_SODA . ' in this bar is awful! Go to the Sal...*Hiccup*...the Salvene HQ, they\'ll know a good bar.',
73
				'Task' => 'Go to the Salvene HQ at [sector=<Sector>]',
74
			],
75
			[
76
				'Step' => 'EnterSector',
77
				'PickSector' => [
78
					'Type' => PlotGroup::Locations,
79
					'X' => 'Bar',
80
				],
81
				'Detail' => [
82
					'SectorID' => '<Sector>',
83
				],
84
				'Text' => 'Here we are! The Salvene HQ! You ask around a bit and find that the bar in [sector=<Sector>] does the best ' . BarDrink::SALVENE_SWAMP_SODA . ' around!',
85
				'Task' => 'Go to the bar at [sector=<Sector>] and buy a ' . BarDrink::SALVENE_SWAMP_SODA . ' from the bartender. This may take many tries.',
86
			],
87
			[
88
				'Step' => 'BuyDrink',
89
				'Detail' => [
90
					'SectorID' => '<Sector>',
91
					'Drink' => BarDrink::SALVENE_SWAMP_SODA,
92
				],
93
				'Text' => 'Here we are! Now let\'s get this ' . BarDrink::SALVENE_SWAMP_SODA . '.',
94
				'Task' => 'Go to the bar at [sector=<Sector>] and buy a ' . BarDrink::SALVENE_SWAMP_SODA . ' from the bartender. This may take many tries.',
95
			],
96
			[
97
				'Step' => 'EnterSector',
98
				'Detail' => [
99
					'SectorID' => '<Starting Sector>',
100
				],
101
				'Text' => 'Finally! A true ' . BarDrink::SALVENE_SWAMP_SODA . ', let\'s return to that drunk!',
102
				'Task' => 'Return to [sector=<Starting Sector>] to claim your reward.',
103
			],
104
			[
105
				'Step' => 'Claim',
106
				'Rewards' => [
107
					'Credits' => 500000,
108
					'Experience' => 1000,
109
					'Text' => '*Hiccup* For your...service *Hiccup* to me, take these *Hiccup* 500,000 credits and 1,000 experience *Hiccup*!',
110
				],
111
				'Detail' => [
112
					'SectorID' => '<Starting Sector>',
113
				],
114
				'Text' => 'You hand the ' . BarDrink::SALVENE_SWAMP_SODA . ' to the drunk!',
115
			],
116
		],
117
	],
118
];
119
120
/**
121
 * Callback for array_walk_recursive in SmrPlayer::rebuildMission.
122
 * Searches for placeholders in template and replaces them with values
123
 * derived from the supplied data.
124
 *
125
 * @param array<string, mixed> $data
126
 */
127
function replaceMissionTemplate(string|int|PlotGroup &$template, string $key, array $data): void {
0 ignored issues
show
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

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

127
function replaceMissionTemplate(string|int|PlotGroup &$template, /** @scrutinizer ignore-unused */ string $key, array $data): void {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
128
	if (!is_string($template)) {
129
		return;
130
	}
131
	$search = ['<Race>', '<Sector>', '<Starting Sector>'];
132
	$replace = [$data['player']->getRaceID(), $data['mission']['Sector'], $data['mission']['Starting Sector']];
133
	$template = str_replace($search, $replace, $template);
134
}
135
136
/**
137
 * @param array<string, mixed> $values
138
 * @param array<string, mixed> $requirements
139
 */
140
function checkMissionRequirements(array $values, array $requirements): bool {
141
	foreach ($requirements as $reqName => $reqValue) {
142
		if ($values[$reqName] != $reqValue) {
143
			return false;
144
		}
145
	}
146
	return true;
147
}
148