TextGames: Learning to Self-Play Text-Based Puzzle Games via Language Model Reasoning