update zum laptop
This commit is contained in:
parent
f2290a8ff2
commit
651f6c90ec
33
orga/updateOrder.sql
Normal file
33
orga/updateOrder.sql
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
UPDATE Level SET deleted = 0 WHERE renderer in (80,81,82,83);
|
||||||
|
UPDATE Level SET difficulty = 1000 WHERE deleted = 0 AND difficulty >= 80;
|
||||||
|
|
||||||
|
UPDATE Level SET difficulty = 80 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 7) temp);
|
||||||
|
UPDATE Level SET difficulty = 80 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 7) temp);
|
||||||
|
UPDATE Level SET difficulty = 80 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 8) temp);
|
||||||
|
UPDATE Level SET difficulty = 80 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 7) temp);
|
||||||
|
|
||||||
|
UPDATE Level SET difficulty = 90 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 4) temp);
|
||||||
|
UPDATE Level SET difficulty = 90 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 3) temp);
|
||||||
|
UPDATE Level SET difficulty = 90 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 4) temp);
|
||||||
|
UPDATE Level SET difficulty = 90 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 4) temp);
|
||||||
|
UPDATE Level SET difficulty = 90 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 5) temp);
|
||||||
|
|
||||||
|
UPDATE Level SET difficulty = 100 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 2) temp);
|
||||||
|
UPDATE Level SET difficulty = 100 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 3) temp);
|
||||||
|
UPDATE Level SET difficulty = 100 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 2) temp);
|
||||||
|
UPDATE Level SET difficulty = 100 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 3) temp);
|
||||||
|
UPDATE Level SET difficulty = 100 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 10) temp);
|
||||||
|
|
||||||
|
UPDATE Level SET difficulty = 110 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 1) temp);
|
||||||
|
UPDATE Level SET difficulty = 110 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 1) temp);
|
||||||
|
UPDATE Level SET difficulty = 110 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 2) temp);
|
||||||
|
UPDATE Level SET difficulty = 110 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 1) temp);
|
||||||
|
UPDATE Level SET difficulty = 110 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 15) temp);
|
||||||
|
|
||||||
|
UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 2) temp);
|
||||||
|
UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 1) temp);
|
||||||
|
UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 1) temp);
|
||||||
|
UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 1) temp);
|
||||||
|
UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 10) temp);
|
||||||
|
UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 110 AND difficulty = 1000 LIMIT 5) temp);
|
||||||
|
|
||||||
@ -6474,11 +6474,11 @@ class ColumnSegment extends RowSegment{
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
class SimpleFourWordsLevel extends Level{
|
class BigSegmentsLevels extends Level{
|
||||||
constructor(templateContainer, wordLength, bigSegmentPosition) {
|
constructor(templateContainer, wordLength, bigSegmentPositions) {
|
||||||
super(templateContainer);
|
super(templateContainer);
|
||||||
this.wordLength = wordLength;
|
this.wordLength = wordLength;
|
||||||
this.bigSegmentPosition = bigSegmentPosition;
|
this.bigSegmentPositions = bigSegmentPositions;
|
||||||
}
|
}
|
||||||
|
|
||||||
createSegments() {
|
createSegments() {
|
||||||
@ -6512,7 +6512,7 @@ class SimpleFourWordsLevel extends Level{
|
|||||||
parents[1].addChild(leafsWords[3][2 * i + 1]);
|
parents[1].addChild(leafsWords[3][2 * i + 1]);
|
||||||
|
|
||||||
let parentSegment =null;
|
let parentSegment =null;
|
||||||
if (i === this.bigSegmentPosition){
|
if (this.bigSegmentPositions.indexOf(i) !== -1){
|
||||||
parents[2] = new ParentSegment(this.templateContainer.copyParentTemplate());
|
parents[2] = new ParentSegment(this.templateContainer.copyParentTemplate());
|
||||||
parents[3] = new ParentSegment(this.templateContainer.copyParentTemplate());
|
parents[3] = new ParentSegment(this.templateContainer.copyParentTemplate());
|
||||||
|
|
||||||
@ -6546,6 +6546,77 @@ class SimpleFourWordsLevel extends Level{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SimpleFourWordsLevel extends BigSegmentsLevels{
|
||||||
|
constructor(templateContainer, wordLength, bigSegmentPosition) {
|
||||||
|
console.log(bigSegmentPosition, "P");
|
||||||
|
super(templateContainer, wordLength, [bigSegmentPosition, 3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
class SimpleFourWordsLevel10_0 extends SimpleFourWordsLevel{
|
class SimpleFourWordsLevel10_0 extends SimpleFourWordsLevel{
|
||||||
constructor(templateContainer) {
|
constructor(templateContainer) {
|
||||||
super(templateContainer, 10, 0);
|
super(templateContainer, 10, 0);
|
||||||
|
|||||||
@ -148,7 +148,7 @@ export class LevelSite extends WordRotatorBaseSite {
|
|||||||
return this.nextLevel();
|
return this.nextLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
startEndSite(){
|
startEndSite() {
|
||||||
this.startSite(EndSite);
|
this.startSite(EndSite);
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ export class LevelSite extends WordRotatorBaseSite {
|
|||||||
const db = await WordRotatorDb.getInstance();
|
const db = await WordRotatorDb.getInstance();
|
||||||
const nextLevelJson = await db.loadNextLevel(LevelSite.RENDERER_TYPES);
|
const nextLevelJson = await db.loadNextLevel(LevelSite.RENDERER_TYPES);
|
||||||
|
|
||||||
console.log("nextLevelJson", nextLevelJson);
|
console.log("nextLevelJson", nextLevelJson);
|
||||||
if (nextLevelJson === null) {
|
if (nextLevelJson === null) {
|
||||||
this.startEndSite();
|
this.startEndSite();
|
||||||
return;
|
return;
|
||||||
@ -391,7 +391,7 @@ export class LevelSite extends WordRotatorBaseSite {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:{
|
default: {
|
||||||
this._siteContent.classList.remove("tutorial");
|
this._siteContent.classList.remove("tutorial");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ export class LevelSite extends WordRotatorBaseSite {
|
|||||||
scaleHelper.scaleToFull(textElem, textElem.parentElement, null, true, 1, 2);
|
scaleHelper.scaleToFull(textElem, textElem.parentElement, null, true, 1, 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:{
|
default: {
|
||||||
this._siteContent.classList.remove("tutorial");
|
this._siteContent.classList.remove("tutorial");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -461,14 +461,15 @@ export class LevelSite extends WordRotatorBaseSite {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:{
|
default: {
|
||||||
this._siteContent.classList.remove("tutorial");
|
this._siteContent.classList.remove("tutorial");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LevelSite.RENDERER_TYPES = [20, 40, 60, 80, 81, 82, 83, 100, 120, 140, 160];
|
|
||||||
|
LevelSite.RENDERER_TYPES = [20, 40, 60, 80, 81, 82, 83, 100, 110, 111, 112, 120, 140, 160];
|
||||||
LevelSite.TUTORIAL = {
|
LevelSite.TUTORIAL = {
|
||||||
FIRST_LEVEL: 67,
|
FIRST_LEVEL: 67,
|
||||||
SECOND_LEVEL: 15,
|
SECOND_LEVEL: 15,
|
||||||
|
|||||||
@ -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 BigSegmentsLevels extends Level{
|
||||||
|
constructor(templateContainer, wordLength, bigSegmentPositions) {
|
||||||
|
super(templateContainer);
|
||||||
|
this.wordLength = wordLength;
|
||||||
|
this.bigSegmentPositions = bigSegmentPositions;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 (this.bigSegmentPositions.indexOf(i) !== -1){
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,6 +9,9 @@ import {SimpleFourWordsLevel10_0} from "./SimpleFourWordsLevel10_0";
|
|||||||
import {SimpleFourWordsLevel10_1} from "./SimpleFourWordsLevel10_1";
|
import {SimpleFourWordsLevel10_1} from "./SimpleFourWordsLevel10_1";
|
||||||
import {SimpleFourWordsLevel10_2} from "./SimpleFourWordsLevel10_2";
|
import {SimpleFourWordsLevel10_2} from "./SimpleFourWordsLevel10_2";
|
||||||
import {SimpleFourWordsLevel10_3} from "./SimpleFourWordsLevel10_3";
|
import {SimpleFourWordsLevel10_3} from "./SimpleFourWordsLevel10_3";
|
||||||
|
import {TwoSegmentFourWordsLevel10_0_3} from "./TwoSegmentFourWordsLevel10_0_3";
|
||||||
|
import {TwoSegmentFourWordsLevel10_1_3} from "./TwoSegmentFourWordsLevel10_1_3";
|
||||||
|
import {TwoSegmentFourWordsLevel10_0_2} from "./TwoSegmentFourWordsLevel10_0_2";
|
||||||
|
|
||||||
export class LevelHelper {
|
export class LevelHelper {
|
||||||
static setLevelType(typeId, level) {
|
static setLevelType(typeId, level) {
|
||||||
@ -44,6 +47,9 @@ LevelHelper.types = {
|
|||||||
82: SimpleFourWordsLevel10_2,
|
82: SimpleFourWordsLevel10_2,
|
||||||
83: SimpleFourWordsLevel10_3,
|
83: SimpleFourWordsLevel10_3,
|
||||||
100: SixWordsRowLevel8,
|
100: SixWordsRowLevel8,
|
||||||
|
110: TwoSegmentFourWordsLevel10_0_3,
|
||||||
|
111: TwoSegmentFourWordsLevel10_1_3,
|
||||||
|
112: TwoSegmentFourWordsLevel10_0_2,
|
||||||
120: FourWordsLevel8,
|
120: FourWordsLevel8,
|
||||||
140: SixWordsRowLevel12,
|
140: SixWordsRowLevel12,
|
||||||
160: FourWordsLevel12,
|
160: FourWordsLevel12,
|
||||||
|
|||||||
@ -1,76 +1,7 @@
|
|||||||
import {Level} from "./Level";
|
import {BigSegmentsLevels} from "./BigSegmentsLevels";
|
||||||
import {RowSegment} from "../Segment/RowSegment";
|
|
||||||
import {ParentSegment} from "../Segment/ParentSegment";
|
|
||||||
import {ColumnSegment} from "../Segment/ColumnSegment";
|
|
||||||
|
|
||||||
export class SimpleFourWordsLevel extends Level{
|
export class SimpleFourWordsLevel extends BigSegmentsLevels{
|
||||||
constructor(templateContainer, wordLength, bigSegmentPosition) {
|
constructor(templateContainer, wordLength, bigSegmentPosition) {
|
||||||
super(templateContainer);
|
super(templateContainer, wordLength, [bigSegmentPosition]);
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
import {BigSegmentsLevels} from "./BigSegmentsLevels";
|
||||||
|
|
||||||
|
export class TwoSegmentFourWordsLevel10_0_2 extends BigSegmentsLevels{
|
||||||
|
constructor(templateContainer) {
|
||||||
|
super(templateContainer, 10, [0,2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
import {BigSegmentsLevels} from "./BigSegmentsLevels";
|
||||||
|
|
||||||
|
export class TwoSegmentFourWordsLevel10_0_3 extends BigSegmentsLevels{
|
||||||
|
constructor(templateContainer) {
|
||||||
|
super(templateContainer, 10, [0,3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
import {BigSegmentsLevels} from "./BigSegmentsLevels";
|
||||||
|
|
||||||
|
export class TwoSegmentFourWordsLevel10_1_3 extends BigSegmentsLevels{
|
||||||
|
constructor(templateContainer) {
|
||||||
|
super(templateContainer, 10, [1,3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -79,6 +79,11 @@ class LevelManager extends StandardManager
|
|||||||
return $returnArray;
|
return $returnArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function countWhere($whereArray)
|
||||||
|
{
|
||||||
|
return $this->repository->countWhere($whereArray);
|
||||||
|
}
|
||||||
|
|
||||||
public function getDoubleUsedWords()
|
public function getDoubleUsedWords()
|
||||||
{
|
{
|
||||||
$words = [];
|
$words = [];
|
||||||
@ -113,151 +118,210 @@ class LevelManager extends StandardManager
|
|||||||
public function generateLevels()
|
public function generateLevels()
|
||||||
{
|
{
|
||||||
$levelsToGenerate = [
|
$levelsToGenerate = [
|
||||||
|
//(0) 80
|
||||||
[
|
[
|
||||||
"wordLength" => 12,
|
"wordLength" => 10,
|
||||||
"numWords" => 4,
|
"numWords" => 4,
|
||||||
"numPositions" => 15,
|
"numPositions" => 11,
|
||||||
"renderer" => 160,
|
"renderer" => 80,
|
||||||
"difficulty" => function () {
|
"difficulty" => function () {
|
||||||
return 160;
|
return 1000;
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
//(1) 81
|
||||||
[
|
[
|
||||||
"wordLength" => 8,
|
"wordLength" => 10,
|
||||||
"numWords" => 4,
|
"numWords" => 4,
|
||||||
"numPositions" => 10,
|
"numPositions" => 11,
|
||||||
"renderer" => 120,
|
"renderer" => 81,
|
||||||
"difficulty" => function () {
|
"difficulty" => function () {
|
||||||
$propabillity = rand(1, 100);
|
return 1000;
|
||||||
if ($propabillity <= 2){
|
|
||||||
return 160;
|
|
||||||
}
|
|
||||||
if ($propabillity <= 7){
|
|
||||||
return 140;
|
|
||||||
}
|
|
||||||
return 120;
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
//(2) 82
|
||||||
[
|
[
|
||||||
"wordLength" => 12,
|
"wordLength" => 10,
|
||||||
"numWords" => 6,
|
"numWords" => 4,
|
||||||
"numPositions" => 21,
|
"numPositions" => 11,
|
||||||
"renderer" => 140,
|
"renderer" => 82,
|
||||||
"difficulty" => function () {
|
"difficulty" => function () {
|
||||||
return ((rand(1, 100) <= 5) ? 160 : 140);
|
return 1000;
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
//(3) 83
|
||||||
|
[
|
||||||
|
"wordLength" => 10,
|
||||||
|
"numWords" => 4,
|
||||||
|
"numPositions" => 11,
|
||||||
|
"renderer" => 83,
|
||||||
|
"difficulty" => function () {
|
||||||
|
return 1000;
|
||||||
|
},
|
||||||
|
],
|
||||||
|
//(4) 100
|
||||||
[
|
[
|
||||||
"wordLength" => 8,
|
"wordLength" => 8,
|
||||||
"numWords" => 6,
|
"numWords" => 6,
|
||||||
"numPositions" => 14,
|
"numPositions" => 14,
|
||||||
"renderer" => 100,
|
"renderer" => 100,
|
||||||
"difficulty" => function () {
|
"difficulty" => function () {
|
||||||
$propabillity = rand(1, 100);
|
return 1000;
|
||||||
if ($propabillity <= 2){
|
|
||||||
return 140;
|
|
||||||
}
|
|
||||||
if ($propabillity <= 7){
|
|
||||||
return 120;
|
|
||||||
}
|
|
||||||
return 100;
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
//(5) 110
|
||||||
[
|
[
|
||||||
"wordLength" => 10,
|
"wordLength" => 10,
|
||||||
"numWords" => 4,
|
"numWords" => 4,
|
||||||
"numPositions" => 11,
|
"numPositions" => 12,
|
||||||
"renderer" => function(){
|
"renderer" => 110,
|
||||||
$renderers = [80,81,82,83];
|
|
||||||
return $renderers[rand(0, count($renderers) - 1)];
|
|
||||||
},
|
|
||||||
"difficulty" => function () {
|
"difficulty" => function () {
|
||||||
return ((rand(1, 100) <= 2) ? 100: 80);
|
return 1000;
|
||||||
|
},
|
||||||
|
],
|
||||||
|
//(6) 111
|
||||||
|
[
|
||||||
|
"wordLength" => 10,
|
||||||
|
"numWords" => 4,
|
||||||
|
"numPositions" => 12,
|
||||||
|
"renderer" => 111,
|
||||||
|
"difficulty" => function () {
|
||||||
|
return 1000;
|
||||||
|
},
|
||||||
|
],
|
||||||
|
//(7) 112
|
||||||
|
[
|
||||||
|
"wordLength" => 10,
|
||||||
|
"numWords" => 4,
|
||||||
|
"numPositions" => 12,
|
||||||
|
"renderer" => 112,
|
||||||
|
"difficulty" => function () {
|
||||||
|
return 1000;
|
||||||
|
},
|
||||||
|
],
|
||||||
|
//(8) 120
|
||||||
|
[
|
||||||
|
"wordLength" => 8,
|
||||||
|
"numWords" => 4,
|
||||||
|
"numPositions" => 10,
|
||||||
|
"renderer" => 120,
|
||||||
|
"difficulty" => function () {
|
||||||
|
return 1000;
|
||||||
|
},
|
||||||
|
],
|
||||||
|
//(9) 140
|
||||||
|
[
|
||||||
|
"wordLength" => 12,
|
||||||
|
"numWords" => 6,
|
||||||
|
"numPositions" => 21,
|
||||||
|
"renderer" => 140,
|
||||||
|
"difficulty" => function () {
|
||||||
|
return 1000;
|
||||||
|
},
|
||||||
|
],
|
||||||
|
//(10) 160
|
||||||
|
[
|
||||||
|
"wordLength" => 12,
|
||||||
|
"numWords" => 4,
|
||||||
|
"numPositions" => 15,
|
||||||
|
"renderer" => 160,
|
||||||
|
"difficulty" => function () {
|
||||||
|
return 1000;
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
// [
|
|
||||||
// "wordLength" => 10,
|
|
||||||
// "numWords" => 2,
|
|
||||||
// "numPositions" => 5,
|
|
||||||
// "renderer" => 60,
|
|
||||||
// "difficulty" => function () {
|
|
||||||
// return ((rand(1,100) <= 5)?100:60);
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// "wordLength" => 8,
|
|
||||||
// "numWords" => 2,
|
|
||||||
// "numPositions" => 4,
|
|
||||||
// "renderer" => 40,
|
|
||||||
// "difficulty" => function () {
|
|
||||||
// return ((rand(1,100) <= 5)?120:100);
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
//Für höhere Wahrscheinlichkeiten
|
$creationRation = [
|
||||||
$levelsToGenerate[] = $levelsToGenerate[0];
|
0 => 1,
|
||||||
$levelsToGenerate[] = $levelsToGenerate[1];
|
1 => 1,
|
||||||
|
2 => 1,
|
||||||
|
3 => 1,
|
||||||
|
4 => 16,
|
||||||
|
5 => 5.333333,
|
||||||
|
6 => 5.333333,
|
||||||
|
7 => 5.333333,
|
||||||
|
8 => 24,
|
||||||
|
9 => 28,
|
||||||
|
10 => 52
|
||||||
|
];
|
||||||
|
|
||||||
|
$currentNumbers = [];
|
||||||
|
for ($i = 0; $i < count($levelsToGenerate); $i++) {
|
||||||
|
$currentNumbers[$i] = $this->countWhere(["renderer" => $levelsToGenerate[$i]["renderer"], "difficulty" => 1000]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$levelGenerated = 0;
|
$levelGenerated = 0;
|
||||||
|
|
||||||
|
$currentIndex = count($levelsToGenerate) - 1;
|
||||||
$words = [];
|
$words = [];
|
||||||
do {
|
do {
|
||||||
// var_dump($levelsToGenerate);
|
// var_dump($levelsToGenerate);
|
||||||
$currentIndex = rand(0, count($levelsToGenerate) - 1);
|
if ($currentIndex === 0 || $currentNumbers[$currentIndex] >= $currentNumbers[0] * $creationRation[$currentIndex]) {
|
||||||
|
$currentIndex = ($currentIndex + 1) % count($levelsToGenerate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$words[$levelsToGenerate[$currentIndex]["wordLength"]] = $words[$levelsToGenerate[$currentIndex]["wordLength"]] ?? $this->wordManager->findWordsForLength($levelsToGenerate[$currentIndex]["wordLength"]);
|
$words[$levelsToGenerate[$currentIndex]["wordLength"]] = $words[$levelsToGenerate[$currentIndex]["wordLength"]] ?? $this->wordManager->findWordsForLength($levelsToGenerate[$currentIndex]["wordLength"]);
|
||||||
|
|
||||||
$currentWords = $words[$levelsToGenerate[$currentIndex]["wordLength"]];
|
$currentWords = $words[$levelsToGenerate[$currentIndex]["wordLength"]];
|
||||||
|
|
||||||
// var_dump(count($currentWords), $levelsToGenerate[$currentIndex]["numWords"]);
|
$level = $this->generateLevelWithData($levelsToGenerate[$currentIndex], $currentWords);
|
||||||
|
if ($level) {
|
||||||
if (count($currentWords) >= $levelsToGenerate[$currentIndex]["numWords"]) {
|
|
||||||
$selectedWords = [];
|
|
||||||
for ($i = 0; $i < $levelsToGenerate[$currentIndex]["numWords"]; $i++) {
|
|
||||||
$wordCount = count($currentWords);
|
|
||||||
$currentWordIndex = rand(0, $wordCount - 1);
|
|
||||||
$selectedWords[] = strtoupper($currentWords[$currentWordIndex]->getWord());
|
|
||||||
$currentWords[$currentWordIndex]->setUsed(true);
|
|
||||||
$this->wordManager->save($currentWords[$currentWordIndex], false);
|
|
||||||
array_splice($currentWords, $currentWordIndex, 1);
|
|
||||||
}
|
|
||||||
$words[$levelsToGenerate[$currentIndex]["wordLength"]] = $currentWords;
|
$words[$levelsToGenerate[$currentIndex]["wordLength"]] = $currentWords;
|
||||||
$positions = [];
|
|
||||||
do {
|
|
||||||
for ($i = 0; $i < $levelsToGenerate[$currentIndex]["numPositions"]; $i++) {
|
|
||||||
$positions[] = rand(0, 3);
|
|
||||||
}
|
|
||||||
} while (count(array_filter($positions, function($position) {
|
|
||||||
return $position == 0;
|
|
||||||
}))/$levelsToGenerate[$currentIndex]["numPositions"] >= 0.67);
|
|
||||||
|
|
||||||
$level = new Level();
|
|
||||||
$level->setWords(json_encode($selectedWords));
|
|
||||||
$level->setPositions(json_encode($positions));
|
|
||||||
$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);
|
$this->save($level, false);
|
||||||
|
|
||||||
$levelGenerated++;
|
$levelGenerated++;
|
||||||
|
$currentNumbers[$currentIndex]++;
|
||||||
} else {
|
} else {
|
||||||
array_splice($levelsToGenerate, $currentIndex, 1);
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (count($levelsToGenerate) > 0 && $levelGenerated < 100);
|
} while (count($levelsToGenerate) > 0 && $levelGenerated < 180);
|
||||||
|
|
||||||
$this->emFlush();
|
$this->emFlush();
|
||||||
$this->wordManager->emFlush();
|
$this->wordManager->emFlush();
|
||||||
return $levelGenerated;
|
return $levelGenerated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function generateLevelWithData($levelData, &$words)
|
||||||
|
{
|
||||||
|
if (count($words) >= $levelData["numWords"]) {
|
||||||
|
$selectedWords = [];
|
||||||
|
for ($i = 0; $i < $levelData["numWords"]; $i++) {
|
||||||
|
$wordCount = count($words);
|
||||||
|
$currentWordIndex = rand(0, $wordCount - 1);
|
||||||
|
$selectedWords[] = strtoupper($words[$currentWordIndex]->getWord());
|
||||||
|
$words[$currentWordIndex]->setUsed(true);
|
||||||
|
$this->wordManager->save($words[$currentWordIndex], false);
|
||||||
|
array_splice($words, $currentWordIndex, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$positions = [];
|
||||||
|
do {
|
||||||
|
for ($i = 0; $i < $levelData["numPositions"]; $i++) {
|
||||||
|
$positions[] = rand(0, 3);
|
||||||
|
}
|
||||||
|
} while (count(array_filter($positions, function ($position) {
|
||||||
|
return $position == 0;
|
||||||
|
})) / $levelData["numPositions"] >= 0.67);
|
||||||
|
|
||||||
|
$level = new Level();
|
||||||
|
$level->setWords(json_encode($selectedWords));
|
||||||
|
$level->setPositions(json_encode($positions));
|
||||||
|
$level->setDifficulty($levelData["difficulty"]());
|
||||||
|
$level->setLastUpdated(new \DateTime());
|
||||||
|
$level->setLang(1); //German
|
||||||
|
$level->setDeleted(false);
|
||||||
|
|
||||||
|
if (is_int($levelData["renderer"])) {
|
||||||
|
$level->setRenderer($levelData["renderer"]);
|
||||||
|
} else {
|
||||||
|
$level->setRenderer($levelData["renderer"]());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $level;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -18,8 +18,7 @@ class LevelRepository extends StandardRepository
|
|||||||
$queryBuilder = $this->_em->createQueryBuilder();
|
$queryBuilder = $this->_em->createQueryBuilder();
|
||||||
$queryBuilder->select("l")->from(Level::class, "l");
|
$queryBuilder->select("l")->from(Level::class, "l");
|
||||||
|
|
||||||
if ($date != null)
|
if ($date != null) {
|
||||||
{
|
|
||||||
$queryBuilder->andWhere($queryBuilder->expr()->gte("l.lastUpdated", ":fromDate"));
|
$queryBuilder->andWhere($queryBuilder->expr()->gte("l.lastUpdated", ":fromDate"));
|
||||||
$queryBuilder->setParameter("fromDate", $date->format("Y-m-d H:i:00"));
|
$queryBuilder->setParameter("fromDate", $date->format("Y-m-d H:i:00"));
|
||||||
}
|
}
|
||||||
@ -34,8 +33,7 @@ class LevelRepository extends StandardRepository
|
|||||||
$queryBuilder = $this->_em->createQueryBuilder();
|
$queryBuilder = $this->_em->createQueryBuilder();
|
||||||
$queryBuilder->select("COUNT(l.id) as number")->from(Level::class, "l");
|
$queryBuilder->select("COUNT(l.id) as number")->from(Level::class, "l");
|
||||||
|
|
||||||
if ($date != null)
|
if ($date != null) {
|
||||||
{
|
|
||||||
$queryBuilder->andWhere($queryBuilder->expr()->gte("l.lastUpdated", ":fromDate"));
|
$queryBuilder->andWhere($queryBuilder->expr()->gte("l.lastUpdated", ":fromDate"));
|
||||||
$queryBuilder->setParameter("fromDate", $date->format("Y-m-d H:i:00"));
|
$queryBuilder->setParameter("fromDate", $date->format("Y-m-d H:i:00"));
|
||||||
}
|
}
|
||||||
@ -50,12 +48,24 @@ class LevelRepository extends StandardRepository
|
|||||||
|
|
||||||
public function endTransaction()
|
public function endTransaction()
|
||||||
{
|
{
|
||||||
try{
|
try {
|
||||||
$this->_em->getConnection()->commit();
|
$this->_em->getConnection()->commit();
|
||||||
} catch (\Exception $e)
|
} catch (\Exception $e) {
|
||||||
{
|
|
||||||
$this->_em->getConnection()->rollBack();
|
$this->_em->getConnection()->rollBack();
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function countWhere($whereArray)
|
||||||
|
{
|
||||||
|
$queryBuilder = $this->_em->createQueryBuilder();
|
||||||
|
$queryBuilder->select("COUNT(l.id) as number")->from(Level::class, "l");
|
||||||
|
|
||||||
|
foreach ($whereArray as $field => $arg) {
|
||||||
|
$queryBuilder->andWhere($queryBuilder->expr()->eq("l.".$field, ":".$field));
|
||||||
|
$queryBuilder->setParameter("".$field, $arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $queryBuilder->getQuery()->getSingleScalarResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user