update to pc
This commit is contained in:
parent
ba579e3bdf
commit
e2cf7e0a34
@ -1 +1 @@
|
||||
<div class=max-height><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 class=max-height><div class="show-when-won height-20 center flex-center"><b data-translation=won id=won-text></b></div><div class="flex-center height-60 overflow-hidden"><div id=level></div></div><div class="show-when-won flex-center height-20"><button class=button id=continue-button data-translation=continue></button></div></div></div>
|
||||
<div class=max-height><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 class=max-height><div class="show-when-won height-20 center flex-center"><b data-translation=won id=won-text></b></div><div class="flex-center height-60 overflow-hidden"><div id=level></div></div><div class="show-when-won flex-center height-20"><button class=button id=continue-button data-translation=continue></button></div></div></div>
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -9,6 +9,9 @@
|
||||
<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>
|
||||
<!-- Site Content -->
|
||||
<div class='max-height'>
|
||||
<div class = 'show-when-won height-20 center flex-center'>
|
||||
|
||||
@ -35,14 +35,17 @@ export class LevelSite extends AbstractSite {
|
||||
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");
|
||||
@ -57,7 +60,7 @@ export class LevelSite extends AbstractSite {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -67,9 +70,8 @@ export class LevelSite extends AbstractSite {
|
||||
|
||||
const db = WordRotatorDb.getInstance();
|
||||
// const nextLevelJson = await db.loadNextLevel([20,40,60]);
|
||||
const nextLevelJson = await db.loadNextLevel([40]);
|
||||
if (nextLevelJson === null)
|
||||
{
|
||||
const nextLevelJson = await db.loadNextLevel([100]);
|
||||
if (nextLevelJson === null) {
|
||||
this.startSite(EndSite);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import {SimpleLevel} from "./SimpleLevel";
|
||||
import {RowLevel8} from "./RowLevel8";
|
||||
import {RowLevel10} from "./RowLevel10";
|
||||
import {ThreeWordsRowLevel8} from "./ThreeWordsRowLevel8";
|
||||
|
||||
export class LevelHelper {
|
||||
static setLevelType(typeId, level) {
|
||||
@ -31,4 +32,5 @@ LevelHelper.types = {
|
||||
20: SimpleLevel,
|
||||
40: RowLevel8,
|
||||
60: RowLevel10,
|
||||
100: ThreeWordsRowLevel8,
|
||||
};
|
||||
@ -0,0 +1,61 @@
|
||||
import {RowSegment} from "../Segment/RowSegment";
|
||||
import {Level} from "./Level";
|
||||
import {ParentSegment} from "../Segment/ParentSegment";
|
||||
import {TriangleSegment} from "../Segment/TriangleSegment";
|
||||
|
||||
export class SixWordsRowLevel extends Level {
|
||||
|
||||
constructor(templateContainer, wordLength) {
|
||||
super(templateContainer);
|
||||
this.wordLength = wordLength;
|
||||
}
|
||||
|
||||
createSegments() {
|
||||
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 leafes = [];
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
import {SixWordsRowLevel} from "./SixWordsRowLevel";
|
||||
|
||||
export class ThreeWordsRowLevel8 extends SixWordsRowLevel {
|
||||
constructor(templateContainer) {
|
||||
super(templateContainer, 8);
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,11 @@
|
||||
import {Helper} from "../../../../../../js/lib/pwa-lib";
|
||||
|
||||
export class TemplateContainer{
|
||||
constructor(leafTemplate, parentTemplate, rowTemplate){
|
||||
constructor(leafTemplate, parentTemplate, rowTemplate, triangleTemplate){
|
||||
this.leafTemplate = leafTemplate;
|
||||
this.parentTemplate = parentTemplate;
|
||||
this.rowTemplate = rowTemplate;
|
||||
this.triangleTemplate = triangleTemplate;
|
||||
}
|
||||
|
||||
copyLeafTemplate()
|
||||
@ -21,4 +22,9 @@ export class TemplateContainer{
|
||||
{
|
||||
return Helper.cloneNode(this.rowTemplate);
|
||||
}
|
||||
|
||||
copyTriangleTemplate()
|
||||
{
|
||||
return Helper.cloneNode(this.triangleTemplate);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
import {RowSegment} from "./RowSegment";
|
||||
|
||||
export class TriangleSegment extends RowSegment{
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user