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
Push — main ( 5797ad...3faf69 )
by Dan
29s queued 24s
created

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

Labels
Severity
1
<?php declare(strict_types=1);
2
3
use Smr\Exceptions\UserError;
4
5
function check_bargain_number(int $amount, int $ideal_price, int $offered_price, int $bargain_price, Page $container, AbstractSmrPlayer $player): void {
6
	$var = Smr\Session::getInstance()->getCurrentVar();
7
8
	$port = $player->getSectorPort();
9
10
	// increase current number of tries
11
	$container['number_of_bargains'] = isset($var['number_of_bargains']) ? $var['number_of_bargains'] + 1 : 1;
12
13
	if (isset($var['overall_number_of_bargains'])) {
14
		// lose relations for bad bargain
15
		$player->decreaseRelationsByTrade($amount, $port->getRaceID());
16
		$player->increaseHOF(1, ['Trade', 'Results', 'Fail'], HOF_PUBLIC);
17
		// transfer values
18
		$container->addVar('overall_number_of_bargains');
19
20
		// does we have enough of it?
21
		if ($container['number_of_bargains'] > $container['overall_number_of_bargains']) {
22
			$player->decreaseRelationsByTrade($amount, $port->getRaceID());
23
			$player->increaseHOF(1, ['Trade', 'Results', 'Epic Fail'], HOF_PUBLIC);
24
			throw new UserError('You don\'t want to accept my offer? I\'m sick of you! Get out of here!');
25
		}
26
27
		$port_off = IRound($offered_price * 100 / $ideal_price);
0 ignored issues
show
The function IRound was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

27
		$port_off = /** @scrutinizer ignore-call */ IRound($offered_price * 100 / $ideal_price);
Loading history...
28
		$trader_off = IRound($bargain_price * 100 / $ideal_price);
29
30
		// get relative numbers!
31
		// be carefull! one of this value is negative!
32
		$port_off_rel = 100 - $port_off;
33
		$trader_off_rel = 100 - $trader_off;
34
35
		// only do something, if we are more off than the trader
36
		if (abs($port_off_rel) > abs($trader_off_rel)) {
37
			// get a random number between
38
			// (port_off) and (100 +/- $trader_off_rel)
39
			if (100 + $trader_off_rel < $port_off) {
40
				$offer_modifier = rand(100 + $trader_off_rel, $port_off);
41
			} else {
42
				$offer_modifier = rand($port_off, 100 + $trader_off_rel);
43
			}
44
45
			$container['offered_price'] = IRound($container['ideal_price'] * $offer_modifier / 100);
46
		}
47
	} else {
48
		$container['overall_number_of_bargains'] = rand(2, 5);
49
	}
50
}
51