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 | $classLocale = classLocale::$lang; |
||
47 | rpg_points_change($user['id'], RPG_ARTIFACT, -($darkmater_cost), "Spent for artifact {$classLocale['tech'][$unit_id]} ID {$unit_id}"); |
||
48 | sn_db_transaction_commit(); |
||
49 | header("Location: artifacts.php#{$unit_id}"); |
||
50 | ob_end_flush(); |
||
51 | die(); |
||
52 | } |
||
53 | else |
||
54 | { |
||
55 | $Message = classLocale::$lang['off_maxed_out']; |
||
56 | } |
||
57 | } |
||
58 | else |
||
59 | { |
||
60 | $Message = classLocale::$lang['sys_no_points']; |
||
61 | } |
||
62 | sn_db_transaction_rollback(); |
||
63 | break; |
||
64 | |||
65 | case ACTION_USE: |
||
66 | art_use($user, $planetrow, $unit_id); |
||
67 | header("Location: artifacts.php#{$unit_id}"); |
||
68 | ob_end_flush(); |
||
69 | die(); |
||
70 | break; |
||
71 | } |
||
72 | message($Message, classLocale::$lang['tech'][UNIT_ARTIFACTS], 'artifacts.' . PHP_EX, 5); |
||
73 | } |
||
74 | |||
75 | $template = gettemplate('artifacts', true); |
||
76 | |||
77 | foreach($sn_group_artifacts as $artifact_id) |
||
78 | { |
||
79 | $artifact_level = mrc_get_level($user, array(), $artifact_id, true); |
||
80 | $build_data = eco_get_build_data($user, $planetrow, $artifact_id, $artifact_level); |
||
81 | { |
||
82 | $artifact_data = get_unit_param($artifact_id); |
||
83 | $artifact_data_bonus = $artifact_data['bonus']; |
||
84 | $artifact_data_bonus = $artifact_data_bonus >= 0 ? "+{$artifact_data_bonus}" : "{$artifact_data_bonus}"; |
||
85 | View Code Duplication | switch($artifact_data['bonus_type']) |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
86 | { |
||
87 | case BONUS_PERCENT: |
||
88 | $artifact_data_bonus = "{$artifact_data_bonus}% "; |
||
89 | break; |
||
90 | |||
91 | case BONUS_ADD: |
||
92 | break; |
||
93 | |||
94 | case BONUS_ABILITY: |
||
95 | $artifact_data_bonus = ''; |
||
96 | break; |
||
97 | |||
98 | default: |
||
99 | break; |
||
100 | } |
||
101 | |||
102 | $template->assign_block_vars('artifact', array( |
||
103 | 'ID' => $artifact_id, |
||
104 | 'NAME' => classLocale::$lang['tech'][$artifact_id], |
||
105 | 'DESCRIPTION' => classLocale::$lang['info'][$artifact_id]['description'], |
||
106 | 'EFFECT' => classLocale::$lang['info'][$artifact_id]['effect'], |
||
107 | 'COST' => $build_data[BUILD_CREATE][RES_DARK_MATTER], |
||
108 | 'COST_TEXT' => pretty_number($build_data[BUILD_CREATE][RES_DARK_MATTER]), |
||
109 | 'LEVEL' => intval($artifact_level), |
||
110 | 'LEVEL_MAX' => intval($artifact_data['max']), |
||
111 | 'BONUS' => $artifact_data_bonus, |
||
112 | 'BONUS_TYPE' => $artifact_data['bonus_type'], |
||
113 | 'CAN_BUY' => $build_data['CAN'][BUILD_CREATE], |
||
114 | )); |
||
115 | } |
||
116 | } |
||
117 | |||
118 | $template->assign_vars(array( |
||
119 | 'PAGE_HEADER' => classLocale::$lang['tech'][UNIT_ARTIFACTS], |
||
120 | 'PAGE_HINT' => classLocale::$lang['art_page_hint'], |
||
121 | )); |
||
122 | |||
123 | display(parsetemplate($template), classLocale::$lang['tech'][UNIT_ARTIFACTS]); |
||
124 |
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: