update to laptop

This commit is contained in:
silas
2018-07-06 18:39:42 +02:00
parent f04c9ec9b7
commit eea36bb922
11 changed files with 206 additions and 85 deletions

View File

@@ -51,10 +51,6 @@ export class WordRotatorDb extends MyDb {
}
}
console.log("levels count:", newLevels.length);
console.log("new levels:", newLevels);
console.log("wrong levels:", wrongLevels);
if (newLevels.length === 0) {
return null;
}

View File

@@ -69,8 +69,8 @@ export class LevelSite extends AbstractSite {
this._siteContent.classList.remove('won');
const db = WordRotatorDb.getInstance();
const nextLevelJson = await db.loadNextLevel([20,40,60]);
// const nextLevelJson = await db.loadNextLevel([100]);
// const nextLevelJson = await db.loadNextLevel([20,40,60, 100]);
const nextLevelJson = await db.loadNextLevel([140]);
if (nextLevelJson === null) {
this.startSite(EndSite);
return;

View File

@@ -1,7 +1,8 @@
import {SimpleLevel} from "./SimpleLevel";
import {RowLevel8} from "./RowLevel8";
import {RowLevel10} from "./RowLevel10";
import {ThreeWordsRowLevel8} from "./ThreeWordsRowLevel8";
import {SixWordsRowLevel8} from "./SixWordsRowLevel8";
import {SixWordsRowLevel12} from "./SixWordsRowLevel12";
export class LevelHelper {
static setLevelType(typeId, level) {
@@ -32,5 +33,6 @@ LevelHelper.types = {
20: SimpleLevel,
40: RowLevel8,
60: RowLevel10,
100: ThreeWordsRowLevel8,
100: SixWordsRowLevel8,
140: SixWordsRowLevel12,
};

View File

@@ -21,11 +21,11 @@ export class SixWordsRowLevel extends Level {
) {
let leafsWords = [];
leafsWords[0] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[1] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[2] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[3] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[4] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[5] = 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());
leafsWords[4] = Level._createLeafsForWord(this.words[4], this.templateContainer.copyLeafTemplate());
leafsWords[5] = Level._createLeafsForWord(this.words[5], this.templateContainer.copyLeafTemplate());
let rootSegment = new RowSegment(this.templateContainer.copyRowTemplate());
for (let i = 0, n = this.wordLength / 4; i < n; i++) {
@@ -88,8 +88,13 @@ export class SixWordsRowLevel extends Level {
triangle.getElement().classList.add("type-1");
}
else {
triangle.addChild(parents[0]);
triangle.addChild(parents[1]);
let rowSegment = new RowSegment(this.templateContainer.copyRowTemplate());
rowSegment.addChild(parents[0]);
rowSegment.addChild(parents[1]);
triangle.addChild(rowSegment);
triangle.addChild(parent);
parent.addChild(parents[2]);

View File

@@ -0,0 +1,7 @@
import {SixWordsRowLevel} from "./SixWordsRowLevel";
export class SixWordsRowLevel12 extends SixWordsRowLevel {
constructor(templateContainer) {
super(templateContainer, 12);
}
}

View File

@@ -1,6 +1,6 @@
import {SixWordsRowLevel} from "./SixWordsRowLevel";
export class ThreeWordsRowLevel8 extends SixWordsRowLevel {
export class SixWordsRowLevel8 extends SixWordsRowLevel {
constructor(templateContainer) {
super(templateContainer, 8);
}

View File

@@ -14,13 +14,16 @@ export class ParentSegment extends Segment {
this.rotation %= 360;
this._updateRotationClass();
this.getLevel().checkHasWon(new Promise((resolve, reject) => {
this.element.addEventListener("animationend", resolve);
}));
// return new DelayPromise(250);
return new Promise(function (resolve) {
this.element.classList.add("rotating");
let self = this;
let delayPromise = new Promise(function (resolve) {
setTimeout(resolve, 250);
}).then(()=>{
self.element.classList.remove("rotating");
});
this.getLevel().checkHasWon(delayPromise);
return delayPromise;
}
}
@@ -87,13 +90,18 @@ export class ParentSegment extends Segment {
this._updateRotationClass();
const self = this;
this.element.onclick = function () {
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());
if (i%2 === 1 && this.children.length-1 !== i)
{
childContainer.appendChild(document.createElement("br"));
}
}
}
}

View File

@@ -10,4 +10,22 @@ export class RowSegment extends ParentSegment{
}
return rotations;
}
_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());
}
}
}