These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * artifacts.php |
||
5 | * Artifact actions |
||
6 | * |
||
7 | * @package roleplay |
||
8 | * @version 1.0 |
||
9 | * |
||
10 | * Revision History |
||
11 | * ================ |
||
12 | * 1.0 copyright (c) 2011 by Gorlum for http://supernova.ws |
||
13 | * |
||
14 | */ |
||
15 | |||
16 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
17 | |||
18 | lng_include('infos'); |
||
19 | lng_include('artifacts'); |
||
20 | |||
21 | include('includes/includes/art_artifact.php'); |
||
22 | |||
23 | $sn_group_artifacts = sn_get_groups('artifacts'); |
||
24 | |||
25 | if(($action = sys_get_param_int('action')) && in_array($unit_id = sys_get_param_int('unit_id'), $sn_group_artifacts)) |
||
26 | { |
||
27 | switch($action) |
||
28 | { |
||
29 | case ACTION_BUY: |
||
30 | sn_db_transaction_start(); |
||
31 | |||
32 | $user = db_user_by_id($user['id'], true); |
||
33 | $artifact_level = mrc_get_level($user, array(), $unit_id, true); |
||
34 | |||
35 | $build_data = eco_get_build_data($user, $planetrow, $unit_id, $artifact_level, true); |
||
36 | $darkmater_cost = $build_data[BUILD_CREATE][RES_DARK_MATTER]; |
||
37 | |||
38 | // TODO: more correct check - with "FOR UPDATE" |
||
39 | if(mrc_get_level($user, null, RES_DARK_MATTER) >= $darkmater_cost) |
||
0 ignored issues
–
show
|
|||
40 | { |
||
41 | $unit_max_stack = get_unit_param($unit_id, P_MAX_STACK); |
||
42 | if(!isset($unit_max_stack) || $unit_max_stack > mrc_get_level($user, $planetrow, $unit_id)) |
||
43 | { |
||
44 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, 1, $user); |
||
45 | db_changeset_apply($db_changeset); |
||
46 | rpg_points_change($user['id'], RPG_ARTIFACT, -($darkmater_cost), |
||
47 | sprintf('Spent for artifact %1$s ID %2$d', classLocale::$lang['tech'][$unit_id], $unit_id) |
||
0 ignored issues
–
show
sprintf('Spent for artif...'][$unit_id], $unit_id) is of type string , but the function expects a boolean .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
48 | ); |
||
49 | sn_db_transaction_commit(); |
||
50 | header("Location: artifacts.php#{$unit_id}"); |
||
51 | ob_end_flush(); |
||
52 | die(); |
||
53 | } |
||
54 | else |
||
55 | { |
||
56 | $Message = classLocale::$lang['off_maxed_out']; |
||
57 | } |
||
58 | } |
||
59 | else |
||
60 | { |
||
61 | $Message = classLocale::$lang['sys_no_points']; |
||
62 | } |
||
63 | sn_db_transaction_rollback(); |
||
64 | break; |
||
65 | |||
66 | case ACTION_USE: |
||
67 | art_use($user, $planetrow, $unit_id); |
||
68 | header("Location: artifacts.php#{$unit_id}"); |
||
69 | ob_end_flush(); |
||
70 | die(); |
||
71 | break; |
||
72 | } |
||
73 | message($Message, classLocale::$lang['tech'][UNIT_ARTIFACTS], 'artifacts.' . PHP_EX, 5); |
||
74 | } |
||
75 | |||
76 | $template = gettemplate('artifacts', true); |
||
77 | |||
78 | foreach($sn_group_artifacts as $artifact_id) |
||
79 | { |
||
80 | $artifact_level = mrc_get_level($user, array(), $artifact_id, true); |
||
81 | $build_data = eco_get_build_data($user, $planetrow, $artifact_id, $artifact_level); |
||
82 | { |
||
83 | $artifact_data = get_unit_param($artifact_id); |
||
84 | $artifact_data_bonus = $artifact_data['bonus']; |
||
85 | $artifact_data_bonus = $artifact_data_bonus >= 0 ? "+{$artifact_data_bonus}" : "{$artifact_data_bonus}"; |
||
86 | View Code Duplication | switch($artifact_data['bonus_type']) |
|
87 | { |
||
88 | case BONUS_PERCENT: |
||
89 | $artifact_data_bonus = "{$artifact_data_bonus}% "; |
||
90 | break; |
||
91 | |||
92 | case BONUS_ADD: |
||
93 | break; |
||
94 | |||
95 | case BONUS_ABILITY: |
||
96 | $artifact_data_bonus = ''; |
||
97 | break; |
||
98 | |||
99 | default: |
||
100 | break; |
||
101 | } |
||
102 | |||
103 | $template->assign_block_vars('artifact', array( |
||
104 | 'ID' => $artifact_id, |
||
105 | 'NAME' => classLocale::$lang['tech'][$artifact_id], |
||
106 | 'DESCRIPTION' => classLocale::$lang['info'][$artifact_id]['description'], |
||
107 | 'EFFECT' => classLocale::$lang['info'][$artifact_id]['effect'], |
||
108 | 'COST' => $build_data[BUILD_CREATE][RES_DARK_MATTER], |
||
109 | 'COST_TEXT' => pretty_number($build_data[BUILD_CREATE][RES_DARK_MATTER]), |
||
110 | 'LEVEL' => intval($artifact_level), |
||
111 | 'LEVEL_MAX' => intval($artifact_data['max']), |
||
112 | 'BONUS' => $artifact_data_bonus, |
||
113 | 'BONUS_TYPE' => $artifact_data['bonus_type'], |
||
114 | 'CAN_BUY' => $build_data['CAN'][BUILD_CREATE], |
||
115 | )); |
||
116 | } |
||
117 | } |
||
118 | |||
119 | $template->assign_vars(array( |
||
120 | 'PAGE_HEADER' => classLocale::$lang['tech'][UNIT_ARTIFACTS], |
||
121 | 'PAGE_HINT' => classLocale::$lang['art_page_hint'], |
||
122 | )); |
||
123 | |||
124 | display(parsetemplate($template), classLocale::$lang['tech'][UNIT_ARTIFACTS]); |
||
125 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: