Skip to content

Commit

Permalink
Fix promotion shapes in puzzles
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererXII committed Aug 28, 2022
1 parent afc5e8d commit 8ba4785
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ui/puzzle/src/autoShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { opposite } from 'shogiground/util';
import { Pieces } from 'shogiground/types';
import { isDrop } from 'shogiops/types';
import { makeSquare, parseUsi } from 'shogiops/util';
import { promote } from 'shogiops/variantUtil';
import { defined } from 'common/common';

interface Opts {
Expand Down Expand Up @@ -50,14 +51,14 @@ function makeAutoShapesFromUsi(
brush: brush,
},
];
const pieceToPromote = move.promotion ? pieces?.get(usi.slice(0, 2) as Key) : undefined;
const pieceToPromote = move.promotion ? pieces.get(usi.slice(0, 2) as Key) : undefined;
if (defined(pieceToPromote)) {
shapes.push({
orig: makeSquare(move.to) as Key,
dest: makeSquare(move.to) as Key,
piece: {
color: pieceToPromote.color,
role: pieceToPromote.role,
role: promote('standard')(pieceToPromote.role) || pieceToPromote.role,
scale: 0.8,
},
brush: 'engine',
Expand Down

0 comments on commit 8ba4785

Please sign in to comment.