Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package engine
- import o1.adventure.Action
- import o1.adventure.Area
- import o1.adventure.Item
- import o1.adventure.Player
- import scala.Vector
- class Adventure {
- /** The title of the adventure game. */
- val title = "Cook's Assistant Quest"
- private val castle = new Area("Castle", "You are in the Lumbridge castle. You see the cook here.")
- private val frontYard = new Area("Front yard", "You are in the front yard of the Lumbridge castle.")
- private val goblinField = new Area("Goblin field", "You are surrounded by goblins. Luckily they don't seem aggressive.")
- private val cowField = new Area("Cow field", "You are in the cow field. You see plenty of cows. Maybe you should try to milk one of them.")
- private val chickenCoop = new Area("Chicken coop", "You are in a chicken coop. Chickens are flocking around you.")
- private val grainField = new Area("Grain field", "You are in a grain field.")
- private val mill = new Area("Mill", "You are in the mill. This could probably be used for making flour.")
- private val northCastle = new Area("North of castle", "You are north of the castle.")
- private val destination = castle
- private val egg = new Item("battery", "It's a small battery cell. Looks new.")
- private val grain = new Item("remote", "It's the remote control for your TV.\nWhat it was doing in the forest, you have no idea.\nProblem is, there's no battery.")
- private val bucket = ???
- private val pot = ???
- castle.setNeighbors(Vector("east" -> frontYard))
- frontYard.setNeighbors(Vector("north" -> northCastle, "east" -> goblinField, "west" -> castle))
- goblinField.setNeighbors(Vector("north" -> cowField, "west" -> frontYard))
- cowField.setNeighbors(Vector("north" -> chickenCoop, "south" -> goblinField, "west" -> northCastle))
- chickenCoop.setNeighbors(Vector("south" -> cowField))
- northCastle.setNeighbors(Vector("north" -> grainField, "east" -> goblinField, "south" -> frontYard))
- grainField.setNeighbors(Vector("south" -> northCastle, "west" -> mill))
- mill.setNeighbors(Vector("east" -> grainField))
- val player = new Player(castle)
- var turnCount = 0
- val timeLimit = 40
- def isComplete = this.player.location == this.destination && this.player.has("remote") && this.player.has("battery")
- def isOver = this.isComplete || this.player.hasQuit || this.turnCount == this.timeLimit
- def welcomeMessage = "You are lost in the woods. Find your way back home.\n\nBetter hurry, 'cause Scalatut elämät is on real soon now. And you can't miss Scalkkarit, right?"
- def goodbyeMessage = {
- if (this.isComplete)
- "Home at last... and phew, just in time! Well done!"
- else if (this.turnCount == this.timeLimit)
- "Oh no! Time's up. Starved of entertainment, you collapse and weep like a child.\nGame over!"
- else // game over due to player quitting
- "Quitter!"
- }
- def playTurn(command: String) = {
- val action = new Action(command)
- val outcomeReport = action.execute(this.player)
- if (outcomeReport.isDefined) {
- this.turnCount += 1
- }
- outcomeReport.getOrElse("Unknown command: \"" + command + "\".")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement