New Level type inserted

This commit is contained in:
silas 2018-11-05 22:51:55 +01:00
parent 71bde38da4
commit 13b79c1fd1
24 changed files with 8174 additions and 49 deletions

1
.idea/wordRotator.iml generated
View File

@ -3,6 +3,7 @@
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/module/Application/src" isTestSource="false" packagePrefix="Application\" />
<sourceFolder url="file://$MODULE_DIR$/src/module/Application/pwa/public" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/public/js" />
<excludeFolder url="file://$MODULE_DIR$/publicTest" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/event-manager" />

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
cd $(dirname "$0")/..
npm run build 1
npm run build

View File

@ -58,7 +58,7 @@ return [
],
'systemVariables' => array(
'passwordHash' => '',
'passwordHash' => '123',
'websiteName' => '',
'maxAgeOfUserCodes' => 2 //In Tagen
),

View File

@ -1 +1,2 @@
UPDATE Word SET Word.used = 0;
UPDATE Word SET Word.used = 1 WHERE deleted = 0 AND (SELECT count(*) FROM Level WHERE words LIKE CONCAT("%\"", Word.word, "\"%") AND deleted = 0) > 0

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<div class="max-height overflow-hidden"><div id=segment-leaf-template class="segment segment-leaf"><div class=leaf-element></div></div><div id=segment-parent-template class="segment segment-parent"><div class=child-container></div></div><div id=segment-row-template class="segment segment-row"><div class=child-container></div></div><div id=segment-triangle-template class="segment segment-triangle"><div class=child-container></div></div><div id=tutorial-pointer></div><div class="max-height fill-me"><div class="text-right max-width"><button class="button show-while-playing" id=help-button><img src=img/help.png></button></div><div class="height-20 no-transition tutorial-text center flex-center hidden"><div class="step-1 hidden" data-translation=tutorial-step-1></div><div class="step-2 hidden" data-translation=tutorial-step-2></div><div class="step-3 hidden" data-translation=tutorial-step-3></div><div class="step-4 hidden" data-translation=tutorial-step-4></div></div><div class="height-20 show-when-won center flex-center fill-me" style="min-height: 45px"><div class="grow max-width"><b data-translation=won id=won-text></b></div><div id=coin-container><div id=coin-template class=coin style="opacity: 0"><img src=img/coin.png></div></div></div><div class="flex-center level-container grow"><div id=level></div></div><div class="show-when-won flex-center height-20"><button class="button max-width" id=continue-button data-translation=continue></button></div></div><div class=tutorial-blanket></div></div>
<div class="max-height overflow-hidden"><div id=segment-leaf-template class="segment segment-leaf"><div class=leaf-element></div></div><div id=segment-parent-template class="segment segment-parent"><div class=child-container></div></div><div id=segment-row-template class="segment segment-row"><div class=child-container></div></div><div id=segment-column-template class="segment segment-column"><div class=child-container></div></div><div id=segment-triangle-template class="segment segment-triangle"><div class=child-container></div></div><div id=tutorial-pointer></div><div class="max-height fill-me"><div class="text-right max-width"><button class="button show-while-playing" id=help-button><img src=img/help.png></button></div><div class="height-20 no-transition tutorial-text center flex-center hidden"><div class="step-1 hidden" data-translation=tutorial-step-1></div><div class="step-2 hidden" data-translation=tutorial-step-2></div><div class="step-3 hidden" data-translation=tutorial-step-3></div><div class="step-4 hidden" data-translation=tutorial-step-4></div></div><div class="height-20 show-when-won center flex-center fill-me" style="min-height: 45px"><div class="grow max-width"><b data-translation=won id=won-text></b></div><div id=coin-container><div id=coin-template class=coin style="opacity: 0"><img src=img/coin.png></div></div></div><div class="flex-center level-container grow"><div id=level></div></div><div class="show-when-won flex-center height-20"><button class="button max-width" id=continue-button data-translation=continue></button></div></div><div class=tutorial-blanket></div></div>

File diff suppressed because one or more lines are too long

View File

@ -94,10 +94,11 @@ InitPromise.resolve(app).then(async function () {
storageManager.persist();
}
window["applyAndroidBridge"] = AndroidBridge.applyDefinitions;
let wasOpened = (Helper.nonNull(localStorage.getItem('was-open'), "0") === "1");
if (wasOpened){
Promise.all([storageManager.isPersistent(), navigator["serviceWorker"]["ready"]]).then(res => {
console.log("Init part ", res);
if (!res[0]){
FlashMessenger.addMessage("warning-data-not-persistent");
}
@ -106,8 +107,6 @@ InitPromise.resolve(app).then(async function () {
else{
localStorage.setItem("was-open", "1");
}
window["applyAndroidBridge"] = AndroidBridge.applyDefinitions;
});
// console.log("trying push... 1");

View File

@ -6,6 +6,7 @@ import {Matomo, ScaleHelper, SoundManager} from "../../../../../js/lib/pwa-asset
import {EndSite} from "./EndSite";
import {WordRotatorBaseSite} from "./WordRotatorBaseSite";
import {SettingsManager} from "../../../../../js/lib/pwa-core";
import {SimpleFourWordsLevel} from "../wordrotator/Level/SimpleFourWordsLevel";
export class LevelSite extends WordRotatorBaseSite {
constructor(siteManager) {
@ -54,16 +55,19 @@ export class LevelSite extends WordRotatorBaseSite {
let parentSegmentTemplate = this.findBy("#segment-parent-template");
let rowSegmentTemplate = this.findBy("#segment-row-template");
let triangleTemplate = this.findBy("#segment-triangle-template");
let columnTemplate = this.findBy("#segment-column-template");
leafSegmentTemplate.id = null;
parentSegmentTemplate.id = null;
rowSegmentTemplate.id = null;
triangleTemplate.id = null;
leafSegmentTemplate.removeAttribute("id");
parentSegmentTemplate.removeAttribute("id");
rowSegmentTemplate.removeAttribute("id");
triangleTemplate.removeAttribute("id");
columnTemplate.removeAttribute("id");
leafSegmentTemplate.remove();
parentSegmentTemplate.remove();
rowSegmentTemplate.remove();
triangleTemplate.remove();
columnTemplate.remove();
let self = this;
let continueButton = this.findBy("#continue-button");
@ -85,7 +89,7 @@ export class LevelSite extends WordRotatorBaseSite {
this.levelCounterAction.innerText = this.levelCounter;
this.levelNumberScaler = await scaleHelper.scaleToFull(this.levelCounterAction, this.levelCounterActionContainer, false, false, 4);
this.levelCounterActionContainer.classList.add("visible");
this.templateContainer = new TemplateContainer(leafSegmentTemplate, parentSegmentTemplate, rowSegmentTemplate, triangleTemplate);
this.templateContainer = new TemplateContainer(leafSegmentTemplate, parentSegmentTemplate, rowSegmentTemplate, triangleTemplate, columnTemplate);
this.coinTemplate = this.findBy("#coin-template");
this.coinContainer = this.findBy("#coin-container");
@ -112,7 +116,7 @@ export class LevelSite extends WordRotatorBaseSite {
return this.nextLevel();
}
const level = LevelHelper.inflateLevel(levelJson, this.templateContainer);
let level = LevelHelper.inflateLevel(levelJson, this.templateContainer);
level.setStartRotations(currentLevelInfo["rotations"]);
const self = this;
@ -147,7 +151,6 @@ export class LevelSite extends WordRotatorBaseSite {
startEndSite(){
this.startSite(EndSite);
this.finish();
}
async nextLevel() {
@ -434,7 +437,7 @@ export class LevelSite extends WordRotatorBaseSite {
this._siteContent.classList.add("step-" + currentStep);
let rotatableSegments = this.level.getRotatableSegments();
let firstSegment = rotatableSegments[0];
let firstSegment = rotatableSegments[2];
let pointer = this.findBy("#tutorial-pointer");
pointer.remove();
@ -463,9 +466,9 @@ export class LevelSite extends WordRotatorBaseSite {
}
}
}
LevelSite.RENDERER_TYPES = [20, 40, 60, 100, 120, 140, 160];
LevelSite.RENDERER_TYPES = [20, 40, 60, 80, 81, 82, 83, 100, 120, 140, 160];
LevelSite.TUTORIAL = {
FIRST_LEVEL: 67,
SECOND_LEVEL: 15,
BIG_SEGMENT_LEVEL: 341
BIG_SEGMENT_LEVEL: 1386
};

View File

@ -5,6 +5,10 @@ import {SixWordsRowLevel8} from "./SixWordsRowLevel8";
import {SixWordsRowLevel12} from "./SixWordsRowLevel12";
import {FourWordsLevel8} from "./FourWordsLevel8";
import {FourWordsLevel12} from "./FourWordsLevel12";
import {SimpleFourWordsLevel10_0} from "./SimpleFourWordsLevel10_0";
import {SimpleFourWordsLevel10_1} from "./SimpleFourWordsLevel10_1";
import {SimpleFourWordsLevel10_2} from "./SimpleFourWordsLevel10_2";
import {SimpleFourWordsLevel10_3} from "./SimpleFourWordsLevel10_3";
export class LevelHelper {
static setLevelType(typeId, level) {
@ -35,6 +39,10 @@ LevelHelper.types = {
20: SimpleLevel,
40: RowLevel8,
60: RowLevel10,
80: SimpleFourWordsLevel10_0,
81: SimpleFourWordsLevel10_1,
82: SimpleFourWordsLevel10_2,
83: SimpleFourWordsLevel10_3,
100: SixWordsRowLevel8,
120: FourWordsLevel8,
140: SixWordsRowLevel12,

View File

@ -0,0 +1,76 @@
import {Level} from "./Level";
import {RowSegment} from "../Segment/RowSegment";
import {ParentSegment} from "../Segment/ParentSegment";
import {ColumnSegment} from "../Segment/ColumnSegment";
export class SimpleFourWordsLevel extends Level{
constructor(templateContainer, wordLength, bigSegmentPosition) {
super(templateContainer);
this.wordLength = wordLength;
this.bigSegmentPosition = bigSegmentPosition;
}
createSegments() {
if (this.words.length >= 4 &&
this.words[0].length >= this.wordLength &&
this.words[1].length >= this.wordLength &&
this.words[2].length >= this.wordLength &&
this.words[3].length >= this.wordLength &&
this.wordLength >= 4
) {
let leafsWords = [];
leafsWords[0] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[1] = Level._createLeafsForWord(this.words[1], this.templateContainer.copyLeafTemplate());
leafsWords[2] = Level._createLeafsForWord(this.words[2], this.templateContainer.copyLeafTemplate());
leafsWords[3] = Level._createLeafsForWord(this.words[3], this.templateContainer.copyLeafTemplate());
let rootSegment = new RowSegment(this.templateContainer.copyRowTemplate());
for (let i = 0; i < this.wordLength / 2; i++) {
let parents = [];
parents[0] = new ParentSegment(this.templateContainer.copyParentTemplate());
parents[1] = new ParentSegment(this.templateContainer.copyParentTemplate());
parents[0].addChild(leafsWords[0][2 * i]);
parents[0].addChild(leafsWords[0][2 * i + 1]);
parents[0].addChild(leafsWords[1][2 * i]);
parents[0].addChild(leafsWords[1][2 * i + 1]);
parents[1].addChild(leafsWords[2][2 * i]);
parents[1].addChild(leafsWords[2][2 * i + 1]);
parents[1].addChild(leafsWords[3][2 * i]);
parents[1].addChild(leafsWords[3][2 * i + 1]);
let parentSegment =null;
if (i === this.bigSegmentPosition){
parents[2] = new ParentSegment(this.templateContainer.copyParentTemplate());
parents[3] = new ParentSegment(this.templateContainer.copyParentTemplate());
parents[2].addChild(leafsWords[0][2 * i + 2]);
parents[2].addChild(leafsWords[0][2 * i + 3]);
parents[2].addChild(leafsWords[1][2 * i + 2]);
parents[2].addChild(leafsWords[1][2 * i + 3]);
parents[3].addChild(leafsWords[2][2 * i + 2]);
parents[3].addChild(leafsWords[2][2 * i + 3]);
parents[3].addChild(leafsWords[3][2 * i + 2]);
parents[3].addChild(leafsWords[3][2 * i + 3]);
parentSegment = new ParentSegment(this.templateContainer.copyParentTemplate());
parentSegment.addChild(parents[0]);
parentSegment.addChild(parents[2]);
parentSegment.addChild(parents[1]);
parentSegment.addChild(parents[3]);
i++;
}
else{
parentSegment = new ColumnSegment(this.templateContainer.copyColumnTemplate());
parentSegment.addChild(parents[0]);
parentSegment.addChild(parents[1]);
}
rootSegment.addChild(parentSegment);
}
this.setRootSegment(rootSegment)
}
}
}

View File

@ -0,0 +1,7 @@
import {SimpleFourWordsLevel} from "./SimpleFourWordsLevel";
export class SimpleFourWordsLevel10_0 extends SimpleFourWordsLevel{
constructor(templateContainer) {
super(templateContainer, 10, 0);
}
}

View File

@ -0,0 +1,7 @@
import {SimpleFourWordsLevel} from "./SimpleFourWordsLevel";
export class SimpleFourWordsLevel10_1 extends SimpleFourWordsLevel{
constructor(templateContainer) {
super(templateContainer, 10, 1);
}
}

View File

@ -0,0 +1,7 @@
import {SimpleFourWordsLevel} from "./SimpleFourWordsLevel";
export class SimpleFourWordsLevel10_2 extends SimpleFourWordsLevel{
constructor(templateContainer) {
super(templateContainer, 10, 2);
}
}

View File

@ -0,0 +1,7 @@
import {SimpleFourWordsLevel} from "./SimpleFourWordsLevel";
export class SimpleFourWordsLevel10_3 extends SimpleFourWordsLevel{
constructor(templateContainer) {
super(templateContainer, 10, 3);
}
}

View File

@ -68,7 +68,6 @@ export class SixWordsRowLevel extends Level {
parents[5].addChild(leafsWords[5][4*i+2]);
parents[5].addChild(leafsWords[5][4*i+3]);
let parent = new ParentSegment(this.templateContainer.copyParentTemplate());
let triangle = new TriangleSegment(this.templateContainer.copyTriangleTemplate());
if (i % 2 === 0) {

View File

@ -0,0 +1,74 @@
import {RowSegment} from "./RowSegment";
export class ColumnSegment extends RowSegment{
_updateElement() {
const childContainer = this.element.querySelector(".child-container");
childContainer.removeAllChildren();
this._updateRotationClass();
const self = this;
this.element.onclick = function (e) {
self.rotate();
e.stopPropagation();
};
for (let i = 0, n = this.children.length; i < n; i++) {
this.children[i]._updateElement();
childContainer.appendChild(this.children[i].getElement());
}
}
// constructor(element) {
// super(element);
// this.rotatable = false;
// }
//
// applyRotations(rotations)
// {
// for (let i = 0, n = this.children.length; i < n; i++) {
// rotations = this.children[i].applyRotations(rotations);
// }
// return rotations;
// }
//
// getCurrentRotations(rotations){
// for (let i = 0, n = this.children.length; i < n; i++) {
// rotations = this.children[i].getCurrentRotations(rotations);
// }
// return rotations;
// }
//
// getCurrentLocked(locked) {
// for (let i = 0, n = this.children.length; i < n; i++) {
// locked = this.children[i].getCurrentLocked(locked);
// }
// return locked;
// }
//
// applyLocks(locks) {
// for (let i = 0, n = this.children.length; i < n; i++) {
// locks = this.children[i].applyLocks(locks);
// }
// return locks;
// }
//
// _updateElement() {
// const childContainer = this.element.querySelector(".child-container");
// childContainer.removeAllChildren();
//
// this._updateRotationClass();
//
// const self = this;
// this.element.onclick = function (e) {
// self.rotate();
// e.stopPropagation();
// };
//
// for (let i = 0, n = this.children.length; i < n; i++) {
// this.children[i]._updateElement();
// childContainer.appendChild(this.children[i].getElement());
// }
// }
}

View File

@ -174,7 +174,7 @@ export class ParentSegment extends Segment {
}
applyLocks(locks) {
this.rotatable = locks[0];
this.rotatable = (locks[0] !== false);
locks.splice(0, 1);
for (let i = 0, n = this.children.length; i < n; i++) {
locks = this.children[i].applyLocks(locks);

View File

@ -1,11 +1,12 @@
import {Helper} from "../../../../../../js/lib/pwa-lib";
export class TemplateContainer{
constructor(leafTemplate, parentTemplate, rowTemplate, triangleTemplate){
constructor(leafTemplate, parentTemplate, rowTemplate, triangleTemplate, columnTemplate){
this.leafTemplate = leafTemplate;
this.parentTemplate = parentTemplate;
this.rowTemplate = rowTemplate;
this.triangleTemplate = triangleTemplate;
this.columnTemplate = columnTemplate;
}
copyLeafTemplate()
@ -27,4 +28,8 @@ export class TemplateContainer{
{
return Helper.cloneNode(this.triangleTemplate);
}
copyColumnTemplate(){
return Helper.cloneNode(this.columnTemplate);
}
}

View File

@ -9,6 +9,9 @@
<div id='segment-row-template' class='segment segment-row'>
<div class='child-container'></div>
</div>
<div id='segment-column-template' class='segment segment-column'>
<div class='child-container'></div>
</div>
<div id='segment-triangle-template' class='segment segment-triangle'>
<div class='child-container'></div>
</div>

View File

@ -128,7 +128,14 @@ class LevelManager extends StandardManager
"numPositions" => 10,
"renderer" => 120,
"difficulty" => function () {
return ((rand(1, 100) <= 5) ? 140 : 120);
$propabillity = rand(1, 100);
if ($propabillity <= 2){
return 160;
}
if ($propabillity <= 7){
return 140;
}
return 120;
},
],
[
@ -146,7 +153,26 @@ class LevelManager extends StandardManager
"numPositions" => 14,
"renderer" => 100,
"difficulty" => function () {
return ((rand(1, 100) <= 5) ? 120 : 100);
$propabillity = rand(1, 100);
if ($propabillity <= 2){
return 140;
}
if ($propabillity <= 7){
return 120;
}
return 100;
},
],
[
"wordLength" => 10,
"numWords" => 4,
"numPositions" => 11,
"renderer" => function(){
$renderers = [80,81,82,83];
return $renderers[rand(0, count($renderers) - 1)];
},
"difficulty" => function () {
return ((rand(1, 100) <= 2) ? 100: 80);
},
],
// [
@ -209,11 +235,18 @@ class LevelManager extends StandardManager
$level = new Level();
$level->setWords(json_encode($selectedWords));
$level->setPositions(json_encode($positions));
$level->setRenderer($levelsToGenerate[$currentIndex]["renderer"]);
$level->setDifficulty($levelsToGenerate[$currentIndex]["difficulty"]());
$level->setLastUpdated(new \DateTime());
$level->setLang(1); //German
$level->setDeleted(false);
if (is_int($levelsToGenerate[$currentIndex]["renderer"])){
$level->setRenderer($levelsToGenerate[$currentIndex]["renderer"]);
}
else{
$level->setRenderer($levelsToGenerate[$currentIndex]["renderer"]());
}
$this->save($level, false);
$levelGenerated++;

View File

@ -1,8 +1,8 @@
@keyframes tutorialPointer {
0%{
0% {
top: 75%;
}
100%{
100% {
top: 25%;
}
}
@ -87,30 +87,25 @@
.segment-row {
position: inherit;
> .child-container {
> .segment-triangle:first-child {
position: inherit;
> .child-container {
> .segment-parent:first-child, > .segment-parent:first-child.rotating {
z-index: 9900 !important;
#tutorial-pointer{
width: 0.6em;
height: 0.6em;
//background: red;
.segment-parent.layer-2, > .segment-parent.layer-2.rotating {
z-index: 9900 !important;
#tutorial-pointer {
width: 0.6em;
height: 0.6em;
//background: red;
border-radius: 50%;
border-radius: 50%;
left: 25%;
right: 50%;
position: absolute;
top: 75%;
bottom: 50%;
z-index: 1;
transform: translate(-50%, -50%);
left: 25%;
right: 50%;
position: absolute;
top: 75%;
bottom: 50%;
z-index: 1;
transform: translate(-50%, -50%);
animation: tutorialPointer 2s infinite;
pointer-events: none;
}
}
animation: tutorialPointer 2s infinite;
pointer-events: none;
}
}
}

View File

@ -266,6 +266,13 @@ $coinTowerDimension: 28px;
white-space: nowrap;
}
&.segment-column {
> .child-container > .segment{
display: block;
width: 100%;
}
}
&.segment-leaf {
background-color: transparent !important;
min-width: 1em;

View File

@ -1,7 +1,7 @@
import {Selector} from 'testcafe';
import {ClientFunction} from 'testcafe';
let isLocal = true;
let isLocal = false;
let isMobile = false;
const checkMatrix = async (matrixStringSelector, shouldValues, timeout) => {
@ -353,7 +353,7 @@ test('Play', async t => {
.click(Selector('.segment-parent').nth(SEGMENT.SIXTEEN))
.click(Selector('.segment-parent').nth(SEGMENT.FOURTEEN))
.click(Selector('.segment-parent').nth(SEGMENT.NINETEEN))
.click(Selector('.segment-parent').nth(SEGMENT.TWENTYONE)).debug()
.click(Selector('.segment-parent').nth(SEGMENT.TWENTYONE))
.drag(Selector('.segment-parent').nth(SEGMENT.TEN), dragDimen, -3, {
offsetX: 10,
offsetY: 10