Commit 3e5c1f2d authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Remove the unused legacy functions

parent 3ecf92fc
# tarot implements the rules of the tarot game # tarot implements the rules of the tarot game
# Copyright (C) 2019 Vivien Kraus # Copyright (C) 2019, 2020 Vivien Kraus
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -22,11 +22,5 @@ src_libtarot_libtarot_la_SOURCES += \ ...@@ -22,11 +22,5 @@ src_libtarot_libtarot_la_SOURCES += \
%reldir%/tarot/layout_private.h \ %reldir%/tarot/layout_private.h \
%reldir%/tarot/layout_private_impl.h %reldir%/tarot/layout_private_impl.h
check_PROGRAMS += %reldir%/check-layout
%canon_reldir%_check_layout_LDADD = src/libtarot/libtarot.la
ENUM_HEADER_FILES += %reldir%/tarot/layout.h ENUM_HEADER_FILES += %reldir%/tarot/layout.h
INTROSPECTED_SOURCES += %reldir%/layout.c INTROSPECTED_SOURCES += %reldir%/layout.c
INDENTED += %reldir%/check-layout.c
EXTRA_DIST += %reldir%/check-layout.xsl
/* tarot implements the rules of the tarot game
* Copyright (C) 2018, 2019 Vivien Kraus
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <tarot.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "xalloc.h"
#include <assert.h>
static const size_t skipped[] = {
0, 1, 3, 2
};
static void
print_svg (const char *description, double view_w, double view_h,
double card_w, double card_h, size_t n_my_cards, size_t n_center)
{
TarotPosition *positions = NULL;
size_t n_positions =
tarot_layout_position (view_w, view_h, card_w, card_h, n_my_cards,
sizeof (skipped) / sizeof (skipped[0]), skipped,
n_center, 0, NULL);
size_t i;
size_t n_positions_2;
positions = xmalloc (n_positions * sizeof (TarotPosition));
n_positions_2 =
tarot_layout_position (view_w, view_h, card_w, card_h, n_my_cards,
sizeof (skipped) / sizeof (skipped[0]), skipped,
n_center, n_positions, positions);
if (n_positions_2 != n_positions)
{
fprintf (stderr, "%s:%d: %lu != %lu\n", __FILE__, __LINE__,
n_positions_2, n_positions);
assert (0);
}
printf
("<test description=\"%s (everything)\" width=\"%f\" height=\"%f\" card-width=\"%f\" card-height=\"%f\" n-cards=\"%lu\">",
description, view_w, view_h, card_w, card_h, n_positions);
for (i = 0; i < n_positions; i++)
{
printf
("<card index=\"%lu\" x=\"%f\" y=\"%f\" z=\"%f\" angle=\"%f\" scale=\"%f\" />",
i, positions[i].x, positions[i].y, positions[i].z,
positions[i].angle, positions[i].scale);
}
printf ("</test>");
free (positions);
tarot_layout_hand_alloc (view_w, view_h, card_w, card_h, n_my_cards,
&n_positions, &positions);
printf
("<test description=\"%s (only the hand)\" width=\"%f\" height=\"%f\" card-width=\"%f\" card-height=\"%f\" n-cards=\"%lu\">",
description, view_w, view_h, card_w, card_h, n_positions);
for (i = 0; i < n_positions; i++)
{
printf
("<card index=\"%lu\" x=\"%f\" y=\"%f\" z=\"%f\" angle=\"%f\" scale=\"%f\" />",
i, positions[i].x, positions[i].y, positions[i].z,
positions[i].angle, positions[i].scale);
}
printf ("</test>");
free (positions);
tarot_layout_trick_alloc (view_w, view_h, card_w, card_h, 5, &n_positions,
&positions);
printf
("<test description=\"%s (only the trick)\" width=\"%f\" height=\"%f\" card-width=\"%f\" card-height=\"%f\" n-cards=\"%lu\">",
description, view_w, view_h, card_w, card_h, n_positions);
for (i = 0; i < n_positions; i++)
{
printf
("<card index=\"%lu\" x=\"%f\" y=\"%f\" z=\"%f\" angle=\"%f\" scale=\"%f\" />",
i, positions[i].x, positions[i].y, positions[i].z,
positions[i].angle, positions[i].scale);
}
printf ("</test>");
free (positions);
tarot_layout_center_alloc (view_w, view_h, card_w, card_h, n_center,
&n_positions, &positions);
printf
("<test description=\"%s (only the center)\" width=\"%f\" height=\"%f\" card-width=\"%f\" card-height=\"%f\" n-cards=\"%lu\">",
description, view_w, view_h, card_w, card_h, n_positions);
for (i = 0; i < n_positions; i++)
{
printf
("<card index=\"%lu\" x=\"%f\" y=\"%f\" z=\"%f\" angle=\"%f\" scale=\"%f\" />",
i, positions[i].x, positions[i].y, positions[i].z,
positions[i].angle, positions[i].scale);
}
printf ("</test>");
free (positions);
}
int
main ()
{
printf ("<?xml version=\"1.0\"?>\n");
printf ("<?xml-stylesheet type=\"text/xsl\" href=\"check-layout.xsl\"?>\n");
printf ("<example xmlns=\"http://planete-kraus.eu/tarot\">");
print_svg ("normal", 640, 480, 48, 64, 10, 0);
print_svg ("with a center", 640, 480, 48, 64, 10, 6);
print_svg ("portrait mode", 480, 640, 48, 64, 10, 0);
print_svg ("portrait, a center", 480, 640, 48, 64, 10, 6);
print_svg ("very thin portrait", 480, 2400, 64, 32, 10, 6);
printf ("</example>");
return 0;
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- tarot implements the rules of the tarot game
Copyright (C) 2019 Vivien Kraus
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tarot="http://planete-kraus.eu/tarot"
version="1.0">
<xsl:template match="tarot:example">
<html>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="tarot:test">
<h1><xsl:value-of select="@description" /></h1>
<svg width="{@width}" height="{@height}"
viewbox="{-(@width div 2)} {-(@height div 2)} {@width} {@height}">
<xsl:apply-templates select="tarot:card">
<xsl:sort select="@z" />
</xsl:apply-templates>
</svg>
</xsl:template>
<xsl:template match="tarot:card">
<g transform="translate({@x}, {-@y}) scale({@scale}) rotate({-@angle * 180 div 3.141592})">
<xsl:comment>z = <xsl:value-of select="@z" />, index = <xsl:value-of select="@index" /></xsl:comment>
<rect width="{../@card-width}" height="{../@card-height}"
x="{- ../@card-width div 2}" y="{- ../@card-height div 2}"
stroke="black" fill="yellow"/>
</g>
</xsl:template>
</xsl:stylesheet>
/* tarot implements the rules of the tarot game /* tarot implements the rules of the tarot game
* Copyright (C) 2018, 2019 Vivien Kraus * Copyright (C) 2018, 2019, 2020 Vivien Kraus
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -25,16 +25,6 @@ ...@@ -25,16 +25,6 @@
#define M_PI 3.14 #define M_PI 3.14
#endif /* __FRAMAC__ */ #endif /* __FRAMAC__ */
size_t
tarot_layout_position (double view_w, double view_h, double card_w,
double card_h, size_t n_my_cards, size_t n_adversaries,
const size_t *n_adv_cards, size_t n_center,
size_t max_dst, TarotPosition * dst)
{
return layout_position (view_w, view_h, card_w, card_h, n_my_cards,
n_adversaries, n_adv_cards, n_center, max_dst, dst);
}
size_t size_t
tarot_layout_hand (double view_w, double view_h, double card_w, double card_h, tarot_layout_hand (double view_w, double view_h, double card_w, double card_h,
size_t n_cards, size_t max, size_t start, size_t n_cards, size_t max, size_t start,
......
/* tarot implements the rules of the tarot game /* tarot implements the rules of the tarot game
* Copyright (C) 2018, 2019 Vivien Kraus * Copyright (C) 2018, 2019, 2020 Vivien Kraus
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -42,28 +42,6 @@ extern "C" ...@@ -42,28 +42,6 @@ extern "C"
}; };
typedef struct TarotCollision TarotCollision; typedef struct TarotCollision TarotCollision;
/**
* tarot_layout_position:
* @view_w: the width of the view
* @view_h: the height of the view
* @card_w: the width of each card
* @card_h: the height of each card
* @n_my_cards: the number of cards in my hand
* @n_adversaries: the number of adversaries
* @n_adv_cards: (array length=n_adversaries): the number of cards
* for each adversary
* @n_center: the number of cards in the center (dog / discard, handful)
* @max_dst: the number of positions
* @dst_out: (array length=max_dst): where to store the positions
* Returns: the number of cards to position (n_my_cards + sum
* (n_adv_cards) + n_adversaries + 1 + n_center)
*/
size_t tarot_layout_position (double view_w, double view_h, double card_w,
double card_h, size_t n_my_cards,
size_t n_adversaries,
const size_t *n_adv_cards, size_t n_center,
size_t max_dst, TarotPosition * dst_out);
/** /**
* tarot_layout_hand: * tarot_layout_hand:
* @position_out: (array length=max): * @position_out: (array length=max):
......
/* tarot implements the rules of the tarot game /* tarot implements the rules of the tarot game
* Copyright (C) 2018, 2019 Vivien Kraus * Copyright (C) 2018, 2019, 2020 Vivien Kraus
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -28,12 +28,6 @@ ...@@ -28,12 +28,6 @@
#include <tarot/layout.h> #include <tarot/layout.h>
static size_t layout_position (double view_w, double view_h, double card_w,
double card_h, size_t n_my_cards,
size_t n_adversaries,
const size_t *n_adv_cards, size_t n_center,
size_t max_dst, TarotPosition * dst);
static size_t layout_hand (double view_w, double view_h, double card_w, static size_t layout_hand (double view_w, double view_h, double card_w,
double card_h, size_t n_cards, size_t max, double card_h, size_t n_cards, size_t max,
size_t start, TarotPosition * position); size_t start, TarotPosition * position);
......
/* tarot implements the rules of the tarot game /* tarot implements the rules of the tarot game
* Copyright (C) 2018, 2019 Vivien Kraus * Copyright (C) 2018, 2019, 2020 Vivien Kraus
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -42,91 +42,6 @@ skip_adversaries (size_t n_adversaries, const size_t *n_adv_cards, ...@@ -42,91 +42,6 @@ skip_adversaries (size_t n_adversaries, const size_t *n_adv_cards,
} }
} }
static inline size_t
layout_position (double view_w, double view_h, double card_w, double card_h,
size_t n_my_cards, size_t n_adversaries,
const size_t *n_adv_cards, size_t n_center, size_t max_dst,
TarotPosition * dst)
{
/* First, the hand, then skip the adversaries, then the trick, then
the center. */
size_t ret = 0;
if (n_center != 0)
{
/* 1/3, 1/3, 1/3 */
size_t i;
layout_hand (view_w, view_h / 3, card_w, card_h, n_my_cards,
(ret < max_dst ? max_dst - ret : 0), 0, dst + ret);
for (i = 0; i < n_my_cards; i++)
{
if (ret < max_dst)
{
dst[ret].y -= view_h / 3.0;
dst[ret].z += 1;
dst[ret].z /= 3.0;
}
ret++;
}
/* Skip the adversaries */
skip_adversaries (n_adversaries, n_adv_cards, max_dst, dst, &ret);
layout_trick (view_w, view_h / 3, card_w, card_h, n_adversaries + 1,
(ret < max_dst ? max_dst - ret : 0), 0, dst + ret);
for (i = 0; i < n_adversaries + 1; i++)
{
if (ret < max_dst)
{
dst[ret].y += view_h / 3.0;
dst[ret].z += 0;
dst[ret].z /= 3.0;
}
ret++;
}
layout_center (view_w, view_h / 3, card_w, card_h, n_center,
(ret < max_dst ? max_dst - ret : 0), 0, dst + ret);
for (i = 0; i < n_center; i++)
{
if (ret < max_dst)
{
dst[ret].z += 2;
dst[ret].z /= 3.0;
}
ret++;
}
}
else
{
/* 1/2, 1/2 */
size_t i;
layout_hand (view_w, view_h / 2, card_w, card_h, n_my_cards,
(ret < max_dst ? max_dst - ret : 0), 0, dst + ret);
for (i = 0; i < n_my_cards; i++)
{
if (ret < max_dst)
{
dst[ret].y -= view_h / 4.0;
dst[ret].z += 1;
dst[ret].z /= 2.0;
}
ret++;
}
/* Skip the adversaries */
skip_adversaries (n_adversaries, n_adv_cards, max_dst, dst, &ret);
layout_trick (view_w, view_h / 2, card_w, card_h, n_adversaries + 1,
(ret < max_dst ? max_dst - ret : 0), 0, dst + ret);
for (i = 0; i < n_adversaries + 1; i++)
{
if (ret < max_dst)
{
dst[ret].y += view_h / 4.0;
dst[ret].z += 0;
dst[ret].z /= 2.0;
}
ret++;
}
}
return ret;
}
static inline size_t static inline size_t
layout_hand_one_row (double view_w, double view_h, double card_w, layout_hand_one_row (double view_w, double view_h, double card_w,
double card_h, size_t n_cards, size_t max, size_t start, double card_h, size_t n_cards, size_t max, size_t start,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment