<?
include "vsys.php";
if ($cgi['buy_merc']){
$merc=getCommonInfo();
if ($cgi['mercs_attack']){
if ($cgi['mercs_attack']>$merc->attackSpecCount)$cgi['mercs_attack']=$merc->attackSpecCount;
$gold=$cgi['mercs_attack']*$conf["mercenaries"]["atack"]["prise"];
$user=getUserDetails($_SESSION['isLogined']," gold ");
if ($user->gold>$gold){
updateMercenary(" attackSpecCount=attackSpecCount-{$cgi['mercs_attack']} ");
updateUser($_SESSION['isLogined'], " trainedAttackMerc=trainedAttackMerc+{$cgi['mercs_attack']} , gold=gold-$gold ");
}else{
$strErr="You do not have enough money";
}
}
if ($cgi['mercs_defend']){
if ($cgi['mercs_defend']>$merc->defSpecCount)$cgi['mercs_defend']=$merc->defSpecCount;
$gold=$cgi['mercs_defend']*$conf["mercenaries"]["defence"]["prise"];
$user=getUserDetails($_SESSION['isLogined']," gold ");
if ($user->gold>$gold){
updateMercenary(" defSpecCount =defSpecCount -{$cgi['mercs_defend']} ");
updateUser($_SESSION['isLogined'], " trainedDefMerc=trainedDefMerc+{$cgi['mercs_defend']} , gold=gold-$gold ");
}else{
$strErr="You do not have enough money";
}
}
if ($cgi['mercs_general']){
if ($cgi['mercs_general']>$merc->untrainedCount)$cgi['mercs_general']=$merc->untrainedCount;
$gold=$cgi['mercs_general']*$conf["mercenaries"]["untrained"]["prise"];
$user=getUserDetails($_SESSION['isLogined']," gold ");
if ($user->gold>$gold){
updateMercenary(" untrainedCount =untrainedCount -{$cgi['mercs_general']} ");
updateUser($_SESSION['isLogined'], " untrainedMerc=untrainedMerc+{$cgi['mercs_general']} , gold=gold-$gold ");
}else{
$strErr="You do not have enough money";
}
}
header("Location: mercs.php?strErr=$strErr");
}
?>