Vimcastle is a randomly generated game, built for quick and relax games. There is no game loop, no timing features. Only actions, and results.
Everything starts in vimcastle.vim.
- We prepare the UI in ui.vim
- We bind most keys to
vimcastle#actionand avoid multi-key mappings by reducingtimeoutlen - We create the original
gameand enter a defaultstate
After this, nothing happens. Every time a key is pressed:
- The
vimcastle#actionfunction finds whichactionis mapped to that key, and invokes it on the currentstate - The
statechanges thegameas needed, and potentially goes to anotherstateusinggame.enter
This project uses Vader to make sure everything works as the game gets more complex.
Because of the random nature of the game, two tests are of high interest:
- runthrough.vader plays the game multiple times, and compiles statistics to make sure that the player survives a minimal amount of turns and dies after a maximum amount of turns on average.
- stories.vader tries to fight every monster and create every equippable item, and reports the per-monster difficulty.
Both tests rely on testutils.vim to auto-play the game and make reasonable automated decisions.
action: Something bound to a key, specific to a state; e.g.inventoryin the stateexploreopens the Inventory screen.character: A generic name for bothmonsterandplayer.equippable: Represents weapons, armors and other items that can be "equipped" by a character. Only one equippable item can be used byslot. The only "special" slot is theweaponslot, used when attacking in a fight and havingdmgstats.event: Very similar to astate, but is always shown in theexplorestate. This defines what the player can do and see, and is persisted between states. An example of an event could beencounter, orfinditem.game: Contains the whole state of the game.gen: A suffix for generators. An example:eventgengeneratesevent, andmonstergengenerates amonster.monster: A potential enemy; once in a fight with the player, it becomes anenemy.state: The object that controls what to do whenentering that state, and what to do when a key is pressed. All states are in the states folder.scene: A set of events, monsters, items, etc. in which the player evolves.screen: Represents both the currentstate, and whichuito draw. The screens folder contains all user interfaces for statesstat: A character property that drives game mechanics, likestrfor strengths, which mainly drives the attack damage.story: The parent of allscenes; defines an entry point, and the player can move between scenes of a story, but not between stories.