60 lines
2.5 KiB
TypeScript
60 lines
2.5 KiB
TypeScript
import { HandConnection, HandTo, CircleSide, Facing, facingInAround, oppositeFacing } from "../interpreterCommon.js";
|
|
import { Move } from "../libfigureMapper.js";
|
|
import { SemanticAnimationKind } from "../lowLevelMove.js";
|
|
import { Hand } from "../rendererConstants.js";
|
|
import { ISingleVariantMoveInterpreter, LowLevelMovesForAllDancers, MoveInterpreter, SemanticPositionsForAllDancers, SingleVariantMoveInterpreter, moveInterpreters } from "./_moveInterpreter.js";
|
|
|
|
const moveName: Move["move"] = "California twirl";
|
|
|
|
class CaliforniaTwirlSingleVariant extends SingleVariantMoveInterpreter<CaliforniaTwirl, typeof moveName> {
|
|
moveAsLowLevelMoves(): LowLevelMovesForAllDancers {
|
|
return this.handleCirclePairedMove(this.move.parameters.who, ({ startPos, around }) => {
|
|
if (around === "Center") {
|
|
throw new Error("Don't know how to " + this.move.move + " around the center.");
|
|
}
|
|
|
|
if (startPos.facing === Facing.LeftInCircle || startPos.facing === Facing.RightInCircle) {
|
|
throw new Error("Don't know how to " + this.move.move + " starting facing " + startPos.facing);
|
|
}
|
|
|
|
const facing = startPos.facing === Facing.CenterOfCircle ? facingInAround(around) : startPos.facing;
|
|
const onLeft: boolean = startPos.which.isOnLeft(around, startPos.facing);
|
|
// TODO get rid of this 1 beat set up and make it part of TwirlSwap?
|
|
return this.combine([
|
|
{
|
|
beats: 1,
|
|
endPosition: {
|
|
...startPos,
|
|
hands: new Map<Hand, HandConnection>([onLeft
|
|
? [Hand.Right, { to: HandTo.DancerRight, hand: Hand.Left }]
|
|
: [Hand.Left, { to: HandTo.DancerLeft, hand: Hand.Right }]]),
|
|
facing,
|
|
},
|
|
movementPattern: {
|
|
kind: SemanticAnimationKind.Linear,
|
|
}
|
|
},
|
|
{
|
|
beats: this.move.beats - 1,
|
|
endPosition: {
|
|
...startPos,
|
|
which: startPos.which.swapOnSide(around),
|
|
facing: oppositeFacing(facing),
|
|
},
|
|
movementPattern: {
|
|
kind: SemanticAnimationKind.TwirlSwap,
|
|
around,
|
|
hand: onLeft ? Hand.Right : Hand.Left,
|
|
}
|
|
}], startPos);
|
|
});
|
|
}
|
|
}
|
|
|
|
class CaliforniaTwirl extends MoveInterpreter<typeof moveName> {
|
|
buildSingleVariantMoveInterpreter(startingPos: SemanticPositionsForAllDancers): ISingleVariantMoveInterpreter {
|
|
return new CaliforniaTwirlSingleVariant(this, startingPos);
|
|
}
|
|
}
|
|
|
|
moveInterpreters.set(moveName, CaliforniaTwirl); |