function updateStats($bdd, $characterID) { $update = $bdd->prepare('UPDATE Caranille_Characters SET Character_HP_Equipment = 0, Character_MP_Equipment = 0, Character_Strength_Equipment = 0, Character_Magic_Equipment = 0, Character_Agility_Equipment = 0, Character_Defense_Equipment = 0, Character_Wisdom_Equipment = 0 WHERE Character_ID = :characterID'); $update->execute(['characterID' => $characterID]); $update->closeCursor(); $updateAccount = $bdd->prepare('SELECT * FROM Caranille_Inventory_Equipments WHERE Inventory_Equipment_Equipped = 1 AND Inventory_Equipment_Character_ID = ?'); $updateAccount->execute([$characterID]); while ($item = $updateAccount->fetch()) { $update = $bdd->prepare('UPDATE Caranille_Characters SET Character_HP_Equipment = Character_HP_Equipment + :itemHP, Character_MP_Equipment = Character_MP_Equipment + :itemMP, Character_Strength_Equipment = Character_Strength_Equipment + :itemStrength, Character_Magic_Equipment = Character_Magic_Equipment + :itemMagic, Character_Agility_Equipment = Character_Agility_Equipment + :itemAgility, Character_Defense_Equipment = Character_Defense_Equipment + :itemDefense, Character_Wisdom_Equipment = Character_Wisdom_Equipment + :itemWisdom WHERE Character_ID = :characterID'); $ite = newEquipment($bdd, $item['Inventory_Equipment_Equipment_ID']); $update->execute(['itemHP' => $ite->getHP(), 'itemMP' => $ite->getMP(), 'itemStrength' => $ite->getStrength(), 'itemMagic' => $ite->getMagic(), 'itemAgility' => $ite->getAgility(), 'itemDefense' => $ite->getDefense(), 'itemWisdom' => $ite->getSagesse(), 'characterID' => $characterID]); $update->closeCursor(); } }
function showEquipmentTown($bdd, $townID) { global $atown33, $atown34; $showEquipmentTown = $bdd->prepare('SELECT * FROM Caranille_Towns_Equipments WHERE Town_Equipment_Town_ID = ? ORDER BY Town_Equipment_ID desc'); $showEquipmentTown->execute([$townID]); ?> <br><table class="table"> <tr> <th><?php echo $atown34; ?> </th> <th></th> </tr> <?php while ($Equipment = $showEquipmentTown->fetch()) { $EquipmentID = stripslashes($Equipment['Town_Equipment_Equipment_ID']); $townEquipmentID = stripslashes($Equipment['Town_Equipment_ID']); ?> <tr> <td> <?php echo newEquipment($bdd, $EquipmentID)->getName(); ?> </td> <td> <form method="POST" action="Delete.php"> <input type="hidden" name="townID" value="<?php echo $townID; ?> "> <input type="hidden" name="townEquipmentID" value="<?php echo $townEquipmentID; ?> "> <input class="btn btn-warning" type="submit" value="<?php echo $atown33; ?> "> </form> </td> </tr> <?php } ?> </table> <?php $showEquipmentTown->closeCursor(); }
function showMonsterDrops($bdd, $monsterID) { global $atown19, $atown20, $amonsterDrop3; $showMonsterDrop = $bdd->prepare('SELECT * FROM Caranille_Monsters_Drops WHERE Monster_Drop_Monster_ID = ?'); $showMonsterDrop->execute([$monsterID]); ?> <br> <table class="table"> <tr> <th></th> <th></th> <th></th> </tr> <?php while ($item = $showMonsterDrop->fetch()) { $monsterDropID = stripslashes($item['Monster_Drop_ID']); $monsterDropType = stripslashes($item['Monster_Drop_Item_Type']); ?> <tr> <td> <?php if ($monsterDropType == "item") { echo newItem($bdd, $item['Monster_Drop_Item_ID'])->getName(); } else { echo newEquipment($bdd, $item['Monster_Drop_Item_ID'])->getName(); } ?> </td> <td> <?php echo $item['Monster_Drop_Luck'] . "/1000"; ?> </td> <td> <form method="POST" action="Delete.php"> <input type="hidden" name="monsterDropID" value="<?php echo $monsterDropID; ?> "> <input type="hidden" name="monsterID" value="<?php echo $monsterID; ?> "> <input class="btn btn-warning" type="submit" value="<?php echo $amonsterDrop3; ?> "> </form> </td> </tr> <?php } ?> </table> <?php $showMonsterDrop->closeCursor(); }
<?php $timeStart = microtime(true); session_start(); ob_start(); if (empty($_SESSION)) { exit(header("Location: ../../index.php")); } require_once $_SESSION['File_Root'] . '/Kernel/Include.php'; require_once $_SESSION['File_Root'] . '/HTML/Header.php'; require_once 'Functions/SQL.php'; redirectToLogin($accountID, $linkRoot); redirectToBattle($verifyBattle, $linkRoot); $equipmentID = htmlspecialchars(addslashes($_POST['EquipmentID'])); $canBePurchased = canBePurchased($bdd, $equipmentID, $characterTownID); if ($canBePurchased == 1) { $number = verifyEquipment($bdd, $equipmentID, $characterID); if ($number <= 0) { $equipment = newEquipment($bdd, $equipmentID); addEquipment($bdd, $equipmentID, $characterID); $gold = $character->getGold() - $equipment->getPurchase(); updateCharacterGold($bdd, $gold, $characterID); } else { updateEquipment($bdd, $characterID, $equipmentID); } } else { echo "An error has surved"; } require_once $_SESSION['File_Root'] . '/HTML/Footer.php';
<?php $timeStart = microtime(true); session_start(); ob_start(); if (empty($_SESSION)) { exit(header("Location: ../../index.php")); } require_once $_SESSION['File_Root'] . '/Kernel/Include.php'; require_once $_SESSION['File_Root'] . '/HTML/Header.php'; require_once 'Functions/SQL.php'; redirectToLogin($accountID, $linkRoot); redirectToBattle($verifyBattle, $linkRoot); $inventoryID = htmlspecialchars(addslashes($_POST['InventoryID'])); $itemID = htmlspecialchars(addslashes($_POST['itemID'])); $itemType = htmlspecialchars(addslashes($_POST['itemType'])); if ($itemType == 'Armor' || $itemType == 'Boots' || $itemType == 'Gloves' || $itemType == 'Helmet' || $itemType == 'Weapon') { $item = newEquipment($bdd, $itemID); } else { $item = newItem($bdd, $itemID); } if ($item->getLevel() <= $characterLevel) { if (verifyEquip($bdd, $characterID, $itemType, $itemID, '0')['Inventory_Equipment_Equipped'] == '0') { $itemIDEquip = verifyEquipID($bdd, $characterID, $itemType)['Inventory_Equipment_ID']; initialEquip($bdd, $characterID, $itemType, '0'); } updateEquip($bdd, $characterID, $itemID, '1'); updateStats($bdd, $characterID); updateAllStats($bdd, $characterID); } require_once $_SESSION['File_Root'] . '/HTML/Footer.php';