saimod quests

This commit is contained in:
Ulf Gebhardt 2014-12-22 06:50:46 +01:00
parent 2104e10e3e
commit c0a1173466
19 changed files with 277 additions and 22 deletions

View File

@ -3,10 +3,10 @@ class tags {
const TAG_TABLE_CREATURE = 1;
const TAG_TABLE_OBJECT = 2;
const TAG_TABLE_ITEM = 3;
const TAG_TABLE_QUESTS = 4;
const TAG_TABLE_SPELLS = 5;
const TAG_TABLE_PLAYERS = 6;
const TAG_TABLE_TOPICS = 7;
const TAG_TABLE_QUEST = 4;
const TAG_TABLE_SPELL = 5;
const TAG_TABLE_PLAYER = 6;
const TAG_TABLE_TOPIC = 7;
public static function statistics($table,$type){
}

View File

@ -0,0 +1,11 @@
<?php
namespace DBD;
class TOOLTIP_QUEST extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
'',
'SELECT entry FROM quest_template WHERE entry = ? LIMIT 1;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1 @@
Quest: ${entry}

View File

@ -16,6 +16,9 @@ class map {
case database_elements::DB_ITEM:
throw new ERROR('Incompatible Type - Item & Position');
case database_elements::DB_QUEST:
if($entry == null){
throw new ERROR('Problem');}
$res = \DBD\MAP_QUESTS_MAPS::QQ(array($entry));
break;
case database_elements::DB_SPELL:
throw new ERROR('Incompatible Type - Spell & Position');
@ -71,7 +74,11 @@ class map {
return JsonResult::toString(\DBD\MAP_CREATURES_MAPS::QA(array($entry)));}
return JsonResult::toString(\DBD\MAP_CREATURES::QA(array($map,$entry)));}
private static function quests($map=null,$entry=null){
}
if($entry == null){
throw new ERROR('Problem');}
if($map == null){
return JsonResult::toString(\DBD\MAP_QUESTS_MAPS::QA(array($entry)));}
return JsonResult::toString(\DBD\MAP_QUESTS::QA(array($map,$entry)));}
public static function zone($map,$x1,$y1){

View File

@ -0,0 +1,15 @@
<?php
namespace DBD;
class MAP_QUESTS extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT guid as id,map,position_x as x,position_y as y,position_z as z,orientation as o, value as map_name FROM gameobject'.
' LEFT JOIN host_mojotrollz.mojotrollz_tags_value ON host_mojotrollz.mojotrollz_tags_value.id = map'.
' WHERE type=1 AND map = ? AND guid=? LIMIT 100;',
new \DBD\mangos_world()
);}}

View File

@ -0,0 +1,15 @@
<?php
namespace DBD;
class MAP_QUESTS_MAPS extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT map, value as map_name FROM gameobject'.
' LEFT JOIN host_mojotrollz.mojotrollz_tags_value ON host_mojotrollz.mojotrollz_tags_value.id = map'.
' WHERE type=1 AND gameobject.id=? GROUP BY map;',
new \DBD\mangos_world()
);}}

View File

@ -5,8 +5,7 @@ SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_server_han
\SYSTEM\SAI\sai::register('saimod_mojotrollz_server_handling');
require_once dirname(__FILE__).'/saimod_mojotrollz_db_creature/autoload.inc';
require_once dirname(__FILE__).'/saimod_mojotrollz_db_item/autoload.inc';
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_quest','');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_quest');
require_once dirname(__FILE__).'/saimod_mojotrollz_db_quest/autoload.inc';
require_once dirname(__FILE__).'/saimod_mojotrollz_db_object/autoload.inc';
require_once dirname(__FILE__).'/saimod_mojotrollz_db_player/autoload.inc';
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_spell','');

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_quest');

View File

@ -0,0 +1,9 @@
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5700, 42, 0, 0, 'saimod_mojotrollz_db_quest', 'action', NULL);
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5710, 42, 3, 5700, 'search', 'search', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5711, 42, 3, 5700, 'search', 'tags', 'JSON');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5715, 42, 3, 5700, 'quest', 'id', 'UINT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5720, 42, 2, 5700, 'tag', 'id', 'UINT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5721, 42, 2, 5700, 'tag', 'tags', 'JSON');

View File

@ -0,0 +1,39 @@
function init_saimod_mojotrollz_db_quest(){
$('#search').click(function(e){
e.preventDefault();
var tags = {};
$('.tag_filter option:selected').each(function(){
var type = $(this).attr('_type');
tags[type] = $(this).val();});
$('#content-wrapper').load(SAI_ENDPOINT + 'sai_mod=saimod_mojotrollz_db_quest&action=search&search=' + $('#filter').val()+'&tags='+ JSON.stringify(tags),function(){
init_saimod_mojotrollz_db_quest();
});
});
$('.wow_quest').click(function(){
load_quest($(this).attr('_id'));
});
}
function load_quest(id){
$('#content-wrapper').load(SAI_ENDPOINT + 'sai_mod=saimod_mojotrollz_db_quest&action=quest&id=' + id,function(){
$('#btn_edit').click(function(e){
e.preventDefault();
var tags = {};
$('.tag_filter option:selected').each(function(){
var type = $(this).attr('_type');
tags[type] = $(this).val();});
$.ajax({ type :'GET',
url : SAI_ENDPOINT+'sai_mod=saimod_mojotrollz_db_quest&action=tag'+
'&id='+id+
'&tags='+JSON.stringify(tags),
success : function(data) {
if(data.status){
load_quest(id);
}else{
alert('Problem: '+data);}
}
});
});
map(4,id);
});
}

View File

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

View File

@ -1,23 +1,99 @@
<?php
class saimod_mojotrollz_db_quest extends \SYSTEM\SAI\SaiModule {
public static function sai_mod_saimod_mojotrollz_db_quest(){
$con = new \SYSTEM\DB\Connection(new \DBD\mangos_world());
$res = $con->query('SELECT * FROM quest_template LIMIT 100;');
$result = '<table><tr>
<th>entry</th>
</tr>';
while($row = $res->next()){
$result .= '<tr>
<td>'.$row['entry'].'</td>
</tr>';
public static function sai_mod_saimod_mojotrollz_db_quest_action_search($search,$tags=null){
return self::sai_mod_saimod_mojotrollz_db_quest($search,$tags);}
public static function sai_mod_saimod_mojotrollz_db_quest_action_tag($id,$tags){
$tags = json_decode($tags,true);
foreach ($tags as $type=>$value){
if($value == -2){
tags::del(tags::TAG_TABLE_QUEST, $id, $type);}
tags::set(tags::TAG_TABLE_QUEST, $id, $type, $value);}
return JsonResult::ok();
}
public static function sai_mod_saimod_mojotrollz_db_quest_action_quest($id){
$vars = array();
$vars['entries'] = $vars['tag_entries'] = '';
$vars['map'] = map::generate(tags::TAG_TABLE_QUEST,$id);
$base_row = \DBD\DB_QUEST_TEMPLATE_QUEST::Q1(array($id));
foreach($base_row as $key=>$value){
$vars['entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_quest/tpl/quest_base.tpl'), array('key' => $key, 'value' => $value));}
//Quest Tags
$tags_res = tags::get(tags::TAG_TABLE_QUEST, $base_row['entry']);
$tags = array();
while($tag = $tags_res->next()){
$tags[$tag['type']] = $tag;}
//Tag Types
$tags_types = tags::get_type(tags::TAG_TABLE_QUEST);
while($tag = $tags_types->next()){
$tag['options'] = '';
$tags_values = tags::get_value($tag['id']);
while($value = $tags_values->next()){
$value['selected'] = '';
if( array_key_exists($value['type'], $tags) &&
$tags[$value['type']]['value'] == $value['id']){
$value['selected'] = 'selected';}
$tag['options'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_quest/tpl/tag_entry_option.tpl'), $value);}
$vars['tag_entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_quest/tpl/tag_quest_entry.tpl'), $tag);}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_quest/tpl/quest.tpl'), $vars);
}
public static function sai_mod_saimod_mojotrollz_db_quest($search='%',$tags=null){
$vars = array();
$vars['search'] = $search;
$vars['entries'] = $vars['tag_entries'] = '';
$tags = json_decode($tags,true);
if(!$tags){
$tags = array();}
$tags_types = tags::get_type(tags::TAG_TABLE_QUEST);
while($tag = $tags_types->next()){
$tag['options'] = '';
$tags_values = tags::get_value($tag['id']);
while($value = $tags_values->next()){
$value['selected'] = '';
if( array_key_exists($value['type'], $tags) &&
$tags[$value['type']] == $value['id']){
$value['selected'] = 'selected';}
$tag['options'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_quest/tpl/tag_entry_option.tpl'), $value);}
$vars['tag_entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_quest/tpl/tag_entry.tpl'), $tag);}
$sql_join = $sql_where = '';
foreach($tags as $type=>$value){
if($value == -1){
continue;}
if($value == -2){
$sql_where .= 'entry NOT IN (SELECT id FROM host_mojotrollz.mojotrollz_tags WHERE `table` = '.tags::TAG_TABLE_QUEST.' AND `type` = '.$type.') AND ';
continue;}
$sql_join .= 'LEFT JOIN host_mojotrollz.mojotrollz_tags as t'.$type.' ON quest_template.entry = t'.$type.'.id ';
$sql_where .= 't'.$type.'.`table` = '.tags::TAG_TABLE_QUEST.' AND t'.$type.'.`type` = '.$type.' AND t'.$type.'.value = '.$value.' AND ';
}
$result .= '</table>';
return $result;}
$con = new \SYSTEM\DB\Connection(new \DBD\mangos_world());
$res = $con->prepare( 'search-quest',
'SELECT quest_template.* FROM quest_template '.
$sql_join.
' WHERE '.$sql_where.
' (`entry` LIKE ? OR `title` LIKE ?) LIMIT 100;',
array($search,$search));
while($row = $res->next()){
$vars['entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_quest/tpl/search_entry.tpl'), $row);}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_quest/tpl/search.tpl'), $vars);
}
public static function html_li_menu(){return '<li><a href="#" saimenu="saimod_mojotrollz_db_quest">DB:Quests</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_quest_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array());}
public static function sai_mod_saimod_mojotrollz_db_quest_flag_css(){}
public static function sai_mod_saimod_mojotrollz_db_quest_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array(
\SYSTEM\WEBPATH(new PAPI(),'database/js/wow.js'),
\SYSTEM\WEBPATH(new PAPI(),'map/js/map.js'),
\SYSTEM\WEBPATH(new PSAI(),'saimod_mojotrollz_db_quest/js/saimod_mojotrollz_db_quest.js')));}
public static function sai_mod_saimod_mojotrollz_db_quest_flag_css(){return \SYSTEM\LOG\JsonResult::toString(array(
\SYSTEM\WEBPATH(new PAPI(),'map/css/map.css')));}
}

View File

@ -0,0 +1,15 @@
<div style="float: left;">
${map}
</div>
<table class="sai_table" style="float: left; margin-left: 25px;">
<tr>
<th>TagType</th>
<th>TagTypeValue</th>
</tr>
${tag_entries}
</table>
<button class="btn btn-danger" type="button" id="btn_edit">Edit</button>
<div style="clear: both"></div>
<table class="sai_table">
${entries}
</table>

View File

@ -0,0 +1,4 @@
<tr>
<td>${key}</td>
<td>${value}</td>
</tr>

View File

@ -0,0 +1,21 @@
<div id="filter_container">
<input id="filter" value="${search}" type="text"/>
<table class="sai_table">
<tr>
<th>TagType</th>
<th>TagTypeValue</th>
</tr>
${tag_entries}
</table>
<button class="btn btn-primary" type="button" id="search">Search</button>
</div>
<hr/>
<table class="sai_table">
<tr>
<th>Entry</th>
<th>Title</th>
<th>Details</th>
<th>Objectives</th>
</tr>
${entries}
</table>

View File

@ -0,0 +1,6 @@
<tr class="wow_quest" _id="${entry}">
<td>${entry}</td>
<td>${Title}</td>
<td>${Details}</td>
<td>${Objectives}</td>
</tr>

View File

@ -0,0 +1,10 @@
<tr>
<td>${name}</td>
<td>
<select class="tag_filter">
<option value="-1" _type="${id}">No Filter</option>
<option value="-2" _type="${id}">No Tag</option>
${options}
</select>
</td>
</tr>

View File

@ -0,0 +1 @@
<option ${selected} _type="${type}" value="${id}">${value}</option>

View File

@ -0,0 +1,9 @@
<tr>
<td>${name}</td>
<td>
<select class="tag_filter">
<option value="-2" _type="${id}">No Tag</option>
${options}
</select>
</td>
</tr>