1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by Gorlum 05.03.2018 20:42 |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Player; |
7
|
|
|
|
8
|
|
|
use SN; |
9
|
|
|
use DBStaticPlanet; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class PlayerStatic |
13
|
|
|
* @package Player |
14
|
|
|
* |
15
|
|
|
* @deprecated |
16
|
|
|
*/ |
17
|
|
|
class PlayerStatic { |
18
|
|
|
|
19
|
|
|
public static function getPlayerProduction($userId) { |
20
|
|
|
return doquery(" |
21
|
|
|
SELECT |
22
|
|
|
sum(metal_perhour) + sum(crystal_perhour) * 2 + sum(deuterium_perhour) * 4 AS `total`, |
23
|
|
|
sum(metal_perhour) AS `metal`, |
24
|
|
|
sum(crystal_perhour) AS `crystal`, |
25
|
|
|
sum(deuterium_perhour) AS `deuterium`, |
26
|
|
|
avg(metal_mine_porcent) AS `avg_metal_percent`, |
27
|
|
|
avg(crystal_mine_porcent) AS `avg_crystal_percent`, |
28
|
|
|
avg(deuterium_sintetizer_porcent) AS `avg_deuterium_percent` |
29
|
|
|
FROM |
30
|
|
|
`{{planets}}` AS p |
31
|
|
|
WHERE |
32
|
|
|
p.`id_owner` = {$userId} |
33
|
|
|
GROUP BY |
34
|
|
|
id_owner", true); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param $UserID |
39
|
|
|
* |
40
|
|
|
* @deprecated |
41
|
|
|
* |
42
|
|
|
* TODO: Full rewrite |
43
|
|
|
*/ |
44
|
|
|
public static function DeleteSelectedUser($UserID) { |
45
|
|
|
$internalTransaction = false; |
46
|
|
|
if (!sn_db_transaction_check(false)) { |
47
|
|
|
sn_db_transaction_start(); |
48
|
|
|
|
49
|
|
|
$internalTransaction = true; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$TheUser = db_user_by_id($UserID); |
|
|
|
|
53
|
|
|
|
54
|
|
|
if (!empty($TheUser['ally_id'])) { |
55
|
|
|
$TheAlly = doquery("SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';", '', true); |
56
|
|
|
$TheAlly['ally_members'] -= 1; |
57
|
|
|
doquery("UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
58
|
|
|
|
59
|
|
|
// if ( $TheAlly['ally_members'] > 0 ) { |
|
|
|
|
60
|
|
|
// doquery ( "UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
61
|
|
|
// } else { |
62
|
|
|
// doquery ( "DELETE FROM `{{alliance}}` WHERE `id` = '" . $TheAlly['id'] . "';"); |
63
|
|
|
// doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';"); |
64
|
|
|
// } |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
// Deleting all fleets |
68
|
|
|
db_fleet_list_delete_by_owner($UserID); |
69
|
|
|
|
70
|
|
|
// Deleting all planets |
71
|
|
|
DBStaticPlanet::db_planet_list_delete_by_owner($UserID); |
72
|
|
|
|
73
|
|
|
// TEMPORARY player messages not deleted |
74
|
|
|
// doquery("DELETE FROM `{{messages}}` WHERE `message_sender` = '" . $UserID . "';"); |
75
|
|
|
// doquery("DELETE FROM `{{messages}}` WHERE `message_owner` = '" . $UserID . "';"); |
76
|
|
|
|
77
|
|
|
doquery("DELETE FROM `{{notes}}` WHERE `owner` = '" . $UserID . "';"); |
78
|
|
|
|
79
|
|
|
doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '" . $UserID . "';"); |
80
|
|
|
doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '" . $UserID . "';"); |
81
|
|
|
|
82
|
|
|
doquery("DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');"); |
83
|
|
|
|
84
|
|
|
doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';"); |
85
|
|
|
|
86
|
|
|
// Deleting all units |
87
|
|
|
SN::db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLAYER . " AND `unit_player_id` = " . $UserID); |
88
|
|
|
|
89
|
|
|
// Deleting player's record |
90
|
|
|
SN::db_del_record_by_id(LOC_USER, $UserID); |
91
|
|
|
SN::$config->pass()->users_amount = SN::$config->pass()->users_amount - 1; |
92
|
|
|
|
93
|
|
|
if ($internalTransaction) { |
94
|
|
|
sn_db_transaction_commit(); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
} |
99
|
|
|
|