database tools improvement: creature

This commit is contained in:
Tobi 2014-10-19 00:36:01 +02:00
parent 831e14e270
commit 9eba891eb6
22 changed files with 377 additions and 83 deletions

View File

@ -2,7 +2,6 @@
SYSTEM\autoload::registerFolder(dirname(__FILE__).'','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_server_handling','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_command','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_creature','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_event','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_gossip','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_item','');

View File

@ -1,7 +1,7 @@
<?php
\SYSTEM\SAI\sai::register('saimod_mojotrollz_server_handling');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_command');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_creature');
require_once dirname(__FILE__).'/saimod_mojotrollz_db_creature/autoload.inc.php';
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_event');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_gossip');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_item');
@ -13,3 +13,4 @@
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_reputation');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_script');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_spell');
require_once dirname(__FILE__).'/saimod_mojotrollz_import/autoload.inc.php';

View File

@ -0,0 +1,4 @@
<?php
SYSTEM\autoload::registerFolder(dirname(__FILE__),'');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/qq','DBD');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_creature');

View File

@ -0,0 +1,4 @@
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1200, 42, 0, 0, 'saimod_mojotrollz_db_creature', 'action', NULL);
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1210, 42, 3, 1200, 'search', 'search', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1215, 42, 3, 1200, 'creature', 'id', 'UINT');

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class DB_CREATURE_TEMPLATE_CREATURE extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT * FROM creature_template WHERE `Entry` = ?;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class DB_CREATURE_TEMPLATE_CREATURE_CREATURE extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT * FROM creature WHERE `id` = ?;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class DB_CREATURE_TEMPLATE_CREATURE_INVOLVEMENT_RELATION extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT * FROM creature_involvedrelation WHERE `id` = ?;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class DB_CREATURE_TEMPLATE_CREATURE_LINKING_TEMPLATE extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT * FROM creature_linking_template WHERE `Entry` = ?;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class DB_CREATURE_TEMPLATE_CREATURE_LOOT extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT * FROM creature_loot_template WHERE `Entry` = ?;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class DB_CREATURE_TEMPLATE_CREATURE_ONKILL_REPUTATION extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT * FROM creature_onkill_reputation WHERE `creature_id` = ?;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class DB_CREATURE_TEMPLATE_CREATURE_QUESTRELATION extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT * FROM creature_questrelation WHERE `id` = ?;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class DB_CREATURE_TEMPLATE_CREATURE_TEMPLATE_ADDON extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT * FROM creature_template_addon WHERE `Entry` = ?;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class DB_CREATURE_TEMPLATE_CREATURE_TEMPLATE_SPELLS extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT * FROM creature_template_spells WHERE `Entry` = ?;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class DB_CREATURE_TEMPLATE_SEARCH extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT * FROM creature_template WHERE `Entry` LIKE ? OR `Name` LIKE ? OR `Subname` LIKE ? LIMIT 100;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1,13 @@
function init_saimod_mojotrollz_db_creature(){
$('#search').click(function(e){
e.preventDefault();
$('#content-wrapper').load(SAI_ENDPOINT + 'sai_mod=saimod_mojotrollz_db_creature&action=search&search=' + $('#filter').val(),function(){
init_saimod_mojotrollz_db_creature();
});
});
$('.sai_table_row').click(function(){
$('#content-wrapper').load(SAI_ENDPOINT + 'sai_mod=saimod_mojotrollz_db_creature&action=creature&id=' + $(this).attr('sai_table_row'),function(){
});
});
}

View File

@ -1,84 +1,154 @@
<?php
class saimod_mojotrollz_db_creature extends \SYSTEM\SAI\SaiModule {
public static function sai_mod_saimod_mojotrollz_db_creature(){
$con = new \SYSTEM\DB\Connection(new \DBD\mangos_world());
$res = $con->query('SELECT * FROM creature_template LIMIT 100;');
public static function sai_mod_saimod_mojotrollz_db_creature_action_search($search){
return self::sai_mod_saimod_mojotrollz_db_creature('%'.$search.'%');}
$result = '<table><tr>
<th>entry</th>
<th>modelid_1</th>
<th>modelid_2</th>
<th>name</th>
<th>subname</th>
<th>minlevel</th>
<th>maxlevel</th>
<th>faction_A</th>
<th>faction_H</th>
<th>npcflag</th>
<th>rank</th>
<th>unit_class</th>
<th>unit_flags</th>
<th>dynamicflags</th>
<th>family</th>
<th>trainer_type</th>
<th>trainer_spell</th>
<th>trainer_class</th>
<th>trainer_race</th>
<th>type</th>
<th>type_flags</th>
<th>AIName</th>
<th>MovementType</th>
<th>InhabitType</th>
<th>Civilian</th>
<th>RacialLeader</th>
<th>equipment_id</th>
<th>trainer_id</th>
<th>vendor_id</th>
<th>flags_extra</th>
<th>ScriptName</th>
</tr>';
public static function sai_mod_saimod_mojotrollz_db_creature_action_creature($id){
$def = array('additional_tables' => array( '\DBD\DB_CREATURE_TEMPLATE_CREATURE_LOOT' => array('key' => 'LootId', 'caption' => 'Loot'),
'\DBD\DB_CREATURE_TEMPLATE_CREATURE_TEMPLATE_ADDON' => array('key' => 'Entry', 'caption' => 'Template Addon'),
'\DBD\DB_CREATURE_TEMPLATE_CREATURE_TEMPLATE_SPELLS' => array('key' => 'Entry', 'caption' => 'Template Spells'),
'\DBD\DB_CREATURE_TEMPLATE_CREATURE_QUESTRELATION' => array('key' => 'Entry', 'caption' => 'Questrelation'),
'\DBD\DB_CREATURE_TEMPLATE_CREATURE_ONKILL_REPUTATION' => array('key' => 'Entry', 'caption' => 'Onkill Reputation'),
'\DBD\DB_CREATURE_TEMPLATE_CREATURE_LINKING_TEMPLATE' => array('key' => 'Entry', 'caption' => 'Linking Template'),
'\DBD\DB_CREATURE_TEMPLATE_CREATURE_INVOLVEMENT_RELATION' => array('key' => 'Entry', 'caption' => 'Involvement Relation'),
'\DBD\DB_CREATURE_TEMPLATE_CREATURE_CREATURE' => array('key' => 'Entry', 'caption' => 'Spawns'),));
$result = '<table class="sai_table">';
$base_row = \DBD\DB_CREATURE_TEMPLATE_CREATURE::Q1(array($id));
foreach($base_row as $key=>$value){
$result .= '<tr><td>'.$key.'</td><td>'.$value.'</td></tr>';}
$result .= '</table>';
foreach($def['additional_tables'] as $key=>$value){
$result .= '<h4>'.$value['caption'].'</h4><table class="sai_table">';
$res = \call_user_func($key.'::QQ',array($base_row[$value['key']]));
$first = true;
while($row = $res->next()){
$result .= '<tr>
<td>'.$row['Entry'].'</td>
<td>'.$row['modelid_1'].'</td>
<td>'.$row['modelid_2'].'</td>
<td>'.$row['name'].'</td>
<td>'.$row['subname'].'</td>
<td>'.$row['minlevel'].'</td>
<td>'.$row['maxlevel'].'</td>
<td>'.$row['faction_A'].'</td>
<td>'.$row['faction_H'].'</td>
<td>'.$row['npcflag'].'</td>
<td>'.$row['rank'].'</td>
<td>'.$row['unit_class'].'</td>
<td>'.$row['unit_flags'].'</td>
<td>'.$row['dynamicflags'].'</td>
<td>'.$row['family'].'</td>
<td>'.$row['trainer_type'].'</td>
<td>'.$row['trainer_spell'].'</td>
<td>'.$row['trainer_class'].'</td>
<td>'.$row['trainer_race'].'</td>
<td>'.$row['type'].'</td>
<td>'.$row['type_flags'].'</td>
<td>'.$row['AIName'].'</td>
<td>'.$row['MovementType'].'</td>
<td>'.$row['InhabitType'].'</td>
<td>'.$row['Civilian'].'</td>
<td>'.$row['RacialLeader'].'</td>
<td>'.$row['equipment_id'].'</td>
<td>'.$row['trainer_id'].'</td>
<td>'.$row['vendor_id'].'</td>
<td>'.$row['mechanic_immune_mask'].'</td>
<td>'.$row['flags_extra'].'</td>
<td>'.$row['ScriptName'].'</td>
</tr>';
if($first){
$result .= '<tr>';
foreach($row as $key=>$value){
$result .= '<th>'.$key.'</th>';}
$result .= '</tr>';
}
$result .= '<tr>';
foreach($row as $key=>$value){
$result .= '<td>'.$value.'</td>';}
$result .= '</tr>';
$first = false;
}
$result .= '</table>';
return $result;}
}
return $result;
}
public static function sai_mod_saimod_mojotrollz_db_creature($search='%'){
$subdef = array( 'key' => 'Entry'); //table identifier
$def = array( 'Entry' => array('caption' => 'ID'),
'ModelId1' => array('hidden' => false),
'ModelId2' => array('hidden' => false),
'Scale' => array('hidden' => true),
'Family' => array('hidden' => false),
'CreatureType' => array('hidden' => true),
'InhabitType' => array('hidden' => true),
'RegenerateHealth' => array('hidden' => true),
'RacialLeader' => array('hidden' => true),
'NpcFlags' => array('hidden' => true),
'UnitFlags' => array('hidden' => true),
'DynamicFlags' => array('hidden' => true),
'ExtraFlags' => array('hidden' => true),
'CreatureTypeFlags' => array('hidden' => true),
'SpeedWalk' => array('hidden' => true),
'SpeedRun' => array('hidden' => true),
'HealthMultiplier' => array('hidden' => true),
'ManaMultiplier' => array('hidden' => true),
'DamageMultiplier' => array('hidden' => true),
'DamageVariance' => array('hidden' => true),
'ArmorMultiplier' => array('hidden' => true),
'ExperienceMultiplier' => array('hidden' => true),
'MinLevelHealth' => array('hidden' => true),
'MaxLevelHealth' => array('hidden' => true),
'MinLevelMana' => array('hidden' => true),
'MaxLevelMana' => array('hidden' => true),
'MinMeeleDmg' => array('hidden' => true),
'MaxMeeleDmg' => array('hidden' => true),
'MinRangedDmg' => array('hidden' => true),
'MaxRangedDmg' => array('hidden' => true),
'Armor' => array('hidden' => true),
'MeeleAttackPower' => array('hidden' => true),
'RangedAttackPower' => array('hidden' => true),
'MeeleBaseAttackTime' => array('hidden' => true),
'MaxMeleeDmg' => array('hidden' => true),
'MeleeAttackPower' => array('hidden' => true),
'RangedBaseAttackTime' => array('hidden' => true),
'DamageSchool' => array('hidden' => true),
'MinLootGold' => array('hidden' => true),
'MaxLootGold' => array('hidden' => true),
'LootId' => array('hidden' => false),
'PickpocketLootId' => array('hidden' => false),
'SkinningLootId' => array('hidden' => false),
'KillCredit1' => array('hidden' => true),
'KillCredit2' => array('hidden' => true),
'MechanicImmuneMask' => array('hidden' => true),
'MinMeleeDmg' => array('hidden' => true),
'MeleeBaseAttackTime' => array('hidden' => true),
'ResistanceHoly' => array('hidden' => true),
'ResistanceFire' => array('hidden' => true),
'ResistanceNature' => array('hidden' => true),
'ResistanceFrost' => array('hidden' => true),
'ResistanceShadow' => array('hidden' => true),
'ResistanceArcane' => array('hidden' => true),
'PetSpellDataId' => array('hidden' => true),
'MovementType' => array('hidden' => true),
'TrainerType' => array('hidden' => true),
'TrainerSpell' => array('hidden' => true),
'TrainerClass' => array('hidden' => true),
'TrainerRace' => array('hidden' => true),
'TrainerTemplateId' => array('hidden' => true),
'VendorTemplateId' => array('hidden' => true),
'GossipMenuId' => array('hidden' => true),
'EquipmentTemplateId' => array('hidden' => true),
'Civilian' => array('hidden' => true),
'AIName' => array('hidden' => true),
'ScriptName' => array('hidden' => false),
);
$res = \DBD\DB_CREATURE_TEMPLATE_SEARCH::QQ(array($search,$search,$search));
$result = '<input id="filter" type="text"/><button class="btn btn-primary" type="button" id="search">Search</button>';
$result .= '<table class="sai_table"><tr>';
$result_body = '<tr>';
$first = true;
while($row = $res->next()){
$result_body .= '<tr class="sai_table_row" sai_table_row="'.$row[$subdef['key']].'">';
foreach($row as $key=>$data){
//hidden
if( array_key_exists($key, $def) &&
array_key_exists('hidden',$def[$key]) &&
$def[$key]['hidden']){
continue;
}
if($first){
if( array_key_exists($key, $def) &&
array_key_exists('caption',$def[$key])){
$key = $def[$key]['caption'];
}
$result .= '<th>'.$key.'</th>';}
$result_body .= '<td>'.$data.'</td>';
}
$first=false;
$result_body .= '</tr>';
}
$result .= '</tr>'.$result_body;
$result .= '</table>';
return $result;
}
public static function html_li_menu(){return '<li><a href="#" saimenu="saimod_mojotrollz_db_creature">DB:Creatures</a></li><li class="divider"></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function sai_mod_saimod_mojotrollz_db_creature_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array());}
public static function sai_mod_saimod_mojotrollz_db_creature_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array(
\SYSTEM\WEBPATH(new PSAI(),'saimod_mojotrollz_db_creature/saimod_mojotrollz_db_creature.js')));}
public static function sai_mod_saimod_mojotrollz_db_creature_flag_css(){}
}

View File

@ -0,0 +1,3 @@
<?php
SYSTEM\autoload::registerFolder(dirname(__FILE__),'');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_import');

View File

@ -0,0 +1,13 @@
function init_saimod_mojotrollz_import(){
$('#import').click(function(){
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: 'saimod_mojotrollz_import',
action: 'import'
},
type: 'POST',
});
});
}

View File

@ -0,0 +1,16 @@
<?php
class saimod_mojotrollz_import extends \SYSTEM\SAI\SaiModule {
public static function sai_mod_saimod_mojotrollz_import(){
$vars = array();
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/saimod_mojotrollz_import.tpl', $vars);}
public static function html_li_menu(){return '<li><a href="#" saimenu="saimod_mojotrollz_import">Import</a></li><li class="divider"></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function sai_mod_saimod_mojotrollz_import_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array(
\SYSTEM\WEBPATH(new PSAI(),'saimod_mojotrollz_import/saimod_mojotrollz_import.js')
));}
public static function sai_mod_saimod_mojotrollz_import_flag_css(){}
public static function sai_mod_saimod_mojotrollz_import_action_import(){
return client::import('127.0.0.1');}
}

View File

@ -0,0 +1,2 @@
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1100, 42, 0, 0, 'saimod_mojotrollz_import', 'action', NULL);

View File

@ -0,0 +1,6 @@
<div class="panel panel-default">
<div class="panel-heading"><h4>Import</h4></div>
<div class="panel-body">
<button id="import" class="btn">import char</button>
</div>
</div>

View File

@ -39,10 +39,43 @@ function init_saimod_mojotrollz_server_handling(){
action: 'worldstop'
},
type: 'POST',
});
update_worldstatus();
});
$('#update').click(function(){
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: 'saimod_mojotrollz_server_handling',
action: 'update'
},
type: 'POST',
});
update_realmstatus();
update_worldstatus();
});
$('#rights').click(function(){
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: 'saimod_mojotrollz_server_handling',
action: 'rights'
},
type: 'POST',
});
});
$('#deploy').click(function(){
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: 'saimod_mojotrollz_server_handling',
action: 'deploy'
},
type: 'POST',
});
update_realmstatus();
update_worldstatus();
});
}
function update_realmstatus(){