Skip to content

Commit

Permalink
Merge pull request #1414 from playmint/advanced-tut-rs
Browse files Browse the repository at this point in the history
Adapting the tutorial island guide to focus on Redstone
  • Loading branch information
ldunnplaymint authored Jul 29, 2024
2 parents ca87432 + d4568dc commit 661169f
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 197 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Follow the guide to [start building on mainnet](./tutorial/README.md).

------------------------------------

# References
## References
__[For more information, check the reference page](/tutorial/REFERENCE.md)__

------------------------------------

# Contributors
## Contributors

For people looking to contribute to the repository, please __[click here](./CONTRIBUTORS.md)__
104 changes: 22 additions & 82 deletions contracts/src/maps/tutorial-room-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,16 @@ Once complete, you will have used the core Downstream tools to create a map that

<a href="https://drive.google.com/file/d/1C6Zou1v_ad8OlvZjKmixuvBBLpVJvkRZ/view?usp=drive_link"><img src="./readme-images/screenshot.png" width=300></a>

[Watch a video run through of this tutorial.](https://drive.google.com/file/d/1C6Zou1v_ad8OlvZjKmixuvBBLpVJvkRZ/view?usp=drive_link)


## Prerequisites
- This repository cloned to your desktop. (Instructions in the top [readme](../../../../README.md).)
- [Docker Desktop](https://docs.docker.com/get-docker/)
- [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) or [npm Windows](https://nodejs.org/en/download/)

## 1. Deploy the game

First, deploy an instance of Downstream locally using Docker.

From a terminal in the repository root run:

```bash
docker compose up --pull=always
```

After some time (this could take up to 5 minutes), you should see "ready" in the terminal output:

contracts-1 | +-------+
contracts-1 | | ready |
contracts-1 | +-------+

You can now open a web browser and navigate to [http://localhost:3000] to load the front page.

From here you can select a zone, select Zone 1 as it will be owned by the deployer.

You should see a blue world, with a single hex tile in the center and the **Welcome to Zone 1** dialogue box:

<img src="./readme-images/step1.png" width=200>

## 2. Enter the Zone and Spawn a Unit

First click the **Connect Wallet** button.
Then, select **LocalDevAccount**.
Then visit Zone 1 (Zone 1 will be owned by the LocalDevAccount)
- Have set up Metamask
- Have claimed a Downstream Redstone Zone
Follow the [Redstone Guide](../../../../tutorial/REDSTONEGUIDE.md) for more information

<img src="./readme-images/step2a.png" width=200>

You can now click "Spawn Unit" and you should see your Unit on the center tile:


<img src="./readme-images/step2b.png" width=200>


## 3. Create a map
## 1. Create a map

There is no where for the Unit to go so we will now expand the world by creating some tiles.

First, open the the **tile-fabricator**, by opening a web browser and navigating to [http://localhost:3000/tile-fabricator].
First, open the the **tile-fabricator**, by opening a web browser and navigating to [tile-fabricator](http://redstone.downstream.game/tile-fabricator).

Now, draw a map design:
- Left click each tile that you want on your map.
Expand All @@ -77,7 +36,7 @@ Finally, create a new folder in your desktop. This folder is your 'map' and will
- Copy the exported tiles manifest into the folder.
- Rename it to 'Locations.yaml'.

## 4. Deploy the new tiles
## 2. Deploy the new tiles

We will use the Downstream CLI to deploy our newly created tiles to our local Downstream instance.

Expand All @@ -90,43 +49,30 @@ Check it is installed from any terminal folder by running:
ds help
```

Now copy your Burner private key from Downstream:
- Browse to [localhost:3000]([http://localhost:3000]).
- Click the player icon at the top left.

<img src="./readme-images/step4a.png" width=200>

- Click **show**

<img src="./readme-images/step4b.png" width=200>

- Highlight and copy the key.

Finally, run the command to deploy your map:
In a terminal at your new folder run the following, where `<private-key>` can be pasted from the one you just copied:
In a terminal at your new folder run the following, where `<zone-number>` is your Zone number:
```bash
ds apply -n local -z 1 -k <private-key> -f Locations.yaml
ds apply -n redstone -z <zone-number> -f Locations.yaml
```

We are using Zone 1 (`-z 1`) as the LocalDevAccount already owns Zone 1 and it saves up some time!

Note: If using Windows you get the error "running scripts is disabled on this system", open Powershell as an Administrator and run `Set-ExecutionPolicy RemoteSigned`

You should see the terminal output display a series of ✅s for each tile that is deployed.
Running the command will open your default broswer and ask you to sign a transaction in Metamask. This will confirm your identity and verify ownership of your zone.

Once you have accepted the Metamask prompts, return to your terminal and the output should display a series of ✅s for each tile that is deployed.

<img src="./readme-images/step4c.png" width=200>

Browse to [localhost:3000/zones/1](http://localhost:3000/zones/1) and you should see your newly created map and be able to move your Unit around it!
Browse to your Zone on [redstone.downstream.game](redstone.downstream.game) and you should see your newly created map and be able to move your Unit around it!

<img src="./readme-images/step4d.png" width=200>



## 5. Create a new type of building
## 3. Create a new type of building

The map is currently empty and there are no buildings to build. So we are going to create a new kind of 'Factory' building that crafts a new kind of item.

First, open the the **building-fabricator**, by opening a web browser and navigating to [http://localhost:3000/building-fabricator].
First, open the the **building-fabricator**, by opening a web browser and navigating to the [building-fabricator](http://redstone.downstream.game/building-fabricator).

You should see a page like this:

Expand All @@ -151,22 +97,20 @@ You should now have a folder that looks this:

<img src="./readme-images/step5c.png" width=200>

## 6. Deploy the new type of building
## 4. Deploy the new type of building

We will use the Downstream CLI to deploy our newly created building to our local Downstream instance.

Deploying the building is the same as the tiles manifest but passing BasicFactory.yaml instead of Locations.yaml:
- In a terminal in the folder with your exported building source.
- (using the same `<private-key>` as above)
- Still using Zone 1 (`-z 1`)
- `ds apply -n local -z 1 -k <private-key> -f BasicFactory.yaml`
- `ds apply -n redstone -z <zone-number> -f BasicFactory.yaml`

You should see the terminal output display for the building kind and item kind defined by your new factory:
Again, metamask will ask you to sign a transaction and then you should see the terminal output display for the building kind and item kind defined by your new factory:

<img src="./readme-images/step6a.png" width=200>

This type of building now exists in our local instance of Downstream, which means it is available for Units to build on the map:
- Browse to [http://localhost:3000/zones/1].
- Browse to your zone on [https://redstone.downstream.game](redstone.downstream.game).
- Select the build action.
- Choose your new building type from the drop down list.
- Confirm.
Expand All @@ -176,15 +120,15 @@ You should now have an instance of your building deployed to the map!
<img src="./readme-images/step6b.png" width=200>


## 7. Add some decorations
## 5. Add some decorations

There are plenty for examples of pre-made building kinds in the ds repository that can be copy and pasted into your map folder.

We will add some decorative blocking buildings to your map and see how everything in the map folder can be deployed at once.

First copy the [blockers.yaml](./blockers.yaml) to your map folder.

Now, use the [tile-fabricator](http://localhost:3000/tile-fabricator) to add some blockers to your map:
Now, use the [tile-fabricator](http://redstone.downstream.game/tile-fabricator) to add some blockers to your map:
- Press the **import** button, navigate to your map folder, and select blockers.yaml.
- New building types will now be available in the **Brush** drop done.

Expand All @@ -197,17 +141,13 @@ Now, use the [tile-fabricator](http://localhost:3000/tile-fabricator) to add som
- When you're happy, press the **export** button.
- Replace your old Locations.yaml with the new downloaded manifest.

## 8. Deploy the whole map folder
## 6. Deploy the whole map folder

To complete the tutorial, we're going to deploy your whole map folder together.

First, stop the Downstream instance running in Docker with **ctrl-c**, and restart it by running `docker compose up`.

Once you see "ready", browse to the game and check you have a single tile world.

Now you can `ds apply` the whole map folder by passing the `-R` flag and the folder path. At a terminal In your map folder run:
```bash
ds apply -n local -z 1 -k <private-key> -R -f .
ds apply -n redstone -z <zone-number> -k <private-key> -R -f .
```

Browsing back to the game, you should now see your new map.
Expand Down
19 changes: 6 additions & 13 deletions contracts/src/maps/tutorial-room-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,14 @@ Once complete, your map should something look like this:


# 1. Setup
Follow steps 1 through 4 of `tutorial-room-1` to get started. This will walk you through:
- Deploying the game
- Spawning a unit
- Creating a map
- Deploying new tiles

[tutorial-room-1/README.md](../tutorial-room-1/README.md)

The only change we want to make to these steps is in _Creating a map_. As this is the next room in the tutorial series, we will be creating our map at a different angle so it doesn't overlap with tutorial-room-1.
As this is the next room in the tutorial series, we will be creating our map at a different angle so it doesn't overlap with tutorial-room-1. One important feature of this map is a choke point to block off using a door.

<img src="./readme-images/step1.png" width=600>

We're using this particular shape to demonstrate the functionality of the gate. We will use the bottleneck to ensure there is no way around the gate.

Run the game and use the [tile-fabricator](http://localhost:3000/tile-fabricator) to create tiles following the shape shown in the example above.
Run the game and use the [tile-fabricator](http://redstone.downstream.game/tile-fabricator) to create tiles following the shape shown in the example above.

Once you've painted the tiles, click export, and save the output file as `Locations.yaml` in a new project folder on your computer.

Expand Down Expand Up @@ -57,7 +50,7 @@ spec:
**Note:** later, we'll be using the item ID to verify the unit has the key in their inventory. If you're following along and want to use the same ID as we do, you should use the same name. Otherwise, you can run the command `ds get items -n local` while running the game to get a list of all the items in your world with their IDs.

One thing here that isn't clear is the icon. The best way to pick an icon is to open the [building-fabricator](http://localhost:3000/building-fabricator) where you can easily flick through the item icons available.
One thing here that isn't clear is the icon. The best way to pick an icon is to open the [building-fabricator](http://redstone.downstream.game/building-fabricator) where you can easily flick through the item icons available.

You can change how much goo it costs the unit to craft this item.

Expand Down Expand Up @@ -154,7 +147,7 @@ spec:
facingDirection: LEFT
```

Before continuing, you may want to use `ds apply` ([see tutorial-room-1](https://github.com/playmint/ds/blob/main/contracts/src/maps/tutorial-room-1/README.md#8-deploy-the-whole-map-folder)) to check your progress!
Before continuing, you may want to use `ds apply` ([see tutorial-room-1](https://github.com/playmint/ds/blob/main/contracts/src/maps/tutorial-room-1/README.md#6-deploy-the-whole-map-folder)) to check your progress!


# 5. Gate
Expand Down Expand Up @@ -386,11 +379,11 @@ spec:
location: [8, -1, -7]
facingDirection: RIGHT
```
2. Run `ds apply` ([see tutorial-room-1](https://github.com/playmint/ds/blob/main/contracts/src/maps/tutorial-room-1/README.md#8-deploy-the-whole-map-folder)) and refresh!
2. Run `ds apply` ([see tutorial-room-1](https://github.com/playmint/ds/blob/main/contracts/src/maps/tutorial-room-1/README.md#6-deploy-the-whole-map-folder)) and refresh!
# You did it, good job! 🥳
At this point, everything should be working! Feel free to refer to the example files to learn more about the implementation.
<img src="./readme-images/step6.png" width=600>
<img src="./readme-images/step6.png" width=600>
4 changes: 2 additions & 2 deletions contracts/src/maps/tutorial-room-3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
We will follow the steps below to create a series of quests which you will use to guide the player to complete various tasks.

## 1. Preparation
- Before starting, ensure that you have deployed an instance of Downstream locally using Docker. You can find instructions on how to do that in [Tutorial 1 here](../tutorial-room-1/README.md).
- Make sure you have followed [Tutorial 1](../tutorial-room-1/README.md) & [Tutorial 2](../tutorial-room-2/README.md).
- You should also copy the CastleOfTreasure .yaml, .sol and .js files out of the tutorial room 3 folder and paste them into your working folder. To save you some time drawing a map, you can also copy the Tile.yaml.


Expand Down Expand Up @@ -119,7 +119,7 @@ We will use the Downstream CLI to deploy our newly created building to our local
Run the following in a terminal in the folder with your exported building source (refer to tutorial 1 for more information).

```
ds apply -n local -z 1 -k <private-key> -R -f ./
ds apply -n redstone -z <zone-number> -R -f ./
```
You should see an output like this:
Expand Down
22 changes: 15 additions & 7 deletions contracts/src/maps/tutorial-room-4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ Once complete, your map should something look like this:

## 1. Setup

Follow steps 1 through 4 of `tutorial-room-1` to get started. This will walk you through:
- Deploying the game
- Spawning a unit
- Creating a map
- Deploying new tiles
Please ensure you have completed Tutorials 1-3.

Let's create the disco room!

https://github.com/playmint/ds/blob/main/contracts/src/maps/tutorial-room-1/README.md

Expand Down Expand Up @@ -190,7 +188,7 @@ function themedRandomColour(){
if `disco` is false, it makes each tile (except for the one the unit is standing on) blue.
And for colouring the tiles, that's it! Once you've passed in the `map` array we pushed to, to the `map`, feel free to [give it a test run](https://github.com/playmint/ds/blob/main/contracts/src/maps/tutorial-room-1/README.md#8-deploy-the-whole-map-folder)!
And for colouring the tiles, that's it! Once you've passed in the `map` array we pushed to, to the `map`, feel free to [give it a test run](https://github.com/playmint/ds/blob/main/contracts/src/maps/tutorial-room-1/README.md#6-deploy-the-whole-map-folder)!
```js
return {
Expand Down Expand Up @@ -413,8 +411,18 @@ return {

<img src="./readme-images/step5.png" width=600>

## 6. Deploy your files

We will use the Downstream CLI to deploy our newly created building to our local Downstream instance.

Run the following in a terminal in the folder with your exported building source (refer to tutorial 1 for more information).

```
ds apply -n redstone -z <zone-number> -R -f ./
```

## You did it, good job! 🥳

At this point, everything should be working! Feel free to refer to the example files to learn more about the implementation.

<img src="./readme-images/step6.png" width=600>
<img src="./readme-images/step6.png" width=600>
Loading

0 comments on commit 661169f

Please sign in to comment.