Skip to content

Commit

Permalink
Grammar corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
RowDaBoat committed Jun 23, 2024
1 parent 7c91ec9 commit 6c5cc7f
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Test and Publish](https://github.com/RowDaBoat/keep-engine/actions/workflows/ci.yml/badge.svg)](https://github.com/RowDaBoat/keep-engine/actions/workflows/ci.yml)

**Keep** is a game engine for text based adventure games written in Kotlin. It features an easy to read and write domain specific language to design scenes, items, characters, actions, and state machines.
**Keep** is a game engine for text-based adventure games written in Kotlin. It features an easy to read and write domain specific language to design scenes, items, characters, actions, and state machines.

## Index

Expand All @@ -15,7 +15,7 @@

## Setup

Add the JitPack to your repositories and `keep-keep` to your dependencies on your project's `build.gradle.kts`.
Add JitPack to your repositories and `keep-engine` to your dependencies on your project's `build.gradle.kts`.

```kotlin
repositories {
Expand Down
12 changes: 6 additions & 6 deletions doc/actions-and-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

## Predefined Actions

In `Keep` actions are used to define the game's behavior when the player interacts with the scenes, the engine has some already defined basic actions:
In `Keep` actions are used to define the game's behavior when the player interacts with the scenes, the engine has some predefined basic actions:

- `Leave()`: leaves an item from the player's inventory on the scene.
- `Take()`: takes an item from the scene and puts it into the player's inventory.
- `Talk()`: talks to another character in the scene.
- `Look()`: looks at an item on the room or in the player's inventory
- `Goto(target, description)`: changes the current scene for `target` and shows as `description` in the actions menu.
- `Look()`: looks at an item in the room or in the player's inventory
- `Goto(target, description)`: changes the current scene for `target` and is displayed as `description` in the "actions" menu.

## Subscribing to Events

Expand All @@ -28,12 +28,12 @@ val potion =
}
```

There is a shorthand `on` method for each of the predefined action's events, each one is equivalent to calling `on(eventKey)` with the key corresponding to each event.
There is a shorthand `on` method for each of the predefined actions' events, each one is equivalent to calling `on(eventKey)` with the key corresponding to each event.
You can use `on(eventKey)` to subscribe to events from your own custom actions.

## Custom Actions

To create an action with custom behavior you can just use the `action` function:
To create an action with custom behavior, you can use the `action` function:

```kotlin

Expand All @@ -55,4 +55,4 @@ val safe = item("safe", "Safe", "A huge safe, what is inside it?")
}
```

You can also implement the `Action` interface if you need a more complex integration.
You can also implement the `Action` interface if you need a more complex behavior.
10 changes: 5 additions & 5 deletions doc/characters.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Simple Characters

Simple characters are declared using the `npc` function with a `key` to identify them, a display `name`, and a `description`. Typically, a callback is registered using `onTalk`, it will be called when the `Talk` action is used on the character.
Simple characters are declared using the `npc` function with a `key` to identify them, a display `name`, and a `description`. Typically, a callback is registered using `onTalk`, which is called when the `Talk` action is used on the character.

The following example shows Bob, who can be talked to by the player and will answer back.

Expand All @@ -13,7 +13,7 @@ val bob =
"Bob",
"Bob, an NPC."
) onTalk {
io.paragraph("${target.name}: Hello ${game.mainCharacter.name}!.")
io.paragraph("${target.name}: Hello, ${game.mainCharacter.name}!.")
io.promptContinue()
}
```
Expand All @@ -22,7 +22,7 @@ val bob =

Characters can also hold state, allowing them to react to the world and the player's actions. Use an overload of the `npc` function, and declare `key`, `initialState` and `states` parameters.

Each state has its own `key`, also the state has `name` and `description` properties that replace the character's ones. Each state can have its own subscriptions to `onTalk` or any other actions, allowing the character to change its dialogues and behavior. Name and description are set on each state to make it easy to reflect changes on each character.
Each state has its own `key`, the state also has `name` and `description` properties that replace the character's ones. Each state can have its own subscriptions to `onTalk` or any other actions, allowing the character to change its dialogues and behavior. Setting the name and description on each state makes it easy to reflect changes in the character.

The following example shows Alice, who greets the player by his name only once.

Expand All @@ -36,14 +36,14 @@ val alice =
"Alice",
"Alice, another NPC.",
) onTalk {
io.paragraph("${target.name}: Oh, hi ${game.mainCharacter.name}!.")
io.paragraph("${target.name}: Oh, hi, ${game.mainCharacter.name}!.")
target.change("regular")
io.promptContinue()
},
characterState(
"regular",
"Alice",
"Alice, another NPC.",
"Alice, another NPC, she has already greeted you.",
) onTalk {
io.paragraph("${target.name}: Hello.")
io.promptContinue()
Expand Down
12 changes: 6 additions & 6 deletions doc/dialogue-graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

## Simple Dialogues

A `DialogGraph` is declared using `dialogues` and `dialogue`. Declare a `dialogue` with a `key` to identify it and a few lines, then pass it to `Scene` using `dialogueGraphs` to register it:
A `DialogGraph` is declared using `dialogues` and `dialogue`. Declare a `dialogue` with a `key` to identify it and a few lines. Then, pass it to a `Scene` using `dialogueGraphs` to register it:

```kotlin
val introduction = dialogues(
dialogue(
"introduction",
"Bob" say "Keep dialogues are declarative and easy.",
"Bob" say "Keep dialogues are declarative and easy to use.",
"Alice" say "Just using a few `say` lines is the simplest form.",
"John" say "Alright, got it."
)
)

val scene = scene(key, title, narration, items, characters, dialogueGraphs(introdcution))
val scene = scene(key, title, narration, items, characters, dialogueGraphs(introduction))
```

## Multiple Lines
Expand All @@ -34,7 +34,7 @@ dialogue(

## Callbacks on Lines

Dialogues can run callbacks when a line is shown:
Dialogues can execute callbacks when a line is shown:

```kotlin
val introduction = dialogues(
Expand All @@ -49,7 +49,7 @@ val introduction = dialogues(

## Go To

Dialogue flow can be reused and redirected using the `goto` function
A dialogue can be reused and redirected using the `goto` function:

```kotlin
val introduction = dialogues(
Expand All @@ -72,7 +72,7 @@ val introduction = dialogues(

## Dialogue Options

A `dialogue` can branch by providing options to the player. Combine `opt between` and `option`s with `goto` allowing complex dialogues to be written:
A `dialogue` can branch by providing options to the player. Combine `opt between` and `option` with `goto`, allowing complex dialogues to be created:

```kotlin
val bobDialogue = dialogues(
Expand Down
30 changes: 19 additions & 11 deletions doc/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
# Keep - Getting Started

## Index
- [Starting off with a simple game](#starting-off-with-a-simple-game)
- [Getting Started with a simple game](#getting-Started-with-a-simple-game)
- [Changing Scenes](#changing-scenes)
- [Adding Items](#adding-items)
- [Adding NPCs](#adding-npcs)

## Starting off with a simple game
## Getting Started with a simple game

To create a `Game` you need at least:
- A `Character` for your main character.
- A `Scene` where the game starts.

Create a main character, it requires a key (`"player"`) to identify it, and a name to display (`"you"`):
Create a main character, it requires:
- A key (`"player"`) to identify it.
- A name to display (`"you"`).

```kotlin
val mainCharacter = mainCharacter("player", "you")
```

Then create a scene, it requires a key (`"hello-keep"`) to identify it, and a title to display (`"Hello Keep"`), scenes usually also have a `narration` as third argument to provide context to the player. The last argument is very important, but we won't use it for now so we just use `actions()`.
Then, create a scene, it requires:
- A key (`"hello-keep"`) to identify it.
- A title to display (`"Hello Keep"`).
- A `narration` to provide context to the player.

The last argument is very important, but we won't use it for now, so we just use `actions()`.

```kotlin
val scene = scene("hello-keep", "Hello Keep", "Keep is a text game engine.", actions())
```

Next create a game using the previously declared objects. The last argument is the `key` of the initial scene.
Next, create a game using the previously declared objects. The last argument is the `key` of the initial scene.

```kotlin
val game = Game(mainCharacter, scenes(scene), "hello-keep")
```

Finally, start and run the game:
Finally, start and run the game with:

```kotlin
game.start()
Expand All @@ -41,7 +49,7 @@ while (true) {

## Changing scenes

Let's add a new `Scene` and actions to go back and forth between the two.
Let's add a new `Scene`, and actions to change between them.

```kotlin

Expand All @@ -57,7 +65,7 @@ val game = Game(inOut, mainCharacter, scenes, "hello-keep")

## Adding items

To add items to the scene, just declare them using `items` and `item`.
To add items to the scene declare them using `items` and `item`.

```kotlin
val items = items(
Expand All @@ -66,7 +74,7 @@ val items = items(
)

val actions = actions(Take(), Leave())
val room = scene("big-room", "Big Room", "You are on a big room.", actions, items)
val room = scene("big-room", "Big Room", "You are in a big room.", actions, items)
```

## Adding NPCs
Expand All @@ -81,7 +89,7 @@ val actions = actions(Talk())
val characters = characters(
npc("bob", "Bob", "Bob, an NPC.")
onTalk {
io.paragraph("${target.name}: Hello ${game.mainCharacter.name}!.")
io.paragraph("${target.name}: Hello, ${game.mainCharacter.name}!.")
io.promptContinue()
}
,
Expand All @@ -99,4 +107,4 @@ val scene = scene("hello-keep", "Hello Keep", "Keep is a text game engine.",

## Where to go from here

**Keep** can do much more to help you design your game, check the [index](../README.md#index) for in depth documentation on items, characters, dialogue, actions, and events.
**Keep** can do much more to help you design your game, check the [index](../README.md#index) for in-depth documentation on items, characters, dialogue, actions, and events.
10 changes: 5 additions & 5 deletions doc/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Simple Items

The most simple items are declared using the `item` function with a `key` to identify it, a display `name`, and a `description`. Typically, a callback is registered using `onUse`, it will be called when the `Use` action is used on the item.
The simplest items are declared using the `item` function with a `key` to identify it, a display `name`, and a `description`. Typically, a callback is registered using `onUse`, which is called when the `Use` action is used on the item.

The following example shows a potion that can be used by the player.

Expand All @@ -20,9 +20,9 @@ val potion =

## Stateful Items

Items can hold state, allowing the world to react and be modified by the player's actions. Use an overload of the `item` function, and declare `key`, `initialState` and `states` parameters.
Items can hold a state, allowing the world to react and be modified by the player's actions. Use an overload of the `item` function, and declare `key`, `initialState`, and `states` parameters.

Each state has its own `key`, also the state has `name` and `description` properties that replace the item's ones. Each state can have its own subscriptions to `onUse` or any other actions, allowing the item to change its behavior.
Each state has its own `key`, the state also has `name` and `description` properties that replace the item's ones. Each state can have its own subscriptions to `onUse` or any other actions, allowing the item to specify its behavior.

The following example shows a switch that can be turned on or off by the player.

Expand All @@ -37,15 +37,15 @@ val switch =
"An example of an item with state in Keep. The switch is off."
) onUse {
target.change("on")
io.paragraph("Turn the switch on...")
io.paragraph("You turn the switch on...")
},
itemState(
"on",
"switch (on)",
"An example of an item with state in Keep. The switch is on."
) onUse {
target.change("off")
io.paragraph("Turn the switch off...")
io.paragraph("You turn the switch off...")
}
)
```
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ val alice =
characterState(
"regular",
"Alice",
"Alice, another NPC.",
"Alice, another NPC, she has already greeted you.",
) onTalk {
io.paragraph("${target.name}: Hello.")
io.promptContinue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fun main() {
val characters = characters(
npc("bob", "Bob", "Bob, an NPC.")
onTalk {
io.paragraph("${target.name}: Hello ${game.mainCharacter.name}!.")
io.paragraph("${target.name}: Hello, ${game.mainCharacter.name}!.")
io.promptContinue()
}
,
Expand Down

0 comments on commit 6c5cc7f

Please sign in to comment.