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 | global $lang, $user, $planetrow; |
||
17 | |||
18 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
19 | |||
20 | lng_include('infos'); |
||
21 | lng_include('artifacts'); |
||
22 | |||
23 | include('includes/includes/art_artifact.php'); |
||
24 | |||
25 | $sn_group_artifacts = sn_get_groups('artifacts'); |
||
26 | |||
27 | if(($action = sys_get_param_int('action')) && in_array($unit_id = sys_get_param_int('unit_id'), $sn_group_artifacts)) |
||
28 | { |
||
29 | switch($action) |
||
30 | { |
||
31 | case ACTION_BUY: |
||
32 | sn_db_transaction_start(); |
||
33 | |||
34 | $user = db_user_by_id($user['id'], true); |
||
0 ignored issues
–
show
|
|||
35 | $artifact_level = mrc_get_level($user, array(), $unit_id, true); |
||
36 | |||
37 | $build_data = eco_get_build_data($user, $planetrow, $unit_id, $artifact_level, true); |
||
38 | $darkmater_cost = $build_data[BUILD_CREATE][RES_DARK_MATTER]; |
||
39 | |||
40 | // TODO: more correct check - with "FOR UPDATE" |
||
41 | if(mrc_get_level($user, null, RES_DARK_MATTER) >= $darkmater_cost) |
||
0 ignored issues
–
show
null is of type null , but the function expects a array .
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);
![]() |
|||
42 | { |
||
43 | $unit_max_stack = get_unit_param($unit_id, P_MAX_STACK); |
||
44 | if(!isset($unit_max_stack) || $unit_max_stack > mrc_get_level($user, $planetrow, $unit_id)) |
||
45 | { |
||
46 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, 1, $user); |
||
0 ignored issues
–
show
|
|||
47 | OldDbChangeSet::db_changeset_apply($db_changeset); |
||
0 ignored issues
–
show
|
|||
48 | rpg_points_change($user['id'], RPG_ARTIFACT, -($darkmater_cost), "Spent for artifact {$lang['tech'][$unit_id]} ID {$unit_id}"); |
||
49 | sn_db_transaction_commit(); |
||
50 | sys_redirect("artifacts.php#{$unit_id}"); |
||
51 | } |
||
52 | else |
||
53 | { |
||
54 | $Message = $lang['off_maxed_out']; |
||
55 | } |
||
56 | } |
||
57 | else |
||
58 | { |
||
59 | $Message = $lang['sys_no_points']; |
||
60 | } |
||
61 | sn_db_transaction_rollback(); |
||
62 | break; |
||
63 | |||
64 | case ACTION_USE: |
||
65 | art_use($user, $planetrow, $unit_id); |
||
66 | sys_redirect("artifacts.php#{$unit_id}"); |
||
67 | break; |
||
68 | } |
||
69 | messageBox($Message, $lang['tech'][UNIT_ARTIFACTS], 'artifacts.' . PHP_EX, 5); |
||
70 | } |
||
71 | |||
72 | $template = gettemplate('artifacts', true); |
||
0 ignored issues
–
show
true is of type boolean , but the function expects a object<template>|null .
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);
![]() |
|||
73 | |||
74 | foreach($sn_group_artifacts as $artifact_id) |
||
75 | { |
||
76 | $artifact_level = mrc_get_level($user, array(), $artifact_id, true); |
||
77 | $build_data = eco_get_build_data($user, $planetrow, $artifact_id, $artifact_level); |
||
78 | { |
||
79 | $artifact_data = get_unit_param($artifact_id); |
||
80 | $artifact_data_bonus = tpl_render_unit_bonus_data($artifact_data); |
||
81 | |||
82 | $template->assign_block_vars('artifact', array( |
||
83 | 'ID' => $artifact_id, |
||
84 | 'NAME' => $lang['tech'][$artifact_id], |
||
85 | 'DESCRIPTION' => $lang['info'][$artifact_id]['description'], |
||
86 | 'EFFECT' => $lang['info'][$artifact_id]['effect'], |
||
87 | 'COST' => $build_data[BUILD_CREATE][RES_DARK_MATTER], |
||
88 | 'COST_TEXT' => pretty_number($build_data[BUILD_CREATE][RES_DARK_MATTER]), |
||
89 | 'LEVEL' => intval($artifact_level), |
||
90 | 'LEVEL_MAX' => intval($artifact_data['max']), |
||
91 | 'BONUS' => $artifact_data_bonus, |
||
92 | 'BONUS_TYPE' => $artifact_data['bonus_type'], |
||
93 | 'CAN_BUY' => $build_data['CAN'][BUILD_CREATE], |
||
94 | )); |
||
95 | } |
||
96 | } |
||
97 | |||
98 | $template->assign_vars(array( |
||
99 | 'PAGE_HEADER' => $lang['tech'][UNIT_ARTIFACTS], |
||
100 | 'PAGE_HINT' => $lang['art_page_hint'], |
||
101 | )); |
||
102 | |||
103 | display($template, $lang['tech'][UNIT_ARTIFACTS]); |
||
104 |
This function has been deprecated.