Daniel Perelman
9fbf7d18ac
Currently just copied over the existing code and applied the quick fixes to get it to compile. Each move should be refactored to be handle its parameters earlier where applicable. But variants support should probably be added first so both refactors can happen together.
74 lines
2.5 KiB
TypeScript
74 lines
2.5 KiB
TypeScript
import { HandConnection, HandTo, BalanceWeight } from "../interpreterCommon.js";
|
|
import { Move } from "../libfigureMapper.js";
|
|
import { SemanticAnimationKind } from "../lowLevelMove.js";
|
|
import { Hand } from "../rendererConstants.js";
|
|
import { ISingleVariantMoveInterpreter, LowLevelMovesForAllDancers, MoveInterpreter, PartialLowLevelMove, SemanticPositionsForAllDancers, SingleVariantMoveInterpreter, moveInterpreters } from "./_moveInterpreter.js";
|
|
|
|
const moveName: Move["move"] = "box the gnat";
|
|
|
|
class BoxTheGnatSingleVariant extends SingleVariantMoveInterpreter<BoxTheGnat, typeof moveName> {
|
|
moveAsLowLevelMoves(): LowLevelMovesForAllDancers {
|
|
return this.handlePairedMove(this.move.parameters.who, ({ startPos, around, withPos }) => {
|
|
const hand = this.move.parameters.hand ? Hand.Right : Hand.Left;
|
|
const balanceBeats = this.move.parameters.bal
|
|
? this.move.beats > 4
|
|
? this.move.beats - 4
|
|
: 2
|
|
: 0;
|
|
const balancePartBeats = balanceBeats / 2;
|
|
const twirlBeats = this.move.beats - balanceBeats;
|
|
|
|
// TODO Adjust facing?
|
|
const startPosition = { ...startPos, hands: new Map<Hand, HandConnection>([[hand, { hand, to: HandTo.DancerForward }]]) };
|
|
|
|
if (around === "Center") {
|
|
throw "TwirlSwap around center is unsupported.";
|
|
}
|
|
|
|
const twirl: PartialLowLevelMove = {
|
|
beats: twirlBeats,
|
|
endPosition: withPos,
|
|
movementPattern: {
|
|
kind: SemanticAnimationKind.TwirlSwap,
|
|
around,
|
|
hand,
|
|
}
|
|
};
|
|
|
|
if (this.move.parameters.bal) {
|
|
return this.combine([
|
|
{
|
|
beats: balancePartBeats,
|
|
endPosition: {
|
|
...startPosition,
|
|
balance: BalanceWeight.Forward,
|
|
},
|
|
movementPattern: {
|
|
kind: SemanticAnimationKind.Linear,
|
|
}
|
|
},
|
|
{
|
|
beats: balancePartBeats,
|
|
endPosition: {
|
|
...startPosition,
|
|
balance: BalanceWeight.Backward,
|
|
},
|
|
movementPattern: {
|
|
kind: SemanticAnimationKind.Linear,
|
|
}
|
|
},
|
|
twirl], startPosition);
|
|
} else {
|
|
return this.combine([twirl], startPosition);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
class BoxTheGnat extends MoveInterpreter<typeof moveName> {
|
|
buildSingleVariantMoveInterpreter(startingPos: SemanticPositionsForAllDancers): ISingleVariantMoveInterpreter {
|
|
return new BoxTheGnatSingleVariant(this, startingPos);
|
|
}
|
|
}
|
|
|
|
moveInterpreters.set(moveName, BoxTheGnat); |