* @author Slawkens * @copyright 2017 MyAAC * @version 0.2.3 * @link http://my-aac.org */ 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 '

Reload spells.

'; echo '

All records deleted from table ' . TABLE_PREFIX . 'spells in database.

'; 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 "

Conjure:

"; 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 ('".$spell_txt."', '".$name."', '".$spell_txt."', '".$type."', '".$mana."', '".$lvl."', '".$mlvl."', '".$soul."', '".$pacc."', '".$vocations_to_db."', '".$count."', '".$hide_spell."')"); } catch(PDOException $error) {} echo "Added: ".$name."
"; } //add instant spells $instantlist = $allspells->getInstantsList(); echo "

Instant:

"; 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 ('".$spell_txt."', '".$name."', '".$spell_txt."', '".$type."', '".$mana."', '".$lvl."', '".$mlvl."', '".$soul."', '".$pacc."', '".$vocations_to_db."', '".$count."', '".$hide_spell."')"); } catch(PDOException $error) {} echo "Added: ".$name."
"; } } if($canEdit) { ?>
Spell Search
Only for vocation:    
query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'spells') . ' WHERE ' . $db->fieldName('hidden') . ' != 1 ORDER BY ' . $order . ', level'); if(isset($vocation_id) && $vocation_id != 'All' && $vocation_id != '') { foreach($spells as $spell) { $spell_vocations = explode(",", $spell['vocations']); if(in_array($vocation_id, $spell_vocations) || empty($spell['vocations'])) { echo ''; if($spell['type'] == 2) echo ''; else echo ''; echo ''; } } } else { foreach($spells as $spell) { $spell_vocations = explode(",", $spell['vocations']); echo ''; if($spell['type'] == 1) echo ''; else echo ''; echo ''; } } ?>
Name Words Type
(count)
Mana Level Magic
Level
Soul Premium Vocations:
' . $spell['name'] . '' . $spell['words'] . 'Conjure ('.$spell['conjure_count'].')Instant' . $spell['mana'] . '' . $spell['level'] . '' . $spell['maglevel'] . '' . $spell['soul'] . '' . ($spell ['premium'] == 1 ? 'yes' : 'no') . '' . $config_vocations[$vocation_id] . '
' .$spell['name'] . '' . $spell['words'] . 'InstantConjure ('.$spell['conjure_count'].')' . $spell['mana'] . '' . $spell['level'] . '' . $spell['maglevel'] . '' . $spell['soul'] . ''. ($spell ['premium'] == 1 ? 'yes' : 'no') .''; $showed_vocations = 0; foreach($spell_vocations as $spell_vocation) { if(isset($config_vocations[$spell_vocation])) { echo $config_vocations[$spell_vocation]; $showed_vocations++; } if($showed_vocations != count($spell_vocations)) echo '
'; } echo '