update to laptop

This commit is contained in:
silas
2018-07-06 12:17:33 +02:00
parent e2cf7e0a34
commit f04c9ec9b7
7 changed files with 218 additions and 141 deletions

View File

@@ -3407,7 +3407,7 @@ class TriangleSegment extends RowSegment{
}
class ThreeWordsRowLevel extends Level {
class SixWordsRowLevel extends Level {
constructor(templateContainer, wordLength) {
super(templateContainer);
@@ -3415,34 +3415,93 @@ class ThreeWordsRowLevel extends Level {
}
createSegments() {
if (this.words.length >= 3 && this.words[0].length >= this.wordLength && this.words[1].length >= this.wordLength && this.words[2].length >= this.wordLength) {
let leafsWordOne = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
let leafsWordTwo = Level._createLeafsForWord(this.words[1], this.templateContainer.copyLeafTemplate());
let leafsWordThree = Level._createLeafsForWord(this.words[2], this.templateContainer.copyLeafTemplate());
if (this.words.length >= 6 &&
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.words[4].length >= this.wordLength &&
this.words[5].length >= this.wordLength
) {
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());
let rootSegment = new RowSegment(this.templateContainer.copyRowTemplate());
for (let i = 0, n = this.wordLength / 2; i < n; i++) {
for (let i = 0, n = this.wordLength / 4; i < n; i++) {
let parents = [];
parents[0] = new ParentSegment(this.templateContainer.copyParentTemplate());
parents[1] = new ParentSegment(this.templateContainer.copyParentTemplate());
parents[2] = new ParentSegment(this.templateContainer.copyParentTemplate());
parents[3] = new ParentSegment(this.templateContainer.copyParentTemplate());
parents[4] = new ParentSegment(this.templateContainer.copyParentTemplate());
parents[5] = new ParentSegment(this.templateContainer.copyParentTemplate());
parents[0].addChild(leafsWords[0][4*i]);
parents[0].addChild(leafsWords[0][4*i+1]);
parents[0].addChild(leafsWords[1][4*i]);
parents[0].addChild(leafsWords[1][4*i+1]);
parents[1].addChild(leafsWords[0][4*i+2]);
parents[1].addChild(leafsWords[0][4*i+3]);
parents[1].addChild(leafsWords[1][4*i+2]);
parents[1].addChild(leafsWords[1][4*i+3]);
parents[2].addChild(leafsWords[2][4*i]);
parents[2].addChild(leafsWords[2][4*i+1]);
parents[2].addChild(leafsWords[3][4*i]);
parents[2].addChild(leafsWords[3][4*i+1]);
parents[3].addChild(leafsWords[2][4*i+2]);
parents[3].addChild(leafsWords[2][4*i+3]);
parents[3].addChild(leafsWords[3][4*i+2]);
parents[3].addChild(leafsWords[3][4*i+3]);
parents[4].addChild(leafsWords[4][4*i]);
parents[4].addChild(leafsWords[4][4*i+1]);
parents[4].addChild(leafsWords[5][4*i]);
parents[4].addChild(leafsWords[5][4*i+1]);
parents[5].addChild(leafsWords[4][4*i+2]);
parents[5].addChild(leafsWords[4][4*i+3]);
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) {
parent.addChild(leafsWordOne[2 * i]);
parent.addChild(leafsWordOne[2 * i + 1]);
parent.addChild(leafsWordTwo[2 * i]);
parent.addChild(leafsWordTwo[2 * i + 1]);
parent.addChild(parents[0]);
parent.addChild(parents[1]);
parent.addChild(parents[2]);
parent.addChild(parents[3]);
let rowSegment = new RowSegment(this.templateContainer.copyRowTemplate());
rowSegment.addChild(parents[4]);
rowSegment.addChild(parents[5]);
triangle.addChild(parent);
triangle.addChild(leafsWordThree[2 * i]);
triangle.addChild(leafsWordThree[2 * i + 1]);
triangle.addChild(rowSegment);
triangle.getElement().classList.add("type-1");
}
else {
parent.addChild(leafsWordTwo[2 * i]);
parent.addChild(leafsWordTwo[2 * i + 1]);
parent.addChild(leafsWordThree[2 * i]);
parent.addChild(leafsWordThree[2 * i + 1]);
triangle.addChild(leafsWordOne[2 * i]);
triangle.addChild(leafsWordOne[2 * i + 1]);
triangle.addChild(parents[0]);
triangle.addChild(parents[1]);
triangle.addChild(parent);
parent.addChild(parents[2]);
parent.addChild(parents[3]);
parent.addChild(parents[4]);
parent.addChild(parents[5]);
triangle.getElement().classList.add("type-2");
}
rootSegment.addChild(triangle);
}
@@ -3451,7 +3510,7 @@ class ThreeWordsRowLevel extends Level {
}
}
class ThreeWordsRowLevel8 extends ThreeWordsRowLevel {
class ThreeWordsRowLevel8 extends SixWordsRowLevel {
constructor(templateContainer) {
super(templateContainer, 8);
}
@@ -3630,8 +3689,8 @@ class LevelSite extends AbstractSite$1 {
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]);
// const nextLevelJson = await db.loadNextLevel([100]);
if (nextLevelJson === null) {
this.startSite(EndSite);
return;