Text based games help

I just got into these games called text based games which instead of graphics
they just have words and the whole story is played with words that appear as
you do stuff.
I was wondering what the main idea is behind them and maybe how it works
or a good place to learn about this.
I know it would have to do with something like an if else
kind of thing but would have to get more advanced.
:D