HawkI wrote:How does this game know what items to give to the player
At
level generation, after most floor features have been placed, the code calls
_builder_items() to generate items for the floor. This calls
items(), requesting an OBJ_RANDOM item a
randomized amount of times, using the absolute depth of the floor as the item level. Item level affects generation of each item type differently, but often results in fancier items being generated at deeper depths. You can see
here the OBJ_RANDOM weightings for each item type, with Gold being common and Staves exceedingly rare. For each item thus generated, the game will then
try to place it somewhere on the level, but it can still delete the item before the floor is finalized if an eligible spot isn't found quickly enough.
HawkI wrote:as well as know the precise amount of hurdles the player can handle?
The game doesn't track this. You can follow
the level generation call to
_builder_monsters() to see exactly what happens there: It generates a
randomized amount of monsters for any given floor, with the hells getting extra monsters and pan/crypt slightly fewer. Dungeon depths for monster generation can be found in
mon-pick-data.h, with the caveat that out-of-depth monsters will sometimes be placed. Floor generation also typically has areas placed through vault Lua, where the monsters and items are defined in the vault's .des file.
I should mention that you don't need to know any of this to play the game. You can search the git repository with grep or through github if you're curious and want to learn about the code, but if you just want to play Crawl none of this is important.