Skip to content

Commit

Permalink
Use constraint bar in puzzlemaker, drop remaining old constraint stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
luxaritas committed Sep 28, 2019
1 parent 35e5e08 commit f0e6d4e
Show file tree
Hide file tree
Showing 18 changed files with 250 additions and 1,314 deletions.
2 changes: 2 additions & 0 deletions src/eterna/constraints/Constraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ export default abstract class Constraint<ConstraintStatus extends BaseConstraint
): HighlightInfo {
return null;
}

public abstract serialize(): [string, string];
}
9 changes: 9 additions & 0 deletions src/eterna/constraints/ConstraintBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ export default class ConstraintBar extends ContainerObject {
)[0].constraintBox;
}

public serializeConstraints(): string {
return this._constraints.map(
(constraint) => constraint.constraint.serialize()
).reduce(
(all, current) => all.concat(current),
[]
).join(',');
}

private _constraints: ConstraintWrapper[];
private _flaggedConstraint: ConstraintWrapper;
}
7 changes: 7 additions & 0 deletions src/eterna/constraints/constraints/BarcodeConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ export default class BarcodeConstraint extends Constraint<BaseConstraintStatus>
showOutline: true
};
}

public serialize(): [string, string] {
return [
BarcodeConstraint.NAME,
'0'
];
}
}
21 changes: 21 additions & 0 deletions src/eterna/constraints/constraints/BindingConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ export class MultistrandBindingsConstraint extends BindingsConstraint<Multistran
color: HighlightType.RESTRICTED
};
}

public serialize(): [string, string] {
return [
BindingsConstraint.NAME,
this.stateIndex.toString()
];
}
}

export class OligoBoundConstraint extends BindingsConstraint<BaseConstraintStatus> {
Expand All @@ -215,6 +222,13 @@ export class OligoBoundConstraint extends BindingsConstraint<BaseConstraintStatu
satisfied: nnfe != null && nnfe[0] === -2
};
}

public serialize(): [string, string] {
return [
OligoBoundConstraint.NAME,
this.stateIndex.toString()
];
}
}

export class OligoUnboundConstraint extends BindingsConstraint<BaseConstraintStatus> {
Expand All @@ -237,4 +251,11 @@ export class OligoUnboundConstraint extends BindingsConstraint<BaseConstraintSta
satisfied: nnfe != null && nnfe[0] !== -2
};
}

public serialize(): [string, string] {
return [
OligoBoundConstraint.NAME,
this.stateIndex.toString()
];
}
}
7 changes: 7 additions & 0 deletions src/eterna/constraints/constraints/BoostConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ class BoostConstraint extends Constraint<BoostConstraintStatus> {
showOutline: true
};
}

public serialize(): [string, string] {
return [
BoostConstraint.NAME,
this.minBoosts.toString()
];
}
}
28 changes: 28 additions & 0 deletions src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export class ConsecutiveAConstraint extends ConsecutiveBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_ADENINE, count);
}

public serialize(): [string, string] {
return [
ConsecutiveAConstraint.NAME,
this.maxConsecutive.toString()
];
}
}

export class ConsecutiveUConstraint extends ConsecutiveBaseConstraint {
Expand All @@ -86,6 +93,13 @@ export class ConsecutiveUConstraint extends ConsecutiveBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_URACIL, count);
}

public serialize(): [string, string] {
return [
ConsecutiveUConstraint.NAME,
this.maxConsecutive.toString()
];
}
}

export class ConsecutiveGConstraint extends ConsecutiveBaseConstraint {
Expand All @@ -94,6 +108,13 @@ export class ConsecutiveGConstraint extends ConsecutiveBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_GUANINE, count);
}

public serialize(): [string, string] {
return [
ConsecutiveGConstraint.NAME,
this.maxConsecutive.toString()
];
}
}

export class ConsecutiveCConstraint extends ConsecutiveBaseConstraint {
Expand All @@ -102,4 +123,11 @@ export class ConsecutiveCConstraint extends ConsecutiveBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_CYTOSINE, count);
}

public serialize(): [string, string] {
return [
ConsecutiveCConstraint.NAME,
this.maxConsecutive.toString()
];
}
}
28 changes: 28 additions & 0 deletions src/eterna/constraints/constraints/MaximumBaseConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ export class MaximumAConstraint extends MaximumBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_ADENINE, count);
}

public serialize(): [string, string] {
return [
MaximumAConstraint.NAME,
this.maxCount.toString()
];
}
}

export class MaximumUConstraint extends MaximumBaseConstraint {
Expand All @@ -76,6 +83,13 @@ export class MaximumUConstraint extends MaximumBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_URACIL, count);
}

public serialize(): [string, string] {
return [
MaximumUConstraint.NAME,
this.maxCount.toString()
];
}
}

export class MaximumGConstraint extends MaximumBaseConstraint {
Expand All @@ -84,6 +98,13 @@ export class MaximumGConstraint extends MaximumBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_GUANINE, count);
}

public serialize(): [string, string] {
return [
MaximumGConstraint.NAME,
this.maxCount.toString()
];
}
}

export class MaximumCConstraint extends MaximumBaseConstraint {
Expand All @@ -92,4 +113,11 @@ export class MaximumCConstraint extends MaximumBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_CYTOSINE, count);
}

public serialize(): [string, string] {
return [
MaximumCConstraint.NAME,
this.maxCount.toString()
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ export default class MaximumMutationConstraint extends Constraint<MaxMutationCon
};
}

public serialize(): [string, string] {
return [
MaximumMutationConstraint.NAME,
this.maxMutations.toString()
];
}

private static get _icon(): Texture {
let icon = new Container();

Expand Down
21 changes: 21 additions & 0 deletions src/eterna/constraints/constraints/MaximumPairConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ export class MaximumGCConstraint extends MaximumPairConstraint {
: BitmapManager.getBitmap(Bitmaps.NovaGCReq)
};
}

public serialize(): [string, string] {
return [
MaximumGCConstraint.NAME,
this.maxPairs.toString()
];
}
}

export class MaximumAUConstraint extends MaximumPairConstraint {
Expand All @@ -102,6 +109,13 @@ export class MaximumAUConstraint extends MaximumPairConstraint {
: BitmapManager.getBitmap(Bitmaps.NovaAUReq)
};
}

public serialize(): [string, string] {
return [
MaximumAUConstraint.NAME,
this.maxPairs.toString()
];
}
}

export class MaximumGUConstraint extends MaximumPairConstraint {
Expand All @@ -123,4 +137,11 @@ export class MaximumGUConstraint extends MaximumPairConstraint {
: BitmapManager.getBitmap(Bitmaps.NovaGUReq)
};
}

public serialize(): [string, string] {
return [
MaximumGUConstraint.NAME,
this.maxPairs.toString()
];
}
}
28 changes: 28 additions & 0 deletions src/eterna/constraints/constraints/MinimumBaseConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export class MinimumAConstraint extends MinimumBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_ADENINE, count);
}

public serialize(): [string, string] {
return [
MinimumAConstraint.NAME,
this.minCount.toString()
];
}
}

export class MinimumUConstraint extends MinimumBaseConstraint {
Expand All @@ -74,6 +81,13 @@ export class MinimumUConstraint extends MinimumBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_URACIL, count);
}

public serialize(): [string, string] {
return [
MinimumUConstraint.NAME,
this.minCount.toString()
];
}
}

export class MinimumGConstraint extends MinimumBaseConstraint {
Expand All @@ -82,6 +96,13 @@ export class MinimumGConstraint extends MinimumBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_GUANINE, count);
}

public serialize(): [string, string] {
return [
MinimumGConstraint.NAME,
this.minCount.toString()
];
}
}

export class MinimumCConstraint extends MinimumBaseConstraint {
Expand All @@ -90,4 +111,11 @@ export class MinimumCConstraint extends MinimumBaseConstraint {
constructor(count: number) {
super(EPars.RNABASE_CYTOSINE, count);
}

public serialize(): [string, string] {
return [
MinimumCConstraint.NAME,
this.minCount.toString()
];
}
}
28 changes: 28 additions & 0 deletions src/eterna/constraints/constraints/MinimumPairConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ export class MinimumGCConstraint extends MinimumPairConstraint {
: BitmapManager.getBitmap(Bitmaps.NovaGCReq)
};
}

public serialize(): [string, string] {
return [
MinimumGCConstraint.NAME,
this.minPairs.toString()
];
}
}

export class MinimumAUConstraint extends MinimumPairConstraint {
Expand All @@ -101,6 +108,13 @@ export class MinimumAUConstraint extends MinimumPairConstraint {
: BitmapManager.getBitmap(Bitmaps.NovaAUReq)
};
}

public serialize(): [string, string] {
return [
MinimumAUConstraint.NAME,
this.minPairs.toString()
];
}
}

export class MinimumGUConstraint extends MinimumPairConstraint {
Expand All @@ -122,6 +136,13 @@ export class MinimumGUConstraint extends MinimumPairConstraint {
: BitmapManager.getBitmap(Bitmaps.NovaGUReq)
};
}

public serialize(): [string, string] {
return [
MinimumGUConstraint.NAME,
this.minPairs.toString()
];
}
}

export class MinimumAnyPairConstraint extends MinimumPairConstraint {
Expand Down Expand Up @@ -172,4 +193,11 @@ export class MinimumAnyPairConstraint extends MinimumPairConstraint {
: BitmapManager.getBitmap(Bitmaps.NovaPairsReq)
};
}

public serialize(): [string, string] {
return [
MinimumAnyPairConstraint.NAME,
this.minPairs.toString()
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export default class MinimumStackLengthConstraint extends Constraint<MinStackCon
};
}

public serialize(): [string, string] {
return [
MinimumStackLengthConstraint.NAME,
this.minLength.toString()
];
}

private static get _icon(): Texture {
let icon = new Container();
let tex = BitmapManager.getBitmap(Bitmaps.BaseWMidPattern);
Expand Down
7 changes: 7 additions & 0 deletions src/eterna/constraints/constraints/ScriptConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,11 @@ export default class ScriptConstraint extends Constraint<ScriptConstraintStatus>
stateIndex: status.stateIndex
};
}

public serialize(): [string, string] {
return [
ScriptConstraint.NAME,
this.scriptID.toString()
];
}
}
Loading

0 comments on commit f0e6d4e

Please sign in to comment.