Over the recent break, I built a basic text adventure game called Power BI Quest for Power BI’s Bookmarking Contest. You can play it on the Data Stories Gallery. It is intentional kitsch and was meant to be a quick homage to early games like Zork minus the ability to type in text and more fully explore the fictional world. Instead, Power BI Quest guides you down a path by having users select between two pre-made decisions.
Apart from setting up the bookmarks used to drive the interactions, Power BI Quest is primarily data-driven. The thought of putting all of that text into Power BI’s built-in, static text boxes makes me shudder. Instead, the text adventure is all based on an Excel data source alongside the HTML Viewer custom visual. Even the font and font size are inline styles, meaning that different stages in the game could have different fonts, etc. (I ended up keeping it consistent for Power BI Quest though).
Here’s what the data looks like. Note the LocationHTML, DecisionAHTML, and DecisionBHTML fields to the right. Those use an Excel formula to dynamically construct the HTML text and style based on the leftmost columns.
Once that data is in Power BI Desktop, the main game page has three corresponding HTML Viewer custom visuals.
By default, the HTML Viewer will show all records at once. To narrow it down to individual rows, I simply applied a filter for the appropriate location.
The main work was setting up the user selection to move through the game. Individual circle shapes needed to be created for each possible decision (bookmark Link values in shapes cannot be bookmarked themselves). I then positioned each shape and had to make them visible or not based on the current location record. You can see the numerous shape objects that were required, which appear with the underscore prefix in the Selection Pane.
Once everything was setup, it was a matter of showing what needed to be shown for the first stage using the Selection Pane, making the bookmark, changing the appropriate decision shapes to link to the bookmark, and then repeat at each stage. Note how in this example “Community Castle” stage, only two decisions (_MountainsOfDAX and _FilterForest) are visible while all others are hidden.
After publishing the “report” to the Power BI Service, all of the bookmarks kicked in, making Power BI Quest a reality.
If you are interested in looking at the source in more detail, a link to the Excel and Power BI Desktop files appears below. The December 2017 version of Power BI Desktop (or eventual future versions) is required.
Download from GitHub: https://github.com/deldersveld/pbiQuest