update to pc
This commit is contained in:
@@ -3215,10 +3215,11 @@ class LeafSegment extends Segment {
|
||||
}
|
||||
|
||||
class TemplateContainer{
|
||||
constructor(leafTemplate, parentTemplate, rowTemplate){
|
||||
constructor(leafTemplate, parentTemplate, rowTemplate, triangleTemplate){
|
||||
this.leafTemplate = leafTemplate;
|
||||
this.parentTemplate = parentTemplate;
|
||||
this.rowTemplate = rowTemplate;
|
||||
this.triangleTemplate = triangleTemplate;
|
||||
}
|
||||
|
||||
copyLeafTemplate()
|
||||
@@ -3235,6 +3236,11 @@ class TemplateContainer{
|
||||
{
|
||||
return Helper.cloneNode(this.rowTemplate);
|
||||
}
|
||||
|
||||
copyTriangleTemplate()
|
||||
{
|
||||
return Helper.cloneNode(this.triangleTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
class Level {
|
||||
@@ -3397,6 +3403,60 @@ class RowLevel10 extends RowLevel{
|
||||
}
|
||||
}
|
||||
|
||||
class TriangleSegment extends RowSegment{
|
||||
|
||||
}
|
||||
|
||||
class ThreeWordsRowLevel extends Level {
|
||||
|
||||
constructor(templateContainer, wordLength) {
|
||||
super(templateContainer);
|
||||
this.wordLength = wordLength;
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
let rootSegment = new RowSegment(this.templateContainer.copyRowTemplate());
|
||||
for (let i = 0, n = this.wordLength / 2; i < n; i++) {
|
||||
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]);
|
||||
|
||||
triangle.addChild(parent);
|
||||
triangle.addChild(leafsWordThree[2 * i]);
|
||||
triangle.addChild(leafsWordThree[2 * i + 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(parent);
|
||||
}
|
||||
rootSegment.addChild(triangle);
|
||||
}
|
||||
this.setRootSegment(rootSegment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ThreeWordsRowLevel8 extends ThreeWordsRowLevel {
|
||||
constructor(templateContainer) {
|
||||
super(templateContainer, 8);
|
||||
}
|
||||
}
|
||||
|
||||
class LevelHelper {
|
||||
static setLevelType(typeId, level) {
|
||||
LevelHelper.types[typeId] = level;
|
||||
@@ -3426,6 +3486,7 @@ LevelHelper.types = {
|
||||
20: SimpleLevel,
|
||||
40: RowLevel8,
|
||||
60: RowLevel10,
|
||||
100: ThreeWordsRowLevel8,
|
||||
};
|
||||
|
||||
class WordRotatorDb extends MyDb {
|
||||
@@ -3535,14 +3596,17 @@ class LevelSite extends AbstractSite$1 {
|
||||
let leafSegmentTemplate = this.findBy("#segment-leaf-template");
|
||||
let parentSegmentTemplate = this.findBy("#segment-parent-template");
|
||||
let rowSegmentTemplate = this.findBy("#segment-row-template");
|
||||
let triangleTemplate = this.findBy("#segment-triangle-template");
|
||||
|
||||
leafSegmentTemplate.id = null;
|
||||
parentSegmentTemplate.id = null;
|
||||
rowSegmentTemplate.id = null;
|
||||
triangleTemplate.id = null;
|
||||
|
||||
leafSegmentTemplate.remove();
|
||||
parentSegmentTemplate.remove();
|
||||
rowSegmentTemplate.remove();
|
||||
triangleTemplate.remove();
|
||||
|
||||
let self = this;
|
||||
let continueButton = this.findBy("#continue-button");
|
||||
@@ -3557,7 +3621,7 @@ class LevelSite extends AbstractSite$1 {
|
||||
scaleHelper.scaleToFull(wonText, wonText.parentElement);
|
||||
|
||||
this.levelCounterAction.setTitle(this.levelCounter);
|
||||
this.templateContainer = new TemplateContainer(leafSegmentTemplate, parentSegmentTemplate, rowSegmentTemplate);
|
||||
this.templateContainer = new TemplateContainer(leafSegmentTemplate, parentSegmentTemplate, rowSegmentTemplate, triangleTemplate);
|
||||
this.nextLevel();
|
||||
}
|
||||
|
||||
@@ -3566,9 +3630,9 @@ class LevelSite extends AbstractSite$1 {
|
||||
this._siteContent.classList.remove('won');
|
||||
|
||||
const db = WordRotatorDb.getInstance();
|
||||
const nextLevelJson = await db.loadNextLevel([40]);
|
||||
if (nextLevelJson === null)
|
||||
{
|
||||
// const nextLevelJson = await db.loadNextLevel([20,40,60]);
|
||||
const nextLevelJson = await db.loadNextLevel([100]);
|
||||
if (nextLevelJson === null) {
|
||||
this.startSite(EndSite);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user