2016-09-01 12:15:17 +02:00
|
|
|
<?php
|
|
|
|
chdir(__DIR__);
|
|
|
|
|
2016-09-01 17:35:43 +02:00
|
|
|
// define('APPLICATION_ENV', 'development');
|
2016-09-01 17:33:00 +02:00
|
|
|
|
2016-09-01 12:15:17 +02:00
|
|
|
require_once __DIR__ . "/../bootstrap.php";
|
|
|
|
|
2016-09-17 23:32:42 +02:00
|
|
|
error_reporting(E_ALL);
|
2016-09-17 23:35:26 +02:00
|
|
|
ini_set('display_errors',1);
|
2016-09-01 12:15:17 +02:00
|
|
|
// Show table creation statements
|
|
|
|
// And (re)generate Proxies
|
|
|
|
|
2016-09-01 12:25:51 +02:00
|
|
|
$em = EmotionHero\Application::getInstance()->getEm();
|
2016-09-01 12:15:17 +02:00
|
|
|
|
|
|
|
var_dump($em->getConnection()->getDatabasePlatform()->getName());
|
|
|
|
// $serializer = JMS\Serializer\SerializerBuilder::create()->build();
|
|
|
|
|
|
|
|
$metadatas = $em->getMetadataFactory()->getAllMetadata();
|
|
|
|
// $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
|
|
|
|
$destPath = $em->getConfiguration()->getProxyDir();
|
|
|
|
$em->getProxyFactory()->generateProxyClasses($metadatas, $destPath);
|
|
|
|
|
|
|
|
|
|
|
|
$tool = new Doctrine\ORM\Tools\SchemaTool($em);
|
|
|
|
|
|
|
|
$classes = $metadatas;
|
|
|
|
|
|
|
|
|
|
|
|
// $classes = array(
|
|
|
|
// $em->getClassMetadata('EmotionHero\Models\Emotion'),
|
|
|
|
// );
|
|
|
|
|
|
|
|
// $tool->getCreateDatabaseSQL();
|
|
|
|
$queries = $tool->getCreateSchemaSQL($classes);
|
|
|
|
// $queries = $tool->getUpdateSchemaSql($classes);
|
|
|
|
foreach($queries as $sql){ echo "$sql;\n"; }
|
|
|
|
// updateSchema
|
|
|
|
$tool->updateSchema($classes);
|
|
|
|
|
2016-10-05 21:42:27 +02:00
|
|
|
$em->getConnection()->query("
|
|
|
|
CREATE TABLE IF NOT EXISTS `TokenBucket` (
|
|
|
|
`name` varchar(128) NOT NULL,
|
|
|
|
`value` varchar(255) NOT NULL
|
|
|
|
) ENGINE=MEMORY DEFAULT CHARSET=utf8;
|
|
|
|
|
|
|
|
ALTER TABLE `TokenBucket`
|
|
|
|
ADD PRIMARY KEY (`name`);
|
|
|
|
");
|
|
|
|
|
2016-09-04 13:41:59 +02:00
|
|
|
|
2016-09-01 17:33:00 +02:00
|
|
|
// ADD EMOTIONS
|
|
|
|
|
|
|
|
$emotions = [];
|
|
|
|
try {
|
|
|
|
$emos = ['anger','contempt','disgust', 'fear', 'joy','sadness','surprise'];
|
|
|
|
foreach($emos as $emo) {
|
|
|
|
$emotion = $em->getRepository(EmotionHero\Models\Emotion::class)->findOneBy(['name' => $emo]);
|
|
|
|
if(empty($emotion))
|
|
|
|
{
|
|
|
|
$emotion = new EmotionHero\Models\Emotion();
|
|
|
|
$emotion->setName($emo);
|
|
|
|
$em->persist($emotion);
|
|
|
|
}
|
|
|
|
$emotions[$emo] = $emotion;
|
|
|
|
|
|
|
|
}
|
|
|
|
$em->flush();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
echo "\nEmotions Probably already inserted...\n";
|
2016-09-01 12:15:17 +02:00
|
|
|
}
|
|
|
|
|
2016-09-17 21:08:09 +02:00
|
|
|
|
2016-09-21 17:40:19 +02:00
|
|
|
/*
|
|
|
|
Already there
|
2016-09-17 21:08:09 +02:00
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
|
|
$lvl->setId(5);
|
|
|
|
$lvl->setName("Welcome to the seven");
|
|
|
|
$i = 2;
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $i++);
|
|
|
|
$i++;
|
|
|
|
$i++;
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $i++);
|
|
|
|
$i++;
|
|
|
|
$i++;
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, $i++);
|
|
|
|
$i++;
|
|
|
|
$i++;
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $i++);
|
|
|
|
$i++;
|
|
|
|
$i++;
|
|
|
|
$lvl->createTarget($emotions['disgust'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 100, $i++);
|
|
|
|
$i++;
|
|
|
|
$i++;
|
|
|
|
$lvl->createTarget($emotions['contempt'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 100, $i++);
|
|
|
|
$i++;
|
|
|
|
$i++;
|
|
|
|
$lvl->createTarget($emotions['fear'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['fear'], 100, $i++);
|
|
|
|
$lvl->createTarget($emotions['fear'], 100, $i++);
|
2016-10-05 21:42:27 +02:00
|
|
|
$em->persist($lvl);
|
2016-09-17 21:08:09 +02:00
|
|
|
|
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
|
|
$lvl->setId(6);
|
|
|
|
$lvl->setName("\"Smile like you mean it\"");
|
|
|
|
|
2016-09-21 17:40:19 +02:00
|
|
|
$s = 2;
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $s++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $s++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 50, $s++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 50, $s++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 30, $s++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 30, $s++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 50, $s++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 50, $s++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $s++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $s++);
|
|
|
|
|
|
|
|
$s++;
|
|
|
|
$s++;
|
|
|
|
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $s++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $s++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 50, $s++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 50, $s++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $s++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $s++);
|
|
|
|
|
|
|
|
$s++;
|
|
|
|
$s++;
|
|
|
|
$s++;
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $s++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $s);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $s++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $s);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $s++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 50, $s);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 30, $s);
|
|
|
|
|
|
|
|
$s++;
|
|
|
|
$s++;
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $s++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 1, $s);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 1, $s);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 1, $s);
|
|
|
|
|
|
|
|
$s++;
|
|
|
|
$s++;
|
|
|
|
$lvl->createTarget($emotions['disgust'], 1, $s++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 1, $s);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $s);
|
|
|
|
|
|
|
|
// setMinimumScoreFromPercentage(40);
|
|
|
|
// minimumAchievements = 2;
|
|
|
|
// achievements.add(achievementCollection.get(5));
|
|
|
|
// achievements.add(achievementCollection.get(6));
|
|
|
|
// achievements.add(achievementCollection.get(7));
|
|
|
|
// break;
|
|
|
|
$em->persist($lvl);
|
|
|
|
|
2016-09-17 21:08:09 +02:00
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
|
|
$lvl->setId(7);
|
|
|
|
$lvl->setName("\"Let's talk business\"");
|
|
|
|
|
2016-09-21 17:40:19 +02:00
|
|
|
$b = 2;
|
|
|
|
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, $b++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, $b++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 50, $b++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 50, $b++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 30, $b++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 30, $b++);
|
|
|
|
$b++;
|
|
|
|
$lvl->createTarget($emotions['disgust'], 100, $b++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 50, $b++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 50, $b++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 30, $b++);
|
|
|
|
$b++;
|
|
|
|
$lvl->createTarget($emotions['contempt'], 100, $b++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 50, $b++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 50, $b++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 30, $b++);
|
|
|
|
$b++;
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $b++);
|
|
|
|
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $b++);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 50, $b);
|
|
|
|
|
|
|
|
$lvl->createTarget($emotions['joy'], 50, $b++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 50, $b++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 30, $b++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 100, $b++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $b++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $b++);
|
|
|
|
|
|
|
|
$b++;
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $b++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 10, $b++);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $b++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 10, $b++);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $b++);
|
|
|
|
$lvl->createTarget($emotions['anger'], 10, $b++);
|
|
|
|
|
|
|
|
$em->persist($lvl);
|
|
|
|
|
|
|
|
// setMinimumScoreFromPercentage(40);
|
|
|
|
// minimumAchievements = 2;
|
|
|
|
// achievements.add(achievementCollection.get(8));
|
|
|
|
// achievements.add(achievementCollection.get(9));
|
|
|
|
// achievements.add(achievementCollection.get(10));
|
|
|
|
// break;
|
|
|
|
|
2016-09-17 21:08:09 +02:00
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
|
|
$lvl->setId(8);
|
|
|
|
$lvl->setName("Show me what you really feel");
|
2016-09-21 17:40:19 +02:00
|
|
|
$r = 2;
|
|
|
|
$lvl->createTarget($emotions['fear'], 100, $r++);
|
|
|
|
$lvl->createTarget($emotions['fear'], 50, $r++);
|
|
|
|
$lvl->createTarget($emotions['fear'], 30, $r++);
|
|
|
|
|
|
|
|
$r++;
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $r++);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 50, $r++);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $r++);
|
|
|
|
|
|
|
|
$r++;
|
|
|
|
$lvl->createTarget($emotions['disgust'], 100, $r++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 100, $r++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 50, $r++);
|
|
|
|
|
|
|
|
$r++;
|
|
|
|
$lvl->createTarget($emotions['disgust'], 100, $r++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 30, $r);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 50, $r++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 50, $r);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 30, $r++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 100, $r);
|
|
|
|
|
|
|
|
$r++;
|
|
|
|
$r++;
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $r++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 50, $r++);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $r++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 50, $r++);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 50, $r++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $r++);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 50, $r++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $r);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $r++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 50, $r);
|
|
|
|
|
|
|
|
|
|
|
|
$em->persist($lvl);
|
|
|
|
// setMinimumScoreFromPercentage(40);
|
|
|
|
// minimumAchievements = 2;
|
|
|
|
// achievements.add(achievementCollection.get(11));
|
|
|
|
// achievements.add(achievementCollection.get(12));
|
|
|
|
// achievements.add(achievementCollection.get(13));
|
|
|
|
// achievements.add(achievementCollection.get(14));
|
|
|
|
|
|
|
|
// break;
|
2016-09-17 21:08:09 +02:00
|
|
|
|
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
|
|
$lvl->setId(9);
|
|
|
|
$lvl->setName("Please act normally");
|
|
|
|
|
2016-09-21 17:40:19 +02:00
|
|
|
$a = 2;
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, $a++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 100, $a++);
|
|
|
|
$lvl->createTarget($emotions['fear'], 100, $a++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, $a++);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, $a++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, $a++);
|
|
|
|
|
|
|
|
$a++;
|
|
|
|
$lvl->createTarget($emotions['anger'], 30, $a++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 30, $a+=0.5);
|
|
|
|
$lvl->createTarget($emotions['fear'], 30, $a+=0.5);
|
|
|
|
$lvl->createTarget($emotions['joy'], 30, $a+=0.5);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 30, $a+=0.5);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 30, $a+=0.5);
|
|
|
|
|
|
|
|
$a++;
|
|
|
|
$lvl->createTarget($emotions['anger'], 30, $a++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 30, $a);
|
|
|
|
$lvl->createTarget($emotions['anger'], 30, $a++);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 30, $a);
|
|
|
|
|
|
|
|
$lvl->createTarget($emotions['fear'], 30, $a++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 30, $a);
|
|
|
|
$lvl->createTarget($emotions['fear'], 30, $a++);
|
|
|
|
$lvl->createTarget($emotions['joy'], 30, $a);
|
|
|
|
|
|
|
|
$lvl->createTarget($emotions['sadness'], 30, $a++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 30, $a);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 30, $a++);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 30, $a);
|
|
|
|
|
|
|
|
$a++;
|
|
|
|
$a++;
|
|
|
|
$lvl->createTarget($emotions['disgust'], 20, $a++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 20, $a);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 20, $a);
|
|
|
|
|
|
|
|
$lvl->createTarget($emotions['disgust'], 10, $a++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 10, $a);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 10, $a);
|
|
|
|
|
|
|
|
$lvl->createTarget($emotions['disgust'], 10, $a++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 10, $a);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 10, $a);
|
|
|
|
|
|
|
|
// Kuleshov's target:
|
|
|
|
// use 3% instead of 0.2% as it otherwise becomes invisible!
|
|
|
|
$lvl->createTarget($emotions['disgust'], 3, $a++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 3, $a);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 3, $a);
|
|
|
|
// END OF KULESHOV
|
|
|
|
|
|
|
|
$lvl->createTarget($emotions['disgust'], 3, $a++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 3, $a);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 3, $a);
|
|
|
|
|
|
|
|
|
|
|
|
$lvl->createTarget($emotions['anger'], 1, $a++);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 1, $a);
|
|
|
|
$lvl->createTarget($emotions['disgust'], 1, $a);
|
|
|
|
$lvl->createTarget($emotions['fear'], 1, $a);
|
|
|
|
$lvl->createTarget($emotions['joy'], 1, $a);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 1, $a);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 1, $a);
|
|
|
|
|
|
|
|
$em->persist($lvl);
|
|
|
|
|
2016-10-05 21:42:27 +02:00
|
|
|
*/
|
2016-09-21 17:40:19 +02:00
|
|
|
|
2016-09-17 21:08:09 +02:00
|
|
|
$em->flush();
|
|
|
|
die();
|
2016-10-05 21:42:27 +02:00
|
|
|
|
2016-09-01 17:33:00 +02:00
|
|
|
// TEST USER
|
2016-10-05 21:42:27 +02:00
|
|
|
die();
|
2016-09-01 17:33:00 +02:00
|
|
|
if(empty($em->getRepository(EmotionHero\Models\User::class)->findOneBy([]))) {
|
|
|
|
$user = new EmotionHero\Models\User();
|
|
|
|
$em->persist($user);
|
|
|
|
|
|
|
|
$em->flush();
|
|
|
|
}
|
2016-09-01 12:15:17 +02:00
|
|
|
|