import { Interpolation, Keyframes, Theme } from '@emotion/react'; import { Location, MaterialHelpDisplay, MaterialItem, MaterialMove } from '@gamepark/rules-api'; import { TFunction } from 'i18next'; import { ComponentType, HTMLAttributes, ReactNode } from 'react'; import { ItemContext, MaterialContext } from '../../locators'; import { ComponentDescription } from './ComponentDescription'; import { ItemButtonProps } from './ItemMenuButton'; export type MaterialHelpProps

= { closeDialog: () => void; } & Omit, 'type'>; export type MaterialHelpDisplayProps

= { item: Partial>; itemType: M; itemIndex?: number; displayIndex?: number; closeDialog: () => void; }; export type MaterialContentProps = { itemId: ItemId; itemIndex?: number; displayIndex?: number; type?: M; highlight?: boolean; playDown?: boolean; preview?: boolean; /** * What material with 2 faces displays on its back face (see {@link FlatMaterialDescription}), where children * are displayed on its front face. Which of the two a location goes to is decided by whoever renders the item, * from the face the location belongs to (see {@link Locator.getParentFace}). */ backChildren?: ReactNode; } & HTMLAttributes; /** * Base class to describe the material in a game */ export declare abstract class MaterialDescription

extends ComponentDescription { /** * Content of the help dialog opened when an item is clicked */ help?: ComponentType>; /** * Custom component to render the item display area in the help dialog. * Replaces the default item rendering (left side of the dialog). * Use this to customize item positioning, show multiple items, add overlays, etc. */ helpDisplay: ComponentType>; /** * The React component to display */ abstract content: (props: MaterialContentProps) => ReactNode; /** * If the component can be moved (token, cards...) or not (writing) */ isMobile: boolean; /** * See {@link getStaticItems} */ staticItem?: MaterialItem; /** * See {@link getStaticItems} */ staticItems: MaterialItem[]; /** * Return any items to display that are not part of the game state because they never move (board or unlimited stockpiles for instance). * Default value: {@link staticItem} if defined, otherwise {@link staticItems}. Override if the static items depends on the context. * * @param {MaterialContext} _context Context of the game * @returns {MaterialItem[]} the extra items to display */ getStaticItems(_context: MaterialContext): MaterialItem[]; /** * See {@link getStockLocation} */ stockLocation?: Location; /** * If items are created of deleted, by default the animation will fade in or fade out the item quickly. * If you want to animate from/to a location (a stockpile for instance), implement this function or simply {@link stockLocation}. * @param _item Item that is getting created or deleted. * @param _context Context of the game * @returns The location to animate from/to */ getStockLocation(_item: MaterialItem, _context: MaterialContext): Location | undefined; /** * See {@link getLocations} */ location?: Location; /** * See {@link getLocations} */ locations: Location[]; /** * The internal locations of the item, for instance the spots to put material on a board. * Will return {@link location} by default if defined, {@link locations} otherwise. * * @param _item The item that contains the locations * @param _context Context of the game */ getLocations(_item: MaterialItem, _context: ItemContext): Location[]; /** * This function determines if an item can currently be dragged by the user to perform a given move. * * @param _move The move to consider * @param _context Context of the item */ canDrag(_move: MaterialMove, _context: ItemContext): boolean; /** * This function determines if a move can be played by clicking for 1 second on an item * * @param move The move to consider * @param context Context of the item */ canLongClick(move: MaterialMove, context: ItemContext): boolean; /** * This function determines if a move can be played by clicking on an item * * @param move The move to consider * @param context Context of the item */ canShortClick(move: MaterialMove, context: ItemContext): boolean; /** * This function returns the move that should be played when clicking on an item, if any * * @param _context Context of the item */ getShortClickMove(_context: ItemContext): MaterialMove | undefined; /** * This function returns the local move that should be played when clicking on an item, if any * * @param _context Context of the item */ getShortClickLocalMove(_context: ItemContext): MaterialMove | undefined; /** * Thickness of the item */ thickness: number; /** * Returns the thickness of the item. Default to {@link thickness} * @param _item the item * @param _context Context of the item * @returns {number} The thickness */ getThickness(_item: MaterialItem, _context: ItemContext): number; /** * Any extra css to add on the item * @param _item The item * @param _context Context of the item * @returns The css, using Emotion framework */ getItemExtraCss(_item: MaterialItem, _context: ItemContext): Interpolation; /** * Whether the item should be highlighted * @param _item The item * @param _context Context of the item * @return true if the item should be highlighted */ highlight(_item: MaterialItem, _context: ItemContext): boolean | undefined; /** * The move to execute in order to display the help dialog about this item. * By default, open the help about this specific item, but it can be the help about the location of the item sometimes. * @param item The item * @param context Context of the item * @return The move to play to open the help dialog */ displayHelp(item: MaterialItem, context: ItemContext): MaterialMove | undefined; /** * Whether the item shows its back face on the game table. Only material with 2 faces ever does * (see {@link FlatMaterialDescription}), hence false here. * @param _item The item * @param _context Context of the item * @returns true if the face the player sees is the back of the item */ isFlippedOnTable(_item: Partial>, _context: MaterialContext): boolean; /** * Whether the item shows its back face in the help dialog. See {@link isFlippedOnTable}. * @param _item The item * @param _context Context of the item * @returns true if the face the player sees is the back of the item */ isFlippedInDialog(_item: Partial>, _context: MaterialContext): boolean; /** * Builds the CSS transform that will be applied to the item. * @param item Item to position * @param context Context of the item * @returns {string[]} a list of CSS transformations */ getItemTransform(item: MaterialItem, context: ItemContext): string[]; /** * Builds the CSS transform that will be applied to the item when hovered. * @param _item Item to position * @param _context Context of the item * @returns {string[]} a list of CSS transformations */ getHoverTransform(_item: MaterialItem, _context: ItemContext): string[]; /** * Provide the locations that are required to drop an item given the legal moves that currently allow to drag the item. * @param context Context of the item. Use {@link getItemFromContext} to get the item from it. * @param dragMoves Legal moves filtered to only keep those that allows the item to be dragged * @return All the locations where the item can be dropped */ getDropLocations(context: ItemContext, dragMoves: MaterialMove[]): Location[]; getMoveDropLocations(context: ItemContext, move: MaterialMove): Location[]; getTooltip(item: MaterialItem, t: TFunction, _context: ItemContext): string | null | undefined; menuAlwaysVisible: boolean; isMenuAlwaysVisible(_item: MaterialItem, _context: ItemContext): boolean; getItemMenu(_item: MaterialItem, _context: ItemContext, _legalMoves: MaterialMove[]): ReactNode; getHelpButton(item: MaterialItem, context: ItemContext, props?: Partial): import("@emotion/react/jsx-runtime").JSX.Element; getAnimationCss(animationKeyframes: Keyframes, duration: number): Interpolation; getHelpDisplayExtraCss(_item: Partial>, _context: ItemContext): Interpolation; } export type MaterialDescriptionRecord

= Record>;