ecattez / shahmat

A Chess implementation with the Domain Driven Design
https://ecattez.github.io/shahmat/
GNU General Public License v3.0
3 stars 0 forks source link

Board Projection : HAL Representation #10

Closed ecattez closed 4 years ago

ecattez commented 4 years ago

For HTTP Clients, we should send a representation such as below (preferred hal-forms format).

{
  "turnOf": "WHITE",
  "number-of-living-black-pieces": 0,
  "number-of-living-white-pieces": 0,
  "_embedded": {
    "squares": [
      {
        "location": "a1",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/a1"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "a2",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/a2"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "a3",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/a3"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "a4",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/a4"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "a5",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/a5"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "a6",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/a6"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "a7",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/a7"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "a8",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/a8"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "b1",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/b1"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "b2",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/b2"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "b3",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/b3"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "b4",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/b4"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "b5",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/b5"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "b6",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/b6"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "b7",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/b7"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "b8",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/b8"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "c1",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/c1"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "c2",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/c2"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "c3",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/c3"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "c4",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/c4"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "c5",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/c5"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "c6",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/c6"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "c7",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/c7"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "c8",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/c8"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "d1",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/d1"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "d2",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/d2"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "d3",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/d3"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "d4",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/d4"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "d5",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/d5"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "d6",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/d6"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "d7",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/d7"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "d8",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/d8"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "e1",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/e1"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "e2",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/e2"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "e3",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/e3"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "e4",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/e4"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "e5",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/e5"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "e6",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/e6"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "e7",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/e7"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "e8",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/e8"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "f1",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/f1"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "f2",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/f2"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "f3",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/f3"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "f4",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/f4"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "f5",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/f5"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "f6",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/f6"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "f7",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/f7"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "f8",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/f8"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "g1",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/g1"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "g2",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/g2"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "g3",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/g3"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "g4",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/g4"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "g5",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/g5"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "g6",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/g6"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "g7",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/g7"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "g8",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/g8"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "h1",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/h1"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "h2",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/h2"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "h3",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/h3"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "h4",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/h4"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "h5",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/h5"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "h6",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/h6"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "h7",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/h7"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      },
      {
        "location": "h8",
        "vacant": true,
        "_links": [
          {
            "self": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c/squares/h8"
            }
          },
          {
            "related": {
              "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
            }
          }
        ]
      }
    ]
  },
  "_links": [
    {
      "self": {
        "href": "http://localhost:8080/boards/3feeafdf02b4c76c"
      }
    }
  ]
}