$gem = array("gtype" => NULL); // max amount of creatures // depends on the best creature max building one CAN have, not on the best building one has $sql = "SELECT MAX(value) FROM buildings WHERE type = '2' AND level <= '{$acc['level']}'"; $result = $db->query($sql); $creaturemax = $db->result($result, 0) + $gdCreatureMaxIncrement; //$creaturemax = gGetCreatureMax($account["id"]); // got through multiplier $throughmultiplier = $gotthrough / $creaturemax; // total multiplier $multiplier = $throughmultiplier * $punishment * $stealmultiplier / $gotthrough * (1 - $dif / $gdResourceLevelDif); if ($multiplier > 1) { $multiplier = 1; } // get quality of gem $quality = gGetGemQuality($target["arcanechamber"]); // not charged enough if (!$quality) { $accountarcanetext = '<br>You attacked the arcane chamber but it wasn\'t charged enough to produce a gem.'; $targetarcanetext = '<br>Your opponent tried to raid your arcane chamber but it wasn\'t charged enough to produce a gem.'; $sql = "SELECT id, accountreport, targetreport, account FROM battles WHERE target = '{$target['id']}' AND resource = 'arcane' AND status = '1' AND id != '{$bid}'"; $nresult = $db->query($sql); $nnumrows = $db->num_rows($nresult); if ($nnumrows <= 0) { $arcanelostreal = ', arcanerise = \'1\''; } } else { // gem quality $gem["quality"] = $quality["index"]; // gem level $gem["glevel"] = ceil($target["level"] * $multiplier);
if ($action == "producegem") { $no = 0; $signid = getRandomGemSign(); $sql = "LOCK TABLES accounts WRITE, gems WRITE, bsgemlog WRITE, signs READ"; $result = $db->query($sql); $sql = "UPDATE accounts SET travelcounter = travelcounter - 8 WHERE id = '{$acc['id']}'"; $result = $db->query($sql); if ($acc["travelcounter"] <= 0) { $action = "mathdwarf"; $no = 1; } else { $sql = "SELECT arcanechamber FROM accounts WHERE id = '{$acc['id']}'"; $result = $db->query($sql); $arcanechamber = $db->result($result, 0); // get quality $quality = gGetGemQuality($arcanechamber); if (!$quality) { echo 'Your chamber isn\'t charged enough yet to produce a gem!<br>'; $no = 1; } } if ($acc["attacked"]) { echo 'You cannot produce a gem while under attack.<br>'; $no = 1; } if ($no == 0) { $sql = "INSERT INTO gems (owner, target, sign, level, quality) VALUES ('mage', '{$acc['id']}', '{$acc['sign']}', '{$acc['level']}', '{$quality['index']}')"; $result = $db->query($sql); $sql = "UPDATE accounts SET arcanechamber = 0, sign = '{$signid}' WHERE id = '{$acc['id']}'"; $result = $db->query($sql); $sql = "INSERT INTO `bsgemlog` (`gemowner` , `newowner` , `stolen` , `gemsign` , `gemlevel` , `gemquality` , `time`)\r\n\t\t\t\t\tVALUES ('{$acc['id']}', '{$acc['id']}', '{$arcanechamber}', '{$acc['sign']}', '{$acc['level']}', '{$quality}', NOW( ));";