July 2018
Intermediate to advanced
400 pages
12h 14m
English
What if a player were to order something other than Dragon’s Breath? toDragonSpeak would still be called. This is not what you want.
Add a conditional to Tavern.kt’s placeOrder function to skip calling toDragonSpeak if the player did not order Dragon’s Breath:
Listing 7.6 Comparing strings in placeOrder (Tavern.kt)
...
private fun placeOrder(menuData: String) {
...
val phrase = "Ah, delicious $name!"
println("Madrigal exclaims: ${toDragonSpeak(phrase)}")
val phrase = if (name == "Dragon's Breath") {
"Madrigal exclaims ${toDragonSpeak("Ah, delicious $name!")}"
} else {
"Madrigal says: Thanks for the $name."
}
println(phrase)
}
Comment out your Dragon’s Breath order in the main function – we will return to ...
Read now
Unlock full access