Sure! Here's an example of a simple text-based medieval fantasy game implemented as a single HTML file using JavaScript:
In this game, players are given the option to explore, visit a shop, or quit. When exploring, they may encounter various random events, including fights, finding treasures, or stumbling upon peaceful villages. The player's health and gold are tracked throughout the game. Additionally, at the shop, players can buy a health potion to restore their health.
Please note that this is a simplified example and can be expanded upon to create a more complex and engaging game.