diff --git a/src/components/FinalPoem.js b/src/components/FinalPoem.js index d516184e..571b61e4 100644 --- a/src/components/FinalPoem.js +++ b/src/components/FinalPoem.js @@ -1,20 +1,40 @@ import React from 'react'; import './FinalPoem.css'; +import PropTypes from 'prop-types'; -const FinalPoem = (props) => { - +const FinalPoem = ({ finalPoemDisplayCallback, poem, poemComplete }) => { return (
{line}
; + }); +}; + +FinalPoem.propTypes = { + finalPoemDisplayCallback: PropTypes.func.isRequired, + poem: PropTypes.arrayOf(PropTypes.string).isRequired, + poemComplete: PropTypes.bool.isRequired, +}; export default FinalPoem; diff --git a/src/components/Game.js b/src/components/Game.js index e99f985a..54970ec2 100644 --- a/src/components/Game.js +++ b/src/components/Game.js @@ -5,46 +5,79 @@ import FinalPoem from './FinalPoem'; import RecentSubmission from './RecentSubmission'; class Game extends Component { - - constructor(props) { - super(props); + constructor() { + super(); + this.state = { + recentSubmission: null, + finalSubmission: { poemComplete: false, poem: [] }, + currentPlayer: 1, + }; } - render() { + onPoemSubmission = lastLine => { + let poem = this.state.finalSubmission.poem; + poem.push(lastLine); + this.setState({ + recentSubmission: lastLine, + finalSubmission: { poemComplete: false, poem: poem }, + currentPlayer: this.state.currentPlayer + 1, + }); + }; + + onFinalPoemDisplay = () => { + this.setState({ + finalSubmission: { ...this.state.finalSubmission, poemComplete: true }, + }); + }; - const exampleFormat = FIELDS.map((field) => { + render() { + const { recentSubmission, finalSubmission, currentPlayer } = this.state; + const exampleFormat = FIELDS.map(field => { if (field.key) { return field.placeholder; } else { return field; } - }).join(" "); - + }).join(' '); return (Each player should take turns filling out and submitting the form below. Each turn should be done individually and in secret! Take inspiration from the revealed recent submission. When all players are finished, click the final button on the bottom to reveal the entire poem.
- -Please follow the following format for your poetry submission:
- -- { exampleFormat } +
+ Each player should take turns filling out and submitting the form + below. Each turn should be done individually and in secret!{' '} + Take inspiration from the revealed recent submission. When all players + are finished, click the final button on the bottom to reveal the + entire poem.
-Please follow the following format for your poetry submission:
-{exampleFormat}
+ {!finalSubmission.poemComplete && + (recentSubmission && ( +