* added faq management - add/edit/move/hide/delete from website

* moved install pages to twig
* load monsters and spells on installation of the AAC
This commit is contained in:
slawkens
2017-10-12 17:40:02 +02:00
parent 315e0400ff
commit f84ae88aa4
27 changed files with 683 additions and 361 deletions

View File

@@ -12,125 +12,11 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Spells';
$config_vocations = $config['vocations'];
$canEdit = hasFlag(FLAG_CONTENT_SPELLS) || admin();
if(isset($_POST['reload_spells']) && $canEdit)
{
try { $db->query('DELETE FROM ' . TABLE_PREFIX . 'spells WHERE 1 = 1'); } catch(PDOException $error) {}
echo '<h2>Reload spells.</h2>';
echo '<h2>All records deleted from table <b>' . TABLE_PREFIX . 'spells</b> in database.</h2>';
foreach($config_vocations as $voc_id => $voc_name) {
$vocations_ids[$voc_name] = $voc_id;
}
$allspells = new OTS_SpellsList($config['data_path'].'spells/spells.xml');
//add conjure spells
$conjurelist = $allspells->getConjuresList();
echo "<h3>Conjure:</h3>";
foreach($conjurelist as $spellname) {
$spell = $allspells->getConjure($spellname);
$lvl = $spell->getLevel();
$mlvl = $spell->getMagicLevel();
$mana = $spell->getMana();
$name = $spell->getName();
$soul = $spell->getSoul();
$spell_txt = $spell->getWords();
$vocations = $spell->getVocations();
$nr_of_vocations = count($vocations);
$vocations_to_db = "";
$voc_nr = 0;
foreach($vocations as $vocation_to_add) {
if(check_number($vocation_to_add)) {
$vocations_to_db .= $vocation_to_add;
}
else
$vocations_to_db .= $vocations_ids[$vocation_to_add];
$voc_nr++;
if($voc_nr != $nr_of_vocations) {
$vocations_to_db .= ',';
}
}
$enabled = $spell->isEnabled();
if($enabled) {
$hide_spell = 0;
}
else {
$hide_spell = 1;
}
$pacc = $spell->isPremium();
if($pacc) {
$pacc = '1';
}
else {
$pacc = '0';
}
$type = 2;
$count = $spell->getConjureCount();
try {
$db->query('INSERT INTO myaac_spells (spell, name, words, type, mana, level, maglevel, soul, premium, vocations, conjure_count, hidden) VALUES (' . $db->quote($spell_txt) . ', ' . $db->quote($name) . ', ' . $db->quote($spell_txt) . ', ' . $db->quote($type) . ', ' . $db->quote($mana) . ', ' . $db->quote($lvl) . ', ' . $db->quote($mlvl) . ', ' . $db->quote($soul) . ', ' . $db->quote($pacc) . ', ' . $db->quote($vocations_to_db) . ', ' . $db->quote($count) . ', ' . $db->quote($hide_spell) . ')');
success("Added: " . $name . "<br>");
}
catch(PDOException $error) {
warning('Error while adding spell (' . $name . '): ' . $error->getMessage());
}
}
//add instant spells
$instantlist = $allspells->getInstantsList();
echo "<h3>Instant:</h3>";
foreach($instantlist as $spellname) {
$spell = $allspells->getInstant($spellname);
$lvl = $spell->getLevel();
$mlvl = $spell->getMagicLevel();
$mana = $spell->getMana();
$name = $spell->getName();
$soul = $spell->getSoul();
$spell_txt = $spell->getWords();
if(strpos($spell_txt, '###') !== false)
continue;
$vocations = $spell->getVocations();
$nr_of_vocations = count($vocations);
$vocations_to_db = "";
$voc_nr = 0;
foreach($vocations as $vocation_to_add) {
if(check_number($vocation_to_add)) {
$vocations_to_db .= $vocation_to_add;
}
else
$vocations_to_db .= $vocations_ids[$vocation_to_add];
$voc_nr++;
if($voc_nr != $nr_of_vocations) {
$vocations_to_db .= ',';
}
}
$enabled = $spell->isEnabled();
if($enabled) {
$hide_spell = 0;
}
else {
$hide_spell = 1;
}
$pacc = $spell->isPremium();
if($pacc) {
$pacc = '1';
}
else {
$pacc = '0';
}
$type = 1;
$count = 0;
try {
$db->query("INSERT INTO myaac_spells (spell, name, words, type, mana, level, maglevel, soul, premium, vocations, conjure_count, hidden) VALUES (".$db->quote($spell_txt).", ".$db->quote($name).", ".$db->quote($spell_txt).", '".$type."', '".$mana."', '".$lvl."', '".$mlvl."', '".$soul."', '".$pacc."', '".$vocations_to_db."', '".$count."', '".$hide_spell."')");
success("Added: ".$name."<br/>");
}
catch(PDOException $error) {
warning('Error while adding spell (' . $name . '): ' . $error->getMessage());
}
}
require LIBS . 'spells.php';
Spells::loadFromXML(true);
}
if($canEdit)
@@ -165,7 +51,7 @@ if(!in_array($order, array('spell', 'words', 'type', 'mana', 'level', 'maglevel'
echo '>All';
foreach($config_vocations as $id => $vocation)
foreach($config['vocations'] as $id => $vocation)
{
echo '<option value="' . $id . '" ';
if($id == $vocation_id && $vocation_id != "All" && $vocation_id != '')
@@ -228,7 +114,7 @@ if(isset($vocation_id) && $vocation_id != 'All' && $vocation_id != '')
else
echo '<TD>Instant</TD>';
echo '<TD>' . $spell['mana'] . '</TD><TD>' . $spell['level'] . '</TD><TD>' . $spell['maglevel'] . '</TD><TD>' . $spell['soul'] . '</TD><TD>' . ($spell ['premium'] == 1 ? 'yes' : 'no') . '</TD><TD>' . $config_vocations[$vocation_id] . '</TD></TR>';
echo '<TD>' . $spell['mana'] . '</TD><TD>' . $spell['level'] . '</TD><TD>' . $spell['maglevel'] . '</TD><TD>' . $spell['soul'] . '</TD><TD>' . ($spell ['premium'] == 1 ? 'yes' : 'no') . '</TD><TD>' . $config['vocations'][$vocation_id] . '</TD></TR>';
}
}
}
@@ -249,8 +135,8 @@ else
$showed_vocations = 0;
foreach($spell_vocations as $spell_vocation)
{
if(isset($config_vocations[$spell_vocation])) {
echo $config_vocations[$spell_vocation];
if(isset($config['vocations'][$spell_vocation])) {
echo $config['vocations'][$spell_vocation];
$showed_vocations++;
}
if($showed_vocations != count($spell_vocations))