Sure! Here's a basic implementation of a text-based game using JavaScript within a single HTML file. Please note that this example is very simplified and only showcases the structure of the game. In a complete game, you'd need to flesh out the different scenarios, actions, and graphics to make it engaging and interactive.
In this example, the game starts in a "Village" location. The player can input different actions like "build", "startWar", or "endWar". Based on the action, the game will call the appropriate function and display a message in the console. The game loop continuously prompts the player for new actions.
Keep in mind that this implementation lacks proper graphics, user interface, and other game mechanics. It's a starting point, and you can expand upon it by adding visuals, user input handling, and more complex gameplay elements to create a compelling medieval fantasy world game.