359 lines
12 KiB
PHP
359 lines
12 KiB
PHP
<?php
|
|
chdir(__DIR__);
|
|
|
|
// define('APPLICATION_ENV', 'development');
|
|
|
|
require_once __DIR__ . "/../bootstrap.php";
|
|
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors',1);
|
|
// Show table creation statements
|
|
// And (re)generate Proxies
|
|
|
|
$em = EmotionHero\Application::getInstance()->getEm();
|
|
|
|
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);
|
|
|
|
$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`);
|
|
");
|
|
|
|
|
|
// 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";
|
|
}
|
|
|
|
|
|
/*
|
|
Already there
|
|
$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++);
|
|
$em->persist($lvl);
|
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
$lvl->setId(6);
|
|
$lvl->setName("\"Smile like you mean it\"");
|
|
|
|
$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);
|
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
$lvl->setId(7);
|
|
$lvl->setName("\"Let's talk business\"");
|
|
|
|
$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;
|
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
$lvl->setId(8);
|
|
$lvl->setName("Show me what you really feel");
|
|
$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;
|
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
$lvl->setId(9);
|
|
$lvl->setName("Please act normally");
|
|
|
|
$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);
|
|
|
|
*/
|
|
|
|
$em->flush();
|
|
die();
|
|
|
|
// TEST USER
|
|
die();
|
|
if(empty($em->getRepository(EmotionHero\Models\User::class)->findOneBy([]))) {
|
|
$user = new EmotionHero\Models\User();
|
|
$em->persist($user);
|
|
|
|
$em->flush();
|
|
}
|
|
|