
    ^h<                     L    d Z ddlZ G d d      Z G d d      Z G d d      Zy)	z9
Tile, Star, and Map classes for hexagon-grid rendering.
    Nc                       e Zd ZdZddZy)Tilez
    Represents a single tile in a grid.
    Attributes:
        x (int): Column index of the tile.
        y (int): Row index of the tile.
        content (list): List of content items in this tile.
    Nc                 6    || _         || _        |xs g | _        y N)xycontent)selfr   r   r	   s       /var/www/ig/map.py__init__zTile.__init__   s    }"    r   )__name__
__module____qualname____doc__r    r   r   r   r      s    %r   r   c                   2    e Zd ZdZdZddddddZdZd	Zd
 Zy)Starz
    A star located on a specific tile.

    Attributes:
        type (str): One of the allowed star types.
        location (Tile): The Tile instance where the star resides.
    )zyellow dwarfz	red dwarfz
blue giantz	red giantzyellow gigantz#FFFF00z#FF0000z#0000FFz#FF4500z#FFD700g?g      ?c                     |t         j                  vrt        d|      t        |t              st        d      || _        || _        y )NzInvalid star type: z location must be a Tile instance)r   ALLOWED_TYPES
ValueError
isinstancer   	TypeErrortypelocation)r
   	star_typer   s      r   r   zStar.__init__0   sG    D...29-@AA(D)>??	 r   N)	r   r   r   r   r   STAR_COLORSDWARF_SCALEGIANT_SCALEr   r   r   r   r   r      s7    M "!!!!K KK!r   r   c                       e Zd ZdZddZd Zy)Mapz
    A hexagon-tiled map of arbitrary size.
    Attributes:
        rows (int): Number of rows.
        cols (int): Number of columns.
        tile_size (float): Size (radius) of each hexagon.
        tiles (dict): Mapping of (x, y) => Tile objects.
    c                     || _         || _        || _        i | _        t	        |      D ]-  }t	        |      D ]  }t        ||      | j                  ||f<    / y r   )rowscols	tile_sizetilesranger   )r
   r#   r$   r%   r   r   s         r   r   zMap.__init__B   sR    		"
tA4[%)!QZ

Aq6" ! r   c                 f   | j                   }t        j                  d      |z  }|dfd|z  dfd|z  |fd|z  d|z  f|d|z  fd|fg}|d| j                  z  dz   z  }|d| j                  z  dz   z  }d| d| dg}| j
                  j                         D ]  \  \  }}}	|dz  |z  |dz  |z  |dz  |z  z   dj                  fd	|D              }
|j                  d
|
 d       t        |	dd      }|bd|z  z   }|z   }d|j                  v rt        j                  nt        j                  }||z  }t        j                  j                  |j                  d      }|j                  d| d| d| d| d|j                    d        |j                  d       dj                  |      S )zO
        Returns an HTML (SVG) string representing the hexagonal grid.
           r            z5<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0  z">c              3   >   K   | ]  \  }}|z    d |z      yw),Nr   ).0vxvydxdys      r   	<genexpr>zMap.render.<locals>.<genexpr>a   s)     BE&"bbeWAbeW-Es   z<polygon points="z." fill="#000" stroke="#333" stroke-width="2"/>starNdwarfz#FFFz<circle cx="z" cy="z" r="z" fill="z	"><title>z</title></circle>z</svg>
)r%   mathsqrtr$   r#   r&   itemsjoinappendgetattrr   r   r   r   r   getname)r
   Shvertswidthheightpartsr   r   tileptsr6   cxcyscalercolorr3   r4   s                    @@r   renderz
Map.renderK   s    NNIIaL1FUAJUAJUAENAJF
 Q]Q&'a$))ma'(CE7!F8SUV
 !JJ,,.LFQDQBa%1q1uqy(B((BEBBCLL#C5(VW 4.D!a%Z!V-4		-A))".. I((,,TYY?"2$fRDaS H"ii[ ) !' /0 	Xyyr   N)2   )r   r   r   r   r   rN   r   r   r   r!   r!   9   s    0, r   r!   )r   r9   r   r   r!   r   r   r   <module>rP      s.    % %!! !!H>  > r   