contra-renderer/www/js/moves/passBy.ts
Daniel Perelman 9fbf7d18ac [WIP] Refactor to split interpreter into one file per move.
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.
2023-10-15 05:25:06 -07:00

35 lines
1.3 KiB
TypeScript

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"] = "pass by";
class PassBySingleVariant extends SingleVariantMoveInterpreter<PassBy, typeof moveName> {
moveAsLowLevelMoves(): LowLevelMovesForAllDancers {
const passByShoulder = this.move.parameters.shoulder ? Hand.Left : Hand.Right;
return this.handlePairedMove(this.move.parameters.who, ({ startPos, around, withPos }) => {
return this.combine([{
beats: this.move.beats,
// TODO Is pass by always a swap?
endPosition: withPos,
movementPattern: {
kind: SemanticAnimationKind.PassBy,
around,
facing: "Forward",
otherPath: "Swap",
side: passByShoulder,
withHands: false,
}
}], startPos);
});
}
}
class PassBy extends MoveInterpreter<typeof moveName> {
buildSingleVariantMoveInterpreter(startingPos: SemanticPositionsForAllDancers): ISingleVariantMoveInterpreter {
return new PassBySingleVariant(this, startingPos);
}
}
moveInterpreters.set(moveName, PassBy);