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#action
and avoid multi-key mappings by reducingtimeoutlen
- We create the original
game
and enter a defaultstate
After this, nothing happens. Every time a key is pressed:
- The
vimcastle#action
function finds whichaction
is mapped to that key, and invokes it on the currentstate
- The
state
changes thegame
as needed, and potentially goes to anotherstate
usinggame.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.inventory
in the stateexplore
opens the Inventory screen.character
: A generic name for bothmonster
andplayer
.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 theweapon
slot, used when attacking in a fight and havingdmg
stats.event
: Very similar to astate
, but is always shown in theexplore
state. 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:eventgen
generatesevent
, andmonstergen
generates amonster
.monster
: A potential enemy; once in a fight with the player, it becomes anenemy
.state
: The object that controls what to do whenenter
ing 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 whichui
to draw. The screens folder contains all user interfaces for statesstat
: A character property that drives game mechanics, likestr
for 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.