-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from scalaquest/feature/base-model-scaladoc
ScalaDoc for Model, Resolver, Interpreter, Reducer; package refactoring
- Loading branch information
Showing
78 changed files
with
1,367 additions
and
904 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
core/src/main/scala/io/github/scalaquest/core/model/Action.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
package io.github.scalaquest.core.model | ||
|
||
/** | ||
* An action is a base representation of a single 'move' into the Game. To be significant, could be | ||
* associated to one or more [[Model.Item]]. | ||
*/ | ||
trait Action | ||
|
||
/** | ||
* Companion object for the [[Action]] trait, including some commonly actions. | ||
*/ | ||
object Action { | ||
|
||
/** | ||
* Some commonly used [[Action]] s. | ||
*/ | ||
object Common { | ||
import io.github.scalaquest.core.model.Room.Direction | ||
|
||
case object Take extends Action | ||
case object Open extends Action | ||
case object Close extends Action | ||
case object Enter extends Action | ||
case object Eat extends Action | ||
case object Inspect extends Action | ||
case class Go(direction: Direction) extends Action | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
core/src/main/scala/io/github/scalaquest/core/model/GameState.scala
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
core/src/main/scala/io/github/scalaquest/core/model/ItemRef.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package io.github.scalaquest.core.model | ||
|
||
trait ItemRef |
22 changes: 0 additions & 22 deletions
22
core/src/main/scala/io/github/scalaquest/core/model/ItemRetriever.scala
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
core/src/main/scala/io/github/scalaquest/core/model/MatchState.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.github.scalaquest.core.model | ||
|
||
/** | ||
* Represents the current state of the match. | ||
* @tparam I | ||
* the specific implementation of the [[Model.Item]]. | ||
*/ | ||
trait MatchState[I <: Model#Item] { | ||
|
||
/** | ||
* The player involved into the match. As it is a core concept, an instance of [[Player]] is | ||
* included into the [[MatchState]]. | ||
* @return | ||
* The current [[Player]]. | ||
*/ | ||
def player: Player[I] | ||
|
||
/** | ||
* Indicates whether the match has reached the end. When true, the entire match ende after the | ||
* current pipeline round. | ||
* @return | ||
* True if the match has to end after the current round, false otherwise. | ||
*/ | ||
def ended: Boolean | ||
|
||
/** | ||
* Represents the configuration match, in terms of [[Room]] s and [[Model.Item]]. | ||
* @return | ||
* a [[Map]] representing all [[Room]] s of the match, and the [[Model.Item]] s in them. | ||
*/ | ||
def geography: Map[Room, Set[I]] | ||
} |
3 changes: 3 additions & 0 deletions
3
core/src/main/scala/io/github/scalaquest/core/model/Message.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
package io.github.scalaquest.core.model | ||
|
||
/** | ||
* A representation a single line of output to render to the user at the end of the pipeline round. | ||
*/ | ||
trait Message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
core/src/main/scala/io/github/scalaquest/core/model/Player.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,23 @@ | ||
package io.github.scalaquest.core.model | ||
|
||
/** | ||
* Represents the main properties of the character impersonated by the user. | ||
* @tparam I | ||
* a subtype of [[Model.Item]], the one effectively used into the model implementation. | ||
*/ | ||
trait Player[I <: Model#Item] { | ||
|
||
/** | ||
* [[Model.Item]] s that the player brings with him. In a contrete story, this not necessarily a | ||
* real bag: it is simply an intuitive term to refer to this set of items. | ||
* @return | ||
*/ | ||
def bag: Set[I] | ||
|
||
/** | ||
* The current location of the player into the map. | ||
* @return | ||
* The current location of the player into the map. | ||
*/ | ||
def location: Room | ||
} |
41 changes: 33 additions & 8 deletions
41
core/src/main/scala/io/github/scalaquest/core/model/Room.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,43 @@ | ||
package io.github.scalaquest.core.model | ||
|
||
import io.github.scalaquest.core.model.Direction.Direction | ||
import io.github.scalaquest.core.model.std.StdRoom | ||
|
||
object Direction extends Enumeration { | ||
type Direction = Value | ||
val NORTH, SOUTH, WEST, EAST, UP, DOWN = Value | ||
} | ||
import io.github.scalaquest.core.model.Room.Direction | ||
|
||
/** | ||
* A geographical portion of the match map. | ||
* | ||
* This is one of the basic block for the story build by the storyteller, as it is used to identify | ||
* [[Player]] 's and [[Model.Item]] s' location, in a given moment of the story. | ||
*/ | ||
trait Room { | ||
|
||
/** | ||
* A textual identifier for the room. | ||
* @return | ||
* A textual identifier for the room. | ||
*/ | ||
def name: String | ||
|
||
/** | ||
* Identifies rooms near to the current one, at the cardinal points. | ||
*/ | ||
def neighbors(direction: Direction): Option[Room] | ||
} | ||
|
||
case class SimpleRoom(name: String, _neighbors: () => Map[Direction, Room]) extends Room { | ||
override def neighbors(direction: Direction): Option[Room] = _neighbors() get direction | ||
} | ||
|
||
object Room { | ||
def apply(name: String, neighbors: () => Map[Direction, Room]): Room = StdRoom(name, neighbors) | ||
def apply(name: String, neighbors: () => Map[Direction, Room]): Room = SimpleRoom(name, neighbors) | ||
|
||
sealed trait Direction | ||
|
||
object Direction { | ||
case object North extends Direction | ||
case object South extends Direction | ||
case object East extends Direction | ||
case object West extends Direction | ||
case object Up extends Direction | ||
case object Down extends Direction | ||
} | ||
} |
Oops, something went wrong.