Example #1
0
 public static function check($event = false)
 {
     require_once 'Cause.class.php';
     require_once 'Effect.class.php';
     global $conf;
     $causeManager = new Cause();
     $effectManager = new Effect();
     $causes = array();
     $storyCauses = $causeManager->loadAll(array('story' => $event->story));
     $validate = $event->story;
     foreach ($storyCauses as $storyCause) {
         switch ($storyCause->type) {
             case 'listen':
                 if ($event->type == $storyCause->type) {
                     if ($storyCause->value != $event->value) {
                         $validate = false;
                     }
                 }
                 break;
             case 'time':
                 list($i, $h, $d, $m, $y) = explode('-', date('i-H-d-m-Y'));
                 list($i2, $h2, $d2, $m2, $y2) = explode('-', $storyCause->value);
                 if ($storyCause->value != $i . '-' . $h . '-' . $d . '-' . $m . '-' . $y) {
                     $validate = false;
                 }
                 if (!(($i == $i2 || $i2 == '*') && ($h == $h2 || $h2 == '*') && ($d == $d2 || $d2 == '*') && ($m == $m2 || $m2 == '*') && ($y == $y2 || $y2 == '*'))) {
                     $validate = false;
                 }
                 break;
             case 'readvar':
                 if ($conf->get($storyCause->target, 'var') != $storyCause->value) {
                     $validate = false;
                 }
                 break;
         }
     }
     if ($validate != false) {
         //consequences
         $effects = $effectManager->loadAll(array('story' => $event->story), 'sort');
         foreach ($effects as $effect) {
             switch ($effect->type) {
                 case 'command':
                     exec($effect->value);
                     break;
                 case 'var':
                     $conf->put($effect->target, $effect->value, 'var');
                     break;
                 case 'actuator':
                     file_get_contents('action.php?action=' . $effect->value);
                     break;
                 case 'sleep':
                     if (is_numeric($effect->value)) {
                         sleep($effect->value);
                     }
                     break;
                 case 'talk':
                     $clientManager = new Client();
                     $clients = $clientManager->populate();
                     foreach ($clients as $client) {
                         $client->talk($effect->value);
                     }
                     break;
             }
         }
     }
     /*
     		$manager = new Story();
     
     		//get all dictionnary values
     		$query = '
     		SELECT * FROM plugin_story_cause WHERE story = (SELECT story.id FROM plugin_story story 
     		LEFT JOIN plugin_story_cause cause ON story.id = cause.story)';
     
     		$storyToCheck = array();
     		
     		$results = $manager->customQuery($query);
     		while($result = $results->fetchArray()){
     			$storyToCheck[$result['story']][] = $result;
     		}
     		
     		if(count($storyToCheck)!=0){
     			foreach($storyToCheck as $story=>$causes){
     				//On part du principe que le scénario est validé tant qu'aucune cause manquante ne viens la contredire
     				$activateStory = true;
     				//On vas checker toutes les causes de ce scenario 
     				foreach($causes as $cause){
     					$validateCause = false;
     					switch($cause['type']){
     						case 'listen':
     							if($cause['value'] == $dic['lastphrase'])
     								$validateCause = true;
     							if($cause['operator']=='!=') $validateCause = !$validateCause;
     						break;
     						case 'readvar':
     						break;
     						case 'event':
     						break;
     						case 'time':
     							list($i2,$h2,$d2,$m2,$y2) = explode('-',$cause['value']);
     							if (
     								($i == $i2 || $i2 == '*') && 
     								($h == $h2 || $h2 == '*') && 
     								($d == $d2 || $d2 == '*') && 
     								($m == $m2 || $m2 == '*') && 
     								($y == $y2 || $y2 == '*')
     							)
     								$validateCause = true;
     							
     							if($cause['operator']=='!=') $validateCause = !$validateCause;
     							
     						break;
     					}
     					$activateStory = $activateStory && $validateCause;
     					
     					var_dump($cause);
     				}
     				if($activateStory) var_dump('story validated !');
     			}
     		
     		}*/
 }
Example #2
0
function story_vocal_command(&$response, $actionUrl)
{
    global $conf;
    require_once dirname(__FILE__) . '/Cause.class.php';
    $causeManager = new Cause();
    $vocals = $causeManager->loadAll(array('type' => 'listen'));
    foreach ($vocals as $vocal) {
        $response['commands'][] = array('command' => $conf->get('VOCAL_ENTITY_NAME') . ' ' . $vocal->value, 'url' => $actionUrl . '?action=plugin_story_check&type=talk&event=' . $vocal->id, 'confidence' => '0.90' + $conf->get('VOCAL_SENSITIVITY'));
    }
}
	                	<input type="hidden" name="artist">
	                	<input type="hidden" name="disagree">
	                	<input type="hidden" id="cause" name="cause" value="0">
	                	<button class="btn btn-danger dropdown-toggle" data-toggle="dropdown" type="button" title="Wrong informations" <?php 
    print $artist->isDisagreedBy($_SESSION['user']->getId()) ? 'disabled' : '';
    ?>
>
	                         <span class="glyphicon glyphicon-ban-circle"> <?php 
    print NotarizeArtist::countDisagreeByArtist($artist->getId());
    ?>
</span>
	                	         <span class="caret"></span>
	                	</button>
	                	<ul class="dropdown-menu" role="menu">
	                        <?php 
    foreach (Cause::all() as $cause) {
        if ((int) $cause->getId() !== 7) {
            ?>
	                    		<li><a href="#" onclick="javascript:$('#cause').val('<?php 
            print $cause->getId();
            ?>
'); $('#notarizeDisagree').submit();"><?php 
            print $cause;
            ?>
</a></li>
	                        <?php 
        }
    }
    ?>
	                	</ul>
	                </form>
Example #4
0
<?php

$story = new Story();
$cause = new Cause();
$effect = new Effect();
$causes = array();
$effects = array();
if (isset($_['story'])) {
    $story = $story->getById($_['story']);
    $effects = $effect->loadAll(array('story' => $story->id), 'sort');
    $causes = $cause->loadAll(array('story' => $story->id), 'sort');
}
?>
		
		<div class="story">
		<h1>Nom : <input id="storyName" value="<?php 
echo $story->label;
?>
" placeholder="Scénario 1"/></h1>
		<input type="hidden" id="story" value="<?php 
echo $story->id;
?>
">
		<h2>
			<span id="causePanelButton" class="active" onclick="switchCauseEffect('CAUSE');"><i class="fa fa-puzzle-piece"></i> Causes</span>
			/ 
			<span id="effectPanelButton" onclick="switchCauseEffect('EFFECT');"><i class="fa fa-bolt"></i> Effets</span>
		</h2>
		<div id="causePanel">
			<ul class="toolbar">
				<?php 
Example #5
0
 public static function check($event = false)
 {
     require_once dirname(__FILE__) . '/Cause.class.php';
     require_once dirname(__FILE__) . '/Effect.class.php';
     global $conf;
     $causeManager = new Cause();
     $effectManager = new Effect();
     $causes = array();
     $storyCauses = $causeManager->loadAll(array('story' => $event->story));
     $validate = $event->story;
     foreach ($storyCauses as $storyCause) {
         switch ($storyCause->type) {
             case 'listen':
                 if ($event->type == $storyCause->type) {
                     if ($storyCause->value != $event->value) {
                         $validate = false;
                     }
                 }
                 break;
             case 'time':
                 list($i, $h, $d, $m, $y) = explode('-', date('i-H-d-m-Y'));
                 list($i2, $h2, $d2, $m2, $y2) = explode('-', $storyCause->value);
                 if ($storyCause->value != $i . '-' . $h . '-' . $d . '-' . $m . '-' . $y) {
                     $validate = false;
                 }
                 if (!(($i == $i2 || $i2 == '*') && ($h == $h2 || $h2 == '*') && ($d == $d2 || $d2 == '*') && ($m == $m2 || $m2 == '*') && ($y == $y2 || $y2 == '*'))) {
                     $validate = false;
                 }
                 break;
             case 'readvar':
                 if ($conf->get($storyCause->target, 'var') != $storyCause->value) {
                     $validate = false;
                 }
                 break;
         }
     }
     if ($validate != false) {
         //consequences
         $effects = $effectManager->loadAll(array('story' => $event->story), 'sort');
         foreach ($effects as $effect) {
             switch ($effect->type) {
                 case 'command':
                     exec($effect->value);
                     break;
                 case 'var':
                     $conf->put($effect->target, $effect->value, 'var');
                     break;
                 case 'actuator':
                     file_get_contents('action.php?action=' . $effect->value);
                     break;
                 case 'sleep':
                     if (is_numeric($effect->value)) {
                         sleep($effect->value);
                     }
                     break;
                 case 'talk':
                     $clientManager = new Client();
                     $clients = $clientManager->populate();
                     foreach ($clients as $client) {
                         $client->talk($effect->value);
                     }
                     break;
             }
         }
     }
 }
Example #6
0
?>
">
		<h1>Nom : <input id="storyName" value="<?php 
echo $story->label;
?>
" placeholder="Scénario 1"/></h1>
		
		<h2>
			<span id="causePanelButton" class="active" onclick="switchCauseEffect('CAUSE');"><i class="fa fa-puzzle-piece"></i> Causes</span>
			/ 
			<span id="effectPanelButton" onclick="switchCauseEffect('EFFECT');"><i class="fa fa-bolt"></i> Effets</span>
		</h2>
		<div id="causePanel">
			<ul class="toolbar">
				<?php 
foreach (Cause::types() as $key => $type) {
    echo '<li data-type="' . $key . '" class="' . $key . '"><i class="fa ' . $type['icon'] . '"></i> ' . $type['label'] . '</li>';
}
?>
				<div class="clear"></div>
			</ul>
			<ul class="workspace">
				<li class="union">SI</li>
				<li id="place-0" class="place">&nbsp;</li>
			</ul>
		</div>
		
		
		<div id="effectPanel">
			<ul class="toolbar">
				<?php