-
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.
Five Torches Deep Random Map Generation (#64)
* add new generator * add divider
- Loading branch information
Showing
7 changed files
with
152 additions
and
0 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
21 changes: 21 additions & 0 deletions
21
client/src/components/FiveTorchesDeep/RandomMapGenerator/Box/Box.tsx
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,21 @@ | ||
import React, { useState } from 'react' | ||
import Roll from "roll" | ||
|
||
import maps from '../../data/maps' | ||
|
||
const Box = ({ name }: {name: string }) => { | ||
const [ number, setNumber ] = useState(new Roll().roll(`1d6`).result) | ||
const { color, description } = maps.find((element) => element.number === number) || maps[0] | ||
const styles = `Map-box Map-box-color-${color}` | ||
|
||
const handleClick = () => setNumber(new Roll().roll(`1d6`).result) | ||
|
||
return ( | ||
<div className={styles} onClick={handleClick}> | ||
<label>{name}</label> | ||
<p>{description}</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default Box |
54 changes: 54 additions & 0 deletions
54
client/src/components/FiveTorchesDeep/RandomMapGenerator/RandomMapGenerator.scss
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,54 @@ | ||
.RandomMapGeneator { | ||
.Map { | ||
display: grid; | ||
justify-content: center; | ||
grid-template-rows: repeat(3, 200px); | ||
grid-template-columns: repeat(3, 200px); | ||
|
||
&-box { | ||
align-content: center; | ||
background-color: white; | ||
border: 3px solid black; | ||
display: grid; | ||
padding: 3px 5px; | ||
|
||
&:hover, | ||
&:focus { | ||
cursor: pointer; | ||
transform: translate(-2px, -2px); | ||
} | ||
|
||
&:active { | ||
transform: translate(2px, 2px); | ||
} | ||
|
||
label { | ||
font-weight: bold; | ||
} | ||
|
||
&-color-white { | ||
background-color: var(--white); | ||
} | ||
|
||
&-color-blue { | ||
background-color: var(--blue); | ||
} | ||
|
||
&-color-green { | ||
background-color: var(--green); | ||
} | ||
|
||
&-color-yellow { | ||
background-color: var(--yellow); | ||
} | ||
|
||
&-color-orange { | ||
background-color: var(--orange); | ||
} | ||
|
||
&-color-red { | ||
background-color: var(--red); | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
client/src/components/FiveTorchesDeep/RandomMapGenerator/RandomMapGenerator.tsx
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,35 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import { Button } from "react-bootstrap" | ||
|
||
import Box from "./Box/Box" | ||
|
||
import './RandomMapGenerator.scss' | ||
|
||
const RandomMapGenerator = () => { | ||
const [ refresh, setRefresh ] = useState(false) | ||
|
||
const handleClick = () => setRefresh(!refresh) | ||
|
||
return ( | ||
<div className='RandomMapGeneator'> | ||
<div key={`map-${refresh}`} className='Map'> | ||
<Box name='Northwest' /> | ||
<Box name='North' /> | ||
<Box name='Northeast' /> | ||
|
||
<Box name='West' /> | ||
<Box name='Center' /> | ||
<Box name='East' /> | ||
|
||
<Box name='Southwest' /> | ||
<Box name='South' /> | ||
<Box name='Southeast' /> | ||
</div> | ||
<div className='mt-3'> | ||
<Button onClick={handleClick}>Generator New Map</Button> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default RandomMapGenerator |
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 @@ | ||
export default [ | ||
{ | ||
number: 1, | ||
color: "white", | ||
description: "open path, entrance, or clearing" | ||
}, | ||
{ | ||
number: 2, | ||
color: "blue", | ||
description: "alternative path (water, ascent)" | ||
}, | ||
{ | ||
number: 3, | ||
color: "green", | ||
description: "a key destination (treasure)" | ||
}, | ||
{ | ||
number: 4, | ||
color: "yellow", | ||
description: "passive threat, hazards, terrain" | ||
}, | ||
{ | ||
number: 5, | ||
color: "orange", | ||
description: "danger, enemy convergences" | ||
}, | ||
{ | ||
number: 6, | ||
color: "red", | ||
description: "blocked or locked, can't travel by any normal means (dorr, wall, etc)" | ||
} | ||
] |
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