new 4475edb243ed4627f4c5f2c470ca40b3def034d4
[tagua/yd.git] / src / variants / crazyhouse / moveserializer.cpp
blob42ced9f28fac55534a0dd5586167ee62d5dbbdd4
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 */
10 #include "moveserializer.h"
11 #include <core/board.h>
12 #include <core/state.h>
13 #include <core/type.h>
15 namespace Crazyhouse {
17 MoveSerializer::MoveSerializer(IMoveSerializer* serializer)
18 : Delegators::MoveSerializer(serializer) { }
20 QString MoveSerializer::serialize(const Move& move, const IState* ref) const {
21 if (move.drop() == Piece())
22 return m_serializer->serialize(move, ref);
24 QString res;
25 if (type() == "decorated") {
26 const IType* type = move.drop().type();
27 if (type)
28 res = "{" + move.drop().type()->name() + '}';
29 else
30 res = "?";
32 else {
33 res = symbol(move.drop().type()).toUpper();
36 return res +
37 '@' +
38 move.dst().toString(ref->board()->size().y) +
39 suffix(move, ref);
42 } // namespace Crazyhouse