2026-11-10 19:53:07 -06:00
extends TestBase
2026-11-10 18:35:24 -06:00
## The shared action menus (Actions): what the card, thread, group and spread
## menus offer in Play and Build, the ☰ menu, running an action, and placing
## a new card where the spread was right-clicked.
## Run: godot --headless --path . -s res://tests/test_actions.gd -- --sample
func _init ( ) - > void :
2026-11-10 19:53:07 -06:00
if not await start_main ( ) :
2026-11-10 18:35:24 -06:00
return
await _test_lists ( )
await _test_popup_and_run ( )
2026-11-14 14:28:59 -06:00
await _test_delete_key ( )
2026-11-10 19:53:07 -06:00
finish ( )
2026-11-10 18:35:24 -06:00
func _texts ( list : Array ) - > Array [ String ] :
var out : Array [ String ] = [ ]
for a : Dictionary in list :
if a . has ( " text " ) :
out . append ( str ( a [ " text " ] ) )
return out
func _test_lists ( ) - > void :
var t : = main . data . get_table ( " loot " )
var play : = _texts ( Actions . card ( main , t ) )
_check ( play . has ( " Roll " ) and not play . has ( " Delete table " ) , " Play: a card can be rolled, not deleted: %s " % str ( play ) )
var bg : = _texts ( Actions . background ( main , Vector2 . ZERO ) )
_check ( bg . has ( " Search… Ctrl+F " ) and bg . has ( " Shuffle all decks " ) and not bg . has ( " New card " ) , " Play spread menu: %s " % str ( bg ) )
main . set_mode ( Main . Mode . BUILD )
await _frames ( )
var build : = _texts ( Actions . card ( main , t ) )
_check ( build . has ( " Table settings… " ) and build . has ( " Colour " ) and build . has ( " Delete table " ) , " Build card menu: %s " % str ( build ) )
bg = _texts ( Actions . background ( main , Vector2 . ZERO ) )
2026-11-10 18:47:05 -06:00
_check ( bg . has ( " New card " ) and bg . has ( " Group the selection Ctrl+G " ) , " Build spread menu: %s " % str ( bg ) )
2026-11-10 18:35:24 -06:00
var key : = " "
for e in t . entries :
if not e . pipes . is_empty ( ) :
key = Roller . pipe_key ( t . id , e . id , e . pipes [ 0 ] )
break
var th : = _texts ( Actions . thread ( main , key ) )
_check ( th . has ( " Go to the end " ) and th . has ( " Delete thread " ) and th . has ( " Colour " ) , " thread menu: %s " % str ( th ) )
_check ( Actions . thread ( main , " nope:x>y " ) . is_empty ( ) , " a missing thread has no menu " )
func _test_popup_and_run ( ) - > void :
var at : = Vector2 ( - 900 , - 700 )
var pm : = Actions . popup_at ( main , Actions . background ( main , at ) , Vector2 ( 50 , 50 ) )
await _frames ( )
var sub : PopupMenu = null
Theme tiers 1-2: theme folders, mascot recolour, background scene and tile, frame sets, picture threads, sounds; nine new built-in themes
- ThemeAssets loads a theme's files; FrameSet + GradientMap (3-stop) generalise the card frame;
ThreadStrip draws threads from a picture; BoardBackdrop draws scene and tile; MascotArt
recolours Morgan by role (logo SVG now uses the Keep File importer); SoundBoard plays
roll / card turn / thread / click / ambient with View > Sound levels.
- Vaporwave, Synthwave, Cozy Autumn, Rustic, Woodsy, Sky Blue, Frutiger Aero, Gothic, Terminal:
generated art (tools/theme_art), sounds (tools/theme_sounds), settings (tools/theme_defs).
- Ten OFL fonts; --theme=<id> flag; docs/THEMES.md format spec; test_theme_assets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:05:40 -06:00
# The first submenu is New card ▸ (Sound ▸ comes later).
2026-11-10 18:35:24 -06:00
for c in pm . get_children ( ) :
Theme tiers 1-2: theme folders, mascot recolour, background scene and tile, frame sets, picture threads, sounds; nine new built-in themes
- ThemeAssets loads a theme's files; FrameSet + GradientMap (3-stop) generalise the card frame;
ThreadStrip draws threads from a picture; BoardBackdrop draws scene and tile; MascotArt
recolours Morgan by role (logo SVG now uses the Keep File importer); SoundBoard plays
roll / card turn / thread / click / ambient with View > Sound levels.
- Vaporwave, Synthwave, Cozy Autumn, Rustic, Woodsy, Sky Blue, Frutiger Aero, Gothic, Terminal:
generated art (tools/theme_art), sounds (tools/theme_sounds), settings (tools/theme_defs).
- Ten OFL fonts; --theme=<id> flag; docs/THEMES.md format spec; test_theme_assets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:05:40 -06:00
if c is PopupMenu and sub == null :
2026-11-10 18:35:24 -06:00
sub = c
_check ( sub != null and sub . item_count == MainEditing . ADD_KINDS . size ( ) , " New card ▸ lists every kind " )
var before : = main . data . tables . size ( )
_check ( Actions . press ( sub , " Roll table " ) , " pressing an item runs it " )
await _frames ( )
var added : RollTable = main . data . tables [ main . data . tables . size ( ) - 1 ]
_check ( main . data . tables . size ( ) == before + 1 and added . position . distance_to ( at ) < 2.0 , " the new card goes where the spread was clicked: %s " % str ( added . position ) )
pm . hide ( )
var t : = main . data . get_table ( " loot " )
Actions . set_card_colour ( main , t , " #2f8a4f " )
_check ( t . color == " #2f8a4f " , " Colour ▸ sets the card ' s colour " )
main . undo_redo . undo ( )
_check ( main . data . get_table ( " loot " ) . color == " " , " and it ' s undoable " )
var bar_pm : = main . top_bar . actions_menu . get_popup ( )
bar_pm . about_to_popup . emit ( )
_check ( bar_pm . item_count > 4 , " the ☰ menu fills with the spread ' s actions " )
2026-11-14 14:28:59 -06:00
## The Delete key: asks first (by default), deletes the selection as one undo
## step, and skips the question when "Ask before deleting" is off.
func _test_delete_key ( ) - > void :
main . set_mode ( Main . Mode . BUILD )
await _frames ( )
main . clear_selection ( )
main . editing . toggle_selected ( " loot " )
main . editing . toggle_selected ( " names " )
var found : = DeleteKey . target ( main )
_eq ( str ( found . get ( " what " , " " ) ) , " 2 cards " , " Delete names what it would delete " )
DeleteKey . press ( main )
await _frames ( )
var asked : = main . get_children ( ) . filter ( func ( n : Node ) - > bool : return n is ModalCard )
_check ( not asked . is_empty ( ) and main . data . get_table ( " loot " ) != null , " by default it asks first and deletes nothing yet " )
for dialog : ModalCard in asked :
dialog . close ( )
DeleteKey . set_asks ( main , false )
DeleteKey . press ( main )
await _frames ( )
_check ( main . data . get_table ( " loot " ) == null and main . data . get_table ( " names " ) == null , " with asking off it deletes both cards " )
main . undo_redo . undo ( )
await _frames ( )
_check ( main . data . get_table ( " loot " ) != null and main . data . get_table ( " names " ) != null , " one undo brings both back " )
DeleteKey . set_asks ( main , true )
main . clear_selection ( )
main . set_mode ( Main . Mode . PLAY )