make the output JSON for rotations more compact

This commit is contained in:
tali 2023-04-13 20:07:00 -04:00
parent a76f03687a
commit d1af51e204
2 changed files with 11 additions and 20 deletions

View File

@ -20,11 +20,11 @@ export async function main(args) {
let mino = { let mino = {
type: move.type, type: move.type,
rotation: { rotation: {
'north': 'spawn', N: 'spawn',
'east': 'right', E: 'right',
'south': 'reverse', S: 'reverse',
'west': 'left', W: 'left',
}[move.orientation], }[move.r],
x: move.x, x: move.x,
y: move.y, y: move.y,
}; };

View File

@ -55,27 +55,18 @@ mod ser {
ty: char, ty: char,
x: i16, x: i16,
y: i16, y: i16,
orientation: Orientation, r: char,
}
#[derive(Serialize)]
#[serde(rename_all = "lowercase")]
enum Orientation {
North,
East,
South,
West,
} }
Placement { Placement {
ty: pc.ty.as_char(), ty: pc.ty.as_char(),
x: pc.loc.x, x: pc.loc.x,
y: pc.loc.y, y: pc.loc.y,
orientation: match pc.loc.r { r: match pc.loc.r {
mino::Rot::N => Orientation::North, mino::Rot::N => 'N',
mino::Rot::E => Orientation::East, mino::Rot::E => 'E',
mino::Rot::S => Orientation::South, mino::Rot::S => 'S',
mino::Rot::W => Orientation::West, mino::Rot::W => 'W',
}, },
} }
.serialize(serializer) .serialize(serializer)