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 = {
type: move.type,
rotation: {
'north': 'spawn',
'east': 'right',
'south': 'reverse',
'west': 'left',
}[move.orientation],
N: 'spawn',
E: 'right',
S: 'reverse',
W: 'left',
}[move.r],
x: move.x,
y: move.y,
};

View File

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