forked from gplanchat/wootook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
marchand.php
157 lines (146 loc) · 4.77 KB
/
marchand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
define('INSIDE' , true);
define('INSTALL' , false);
require_once dirname(__FILE__) .'/application/bootstrap.php';
function ModuleMarchand ( $CurrentUser, &$CurrentPlanet ) {
global $lang, $_POST;
includeLang('marchand');
$parse = $lang;
if ($_POST['ress'] != '') {
$PageTPL = gettemplate('message_body');
$Error = false;
$CheatTry = false;
$Metal = $_POST['metal'];
$Crystal = $_POST['cristal'];
$Deuterium = $_POST['deut'];
if ($Metal < 0) {
$Metal *= -1;
$CheatTry = true;
}
if ($Crystal < 0) {
$Crystal *= -1;
$CheatTry = true;
}
if ($Deuterium < 0) {
$Deuterium *= -1;
$CheatTry = true;
}
if ($CheatTry == false) {
switch ($_POST['ress']) {
case 'metal':
$Necessaire = (( $Crystal * 2) + ( $Deuterium * 4));
if ($CurrentPlanet['metal'] > $Necessaire) {
$CurrentPlanet['metal'] -= $Necessaire;
} else {
$Message = $lang['mod_ma_noten'] ." ". $lang['Metal'] ."! ";
$Error = true;
}
break;
case 'cristal':
$Necessaire = (( $Metal * 0.5) + ( $Deuterium * 2));
if ($CurrentPlanet['crystal'] > $Necessaire) {
$CurrentPlanet['crystal'] -= $Necessaire;
} else {
$Message = $lang['mod_ma_noten'] ." ". $lang['Crystal'] ."! ";
$Error = true;
}
break;
case 'deuterium':
$Necessaire = (( $Metal * 0.25) + ( $Crystal * 0.5));
if ($CurrentPlanet['deuterium'] > $Necessaire) {
$CurrentPlanet['deuterium'] -= $Necessaire;
} else {
$Message = $lang['mod_ma_noten'] ." ". $lang['Deuterium'] ."! ";
$Error = true;
}
break;
}
}
if ($Error == false) {
if ($CheatTry == true) {
$CurrentPlanet['metal'] = 0;
$CurrentPlanet['crystal'] = 0;
$CurrentPlanet['deuterium'] = 0;
} else {
$CurrentPlanet['metal'] += $Metal;
$CurrentPlanet['crystal'] += $Crystal;
$CurrentPlanet['deuterium'] += $Deuterium;
}
$QryUpdatePlanet = "UPDATE {{table}} SET ";
$QryUpdatePlanet .= "`metal` = '". $CurrentPlanet['metal'] ."', ";
$QryUpdatePlanet .= "`crystal` = '". $CurrentPlanet['crystal'] ."', ";
$QryUpdatePlanet .= "`deuterium` = '". $CurrentPlanet['deuterium'] ."' ";
$QryUpdatePlanet .= "WHERE ";
$QryUpdatePlanet .= "`id` = '". $CurrentPlanet['id'] ."';";
doquery ( $QryUpdatePlanet , 'planets');
$Message = $lang['mod_ma_done'];
}
if ($Error == true) {
$parse['title'] = $lang['mod_ma_error'];
} else {
$parse['title'] = $lang['mod_ma_donet'];
}
$parse['mes'] = $Message;
} else {
if ($_POST['action'] != 2) {
$PageTPL = gettemplate('marchand_main');
} else {
$parse['mod_ma_res'] = "1";
switch ($_POST['choix']) {
case 'metal':
$PageTPL = gettemplate('marchand_metal');
$parse['mod_ma_res_a'] = "2";
$parse['mod_ma_res_b'] = "4";
break;
case 'cristal':
$PageTPL = gettemplate('marchand_cristal');
$parse['mod_ma_res_a'] = "0.5";
$parse['mod_ma_res_b'] = "2";
break;
case 'deut':
$PageTPL = gettemplate('marchand_deuterium');
$parse['mod_ma_res_a'] = "0.25";
$parse['mod_ma_res_b'] = "0.5";
break;
}
}
}
$Page = parsetemplate ( $PageTPL, $parse );
return $Page;
}
$Page = ModuleMarchand ( $user, $planetrow );
display ( $Page, $lang['mod_marchand'], true, '', false );
// -----------------------------------------------------------------------------------------------------------
// History version
// 1.0 - Version originelle (Tom1991)
// 1.1 - Version 2.0 de Tom1991 ajout java
// 1.2 - R��criture Chlorel passage aux template, optimisation des appels et des requetes SQL
?>