Ë
    íÆjR  ã                  ó²  — d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	  ed«      Z
	 ddlmZ  ej                  dej                   «      Z ej                  d	ej                   «      Z ej                  d
ej                   «      Z ej                  dej                   «      Zddd„Zdd„Zddd„Zdd„Zdd„Zdd„Zde
df	 dd„Zy# e$ r	 ddlmZ Y Œ¥w xY w)a„  The City: open modern cities for a custom 3D game (GTA-like streets, downtowns, traffic and crime).

A custom 3D game whose words name an open modern city gets the city kit (JavaScript ES modules,
built from the city source as `citykit.tar.gz`, code only) and the builder contract joins the brief. The builder places
streets, buildings and traffic with `createCity` (CITY.md) instead of drawing them. Player vehicles come from the Garage
kit when it is attached. The Engine stages attachments at `.forge/attachments/att<N>/original.<ext>` in order, like
games_garage and games_town. A missing bundle = no city kit, the build goes on as before.
é    )ÚannotationsN)ÚPath)ÚAnyz/srv/forge-assets/dist)Ú	town_kindzþ\b(gta|grand theft(?: auto)?|open[- ]city|open[- ]world city|downtown|crime city|gangsters?|mafia|taxi driver|city streets?|city blocks?|metropolis|metropolises|skyscrapers?|new york|hong kong|big city|modern city|urban crime|los angeles|chicago|miami)\bz?\b(heists?|police chases?|car chases?|getaways?|cops?|police)\bz2\b(city|cities|urban|streets?|avenues?|downtown)\ba  \b(city[- ]builders?|city[- ]building|cities[: ]+skylines|sim ?city|city sims?|tycoon|chess|checkers|board game|racing (?:circuits?|tracks?)|race tracks?|grand prix|formula (?:1|one)|circuits?|side[- ]scroll\w*|pixel|2d|space|spaceships?|starships?|aliens?|asteroids?|galax\w*)\bÚ c                óP  — t        | dd «      }t        | dd«      t        | dd«      t        | dd«      t        | dd«      t        | dd«      dj                  t        | d	d «      xs g «      t        |d
d «      xs dt        |dd «      xs d|xs dg	}dj                  d„ |D «       «      S )NÚworldÚtitler   ÚpitchÚgenreÚ	core_loopÚfirst_versionú ÚmoodÚsettingÚlookc              3  ó8   K  — | ]  }|sŒt        |«      –— Œ y ­w)N)Ústr)Ú.0Úps     úE/home/claude-agent/forge-build/forge-assets/omg/factory/games_city.pyú	<genexpr>z_card_text.<locals>.<genexpr>+   s   è ø€ Ò/˜qªQ”C˜—FÑ/ùs   ‚Š)ÚgetattrÚjoin)ÚcardÚpromptr	   Úpartss       r   Ú
_card_textr   &   s´   € Ü�D˜' 4Ó(€EÜ�T˜7 BÓ'¬°°wÀÓ)CÄWÈTÐSZÐ\^ÓE_ÔahÐimÐozÐ|~ÓaÜ�T˜?¨BÓ/°·±¼'À$ÈÐPTÓ:UÒ:[ÐY[Ó1\Ü�U˜I tÓ,Ò2°´G¸EÀ6È4Ó4PÒ4VÐTVÐX^ÒXdÐbdðf€Eð �8‰8Ñ/ EÔ/Ó/Ð/ó    c                óŽ   — t        | dd «      }t        | dd «      dk(  xr' t        | dd «      dk(  xr |d uxr t        |dd «      dv S )Nr	   ÚlaneÚcustomÚstageÚnoneÚview)ÚfirstÚthirdÚtop)r   )r   r	   s     r   Ú	city_fitsr)   .   se   € Ü�D˜' 4Ó(€EÜ�D˜& $Ó'¨8Ñ3ò J¼ÀÀgÈtÓ8TÐX^Ñ8^ò JÐchÐptÐctò JÜ˜˜v tÓ,Ð0IÐIðKr   c                óâ   — t        | |«      }t        | |«      €t        j                  |«      ryt        j                  |«      ryt
        j                  |«      rt        j                  |«      ryy)z§'city' or None, deterministic from the words. A medieval or Breton settlement is never a city, and neither is a
    racing circuit, a city builder or a side view game.NÚcity)r   r   Ú_NOT_CITY_REÚsearchÚ_CITY_REÚ	_CRIME_REÚ_CITY_CONTEXT_RE)r   r   Útexts      r   Ú	city_kindr2   4   s^   € ô �d˜FÓ#€DÜ��vÓÐ*¬l×.AÑ.AÀ$Ô.GØÜ‡��tÔØÜ×Ñ˜ÔÔ"2×"9Ñ"9¸$Ô"?ØØr   c                óô   — 	 | dz  j                  «       j                  «       xs dS # t        $ r Y nw xY w	 t        j                  | dz  j                  «       «      j                  «       S # t        $ r Y yw xY w)zjsha256 of the city kit tarball (the one `citykit.sha` names), for meta; None when the kit is not vendored.zcitykit.shaNúcitykit.tar.gz)Ú	read_textÚstripÚOSErrorÚhashlibÚsha256Ú
read_bytesÚ	hexdigest)Ú
assets_dirs    r   Úcity_shar=   A   sy   € ðØ˜]Ñ*×5Ñ5Ó7×=Ñ=Ó?ÒGÀ4ÐGøÜò ÙðúðÜ�~‰~˜zÐ,<Ñ<×HÑHÓJÓK×UÑUÓWÐWøÜò Ùðús   ‚$' §	3²3·3A+ Á+	A7Á6A7c                óV   — d| › d�t        j                  |«      j                  «       z   S )Nzdata:z;base64,)Úbase64Ú	b64encodeÚdecode)ÚmimeÚdatas     r   Ú	_data_urlrD   M   s*   € Ø�4�&˜Ð!¤F×$4Ñ$4°TÓ$:×$AÑ$AÓ$CÑCÐCr   c                ó6   — |rdnd}d| z   dz   | z   dz   |z   dz   S )zNThe builder contract for the city kit. code_id is the attachment id (att2...).z¢ The player's own vehicles come from the Garage kit (`createVehicle`, see the Garage contract); the city brings the streets, buildings and its own moving traffic.zY No Garage kit is attached, so the cars are the city kit's own; never draw a car by hand.z. THE CITY COMES FROM OUR CITY KIT. Attachment z„ is the city kit (JavaScript ES modules, three.js, a gzipped tar). First run: `mkdir -p src/lib/city && tar -xzf .forge/attachments/aX  /original.* -C src/lib/city`, then read `src/lib/city/CITY.md` and build the city with `createCity` from `src/lib/city/game.mjs`. Never draw buildings or roads yourself: the kit lays the streets, blocks and buildings. Spawn the player at the city's `spawn`. Collide with the returned `colliders` and with `carPoses()` for every car on the road.z Do not edit src/lib/city.© )Úcode_idÚgarageÚcarss      r   Úcity_contractrJ   Q   s\   € ñ ñAàvð 	ð 	9¸7ÑBð  FLñ  	Lð  OVñ  	Vð	ñ	ð ñ		ð !=ñ		=ðr   Fc                óä   — t        | «      syt        | |«      €y	 |dz  j                  «       }d|dz   › �}t	        d|«      ddddœg}|t        ||«      d	t        |«      d
œfS # t        $ r Y yw xY w)a,  (attachments, contract, meta) or None. first_index = attachments already in the brief (the Engine numbers att1,
    att2... in list order). garage = the Garage kit is attached too. None when the game is not a city or the bundle is
    missing: the city kit is a bonus, never a reason to fail a build.Nr4   Úatté   zapplication/gzipzCity kit (JavaScript, three.js)z/code to extract into src/lib/city and use as is)ÚurlÚfilenameÚaltÚroler+   )ÚkindÚsha)r)   r2   r:   r7   rD   rJ   r=   )r   Úfirst_indexr   r<   rH   ÚcoderG   Úattss           r   Úcity_attachmentsrW   _   s    € ô
 �TŒ?ØÜ��vÓÐ&ØðØÐ-Ñ-×9Ñ9Ó;ˆð �K !‘OÐ$Ð%€GäÐ,¨dÓ3ÐAQÐZ{ØBñ	Dð€Dð ”˜w¨Ó/¸&ÌÐR\ÓI]Ñ1^Ð^Ð^øô ò Ùðús   ›A# Á#	A/Á.A/)r   )r   r   r   r   Úreturnr   )r   r   rX   Úbool)r   r   r   r   rX   ú
str | None)r<   r   rX   rZ   )rB   r   rC   ÚbytesrX   r   )rG   r   rH   rY   rX   r   )r   r   rT   Úintr   r   r<   r   rH   rY   rX   z-tuple[list[dict[str, Any]], str, dict] | None)Ú__doc__Ú
__future__r   r?   r8   ÚreÚpathlibr   Útypingr   ÚDISTÚ forge_corp.api.routes.games_townr   ÚImportErrorÚ
games_townÚcompileÚIr.   r/   r0   r,   r   r)   r2   r=   rD   rJ   rW   rF   r   r   ú<module>rh      sõ   ðñõ #ã Û Û 	Ý Ý áÐ$Ó%€ð%Ý:ð ˆ2�:‰:ð$à%'§T¡Tó+€ð
 ˆB�J‰JÐYÐ[]×[_Ñ[_Ó`€	Ø�2—:‘:ÐSÐUW×UYÑUYÓZÐ Øˆr�z‰zðCàDFÇDÁDóJ€ô0óKô
ó	óDóð ACÐW[Ðlqð _ØGô_øðS ò %ß$ð%ús   ªC ÃCÃC