Ejemplo n.º 1
0
 public void ForceAddTile(DominoTileEntity tile)
 {
     if (head == null && tail == null)
     {
         head = tail = tile;
         return;
     }
     if (head == tail && tile.GetUnlinkedValues().Any(x => x == head.FirstValue))
     {
         tile.Link(head);
         tail = tile;
         return;
     }
     if (head.MatchesUnlinkedValue(tile))
     {
         tile.Link(head);
         head = tile;
         return;
     }
     if (tail.MatchesUnlinkedValue(tile))
     {
         tail.Link(tile);
         tail = tile;
         return;
     }
     throw new ApplicationException($"Illegal move. Head nor tail matches '{tile}'");
 }