From f2059458a2c329a9fd8ce431acd6d73a22d85bde Mon Sep 17 00:00:00 2001 From: Bonnie Schulkin Date: Thu, 29 Mar 2018 16:15:42 -0700 Subject: [PATCH] Bonnie code review comments --- src/controllers/card_carousel.css | 19 --- src/controllers/card_carousel.js | 88 -------------- src/controllers/dragon_card.js | 57 --------- src/controllers/fightMode.css | 13 -- src/controllers/fightMode.js | 167 -------------------------- src/controllers/get_random_dragon.css | 3 - src/controllers/get_random_dragon.js | 69 ----------- src/controllers/human.js | 19 --- 8 files changed, 435 deletions(-) delete mode 100644 src/controllers/card_carousel.css delete mode 100644 src/controllers/card_carousel.js delete mode 100644 src/controllers/dragon_card.js delete mode 100644 src/controllers/fightMode.css delete mode 100644 src/controllers/fightMode.js delete mode 100644 src/controllers/get_random_dragon.css delete mode 100644 src/controllers/get_random_dragon.js delete mode 100644 src/controllers/human.js diff --git a/src/controllers/card_carousel.css b/src/controllers/card_carousel.css deleted file mode 100644 index 7b3849b..0000000 --- a/src/controllers/card_carousel.css +++ /dev/null @@ -1,19 +0,0 @@ -.carousel-container { - background-color: #000; - border-radius: 10px; - height: 470px; -} - -.carousel { - display: flex; - flex-direction: row; - justify-content: center; - margin-top: 20px; -} - -.carousel-item { - background-color: #000; - height: 450px; - margin-top: 0; - width: 300px; -} diff --git a/src/controllers/card_carousel.js b/src/controllers/card_carousel.js deleted file mode 100644 index 44f0e63..0000000 --- a/src/controllers/card_carousel.js +++ /dev/null @@ -1,88 +0,0 @@ -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import Carousel from 'react-bootstrap/lib/Carousel'; -import DragonCard from '../controllers/dragon_card.js'; -import { addToUserDragons } from '../actions/index'; -import './card_carousel.css'; - -class ControlledCarousel extends Component { - constructor(props, context) { - super(props, context); - - this.handleSelect = this.handleSelect.bind(this); - this.generateKey = this.generateKey.bind(this); - - this.state = { - index: 0, - direction: null, - }; - } - - handleSelect(selectedIndex, e) { - this.setState({ - index: selectedIndex, - direction: e.direction - }); - } - - generateKey() { - const randomNum = Math.floor(Math.random() * 10000); - return `${randomNum}_${new Date().getTime()}`; - } - - - render() { - const { index, direction } = this.state; - let dragonList = null; - - if (this.props.dragons.length > 0) { - dragonList = ( - - {this.props.dragons.map((dragon, index) => { - return ( - - - - - )})} - - ) - } else { - dragonList = ( -
-

No dragons here!

-
- ) - } - - return ( -
- {dragonList} -
- ); - } -} - -function mapStateToProps({ dragons }) { - return { dragons }; -}; - -export default connect(mapStateToProps, { addToUserDragons })(ControlledCarousel); diff --git a/src/controllers/dragon_card.js b/src/controllers/dragon_card.js deleted file mode 100644 index 92b0a80..0000000 --- a/src/controllers/dragon_card.js +++ /dev/null @@ -1,57 +0,0 @@ -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { enterFightMode } from '../actions/index'; - -class DragonCard extends Component { - constructor(props) { - super(props); - - this.state = {} - - this.createFightMode = this.createFightMode.bind(this); - } - - createFightMode() { - this.props.toggleFightMode() - this.props.enterFightMode(this.props.dragon) - } - - render() { - let card = null; - if (this.props.randomMode) { - card = ( -
- dragon -

{this.props.type}

-

Level: {this.props.level}

-

HP: {this.props.currenthp} / {this.props.maxhp}

-

Strength: {this.props.strength}

-

Defense: {this.props.defense}

-
- ) - } else { - card = ( -
- dragon -

{this.props.type}

-

Level: {this.props.level}

-

HP: {this.props.currenthp} / {this.props.maxhp}

-

Strength: {this.props.strength}

-

Defense: {this.props.defense}

- -
- ) - } - return ( -
- {card} -
- ); - } -} - -function mapStateToProps({ fightMode }) { - return { fightMode }; -} - -export default connect(mapStateToProps, { enterFightMode })(DragonCard); diff --git a/src/controllers/fightMode.css b/src/controllers/fightMode.css deleted file mode 100644 index a454934..0000000 --- a/src/controllers/fightMode.css +++ /dev/null @@ -1,13 +0,0 @@ -.fight-intro-text { - margin: 20px; -} - -.fight-container { - display: flex; - flex-direction: row; - justify-content: center; -} - -.fight-card { - margin: 10px; -} diff --git a/src/controllers/fightMode.js b/src/controllers/fightMode.js deleted file mode 100644 index fb3d42c..0000000 --- a/src/controllers/fightMode.js +++ /dev/null @@ -1,167 +0,0 @@ -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import DragonCard from './dragon_card'; -import Human from '../Components/human_card'; -import { callHuman, saveHuman } from '../actions' -import './fightMode.css'; - -class Fight extends Component { - constructor(props) { - super(props); - - this.state = { - dragonHP: this.props.fightingDragon.currenthp, - humanHP: this.props.human.currenthp, - winner: null, - borderClass: 'black', - } - - this.enterBattle = this.enterBattle.bind(this); - this.changeActiveCardBorder = this.changeActiveCardBorder.bind(this); - this.levelUpHuman = this.levelUpHuman.bind(this); - } - - componentDidMount() { - if (!this.props.human.type) { - this.props.callHuman(1); - } - } - - levelUpHuman() { - const newHuman = { - type: this.props.human.type, - level: this.props.human.level + 1, - currenthp: Math.round(this.props.human.currenthp + (this.props.human.currenthp * .10)), - maxhp: Math.round(this.props.human.maxhp + (this.props.human.maxhp * .10)), - strength: Math.round(this.props.human.strength + (this.props.human.strength * .15)), - defense: Math.round(this.props.human.defense + (this.props.human.strength * .15)), - imageurl: this.props.human.imageurl, - } - return newHuman; - } - - enterBattle() { - console.log('enterBattle function is being called'); - const dragonStrength = this.props.fightingDragon.strength; - const humanStrength = this.props.human.strength; - const dragonDefense = this.props.fightingDragon.defense; - const humanDefense = this.props.human.defense; - let dragonHP = this.props.fightingDragon.currenthp; - let humanHP = this.props.human.currenthp; - let damageToHuman = dragonStrength - humanDefense; - let damageToDragon = humanStrength - dragonDefense; - - const humanTurn = (hp, damage) => { - this.changeActiveCardBorder(); - if (damage > 0) { - let turnDamage = dragonHP - damageToDragon; - dragonHP = dragonHP - turnDamage; - this.setState({ - dragonHP: dragonHP, - }) - } - - if (dragonHP > 0) { - setTimeout(() => { - dragonTurn() - this.changeActiveCardBorder(); - }, 2000); - } else { - const leveledUpHuman = this.levelUpHuman(this.props.human) - this.props.saveHuman(leveledUpHuman); - this.setState({ - winner: 'Human wins!' - }) - setTimeout(() => { - const leveledUpHuman = this.levelUpHuman(this.props.human) - this.props.saveHuman(leveledUpHuman); - this.props.toggleFightMode(); - }, 3000); - } - } - - // give the dragon a turn. - const dragonTurn = () => { - this.changeActiveCardBorder(); - // the damage is the current hp of the human minus the calculated damaged. - if (damageToHuman > 0) { - humanHP = humanHP - damageToHuman; - this.setState({ - humanHP: humanHP, - }) - } - // if the human hp minus the turn damage is greater than 0, call humanTurn. - if (humanHP > 0) { - setTimeout(() => { - humanTurn(); - this.changeActiveCardBorder(); - }, 2000) - - } else { - this.setState({ - winner: 'Dragon wins!' - }) - setTimeout(() => { - const leveledUpHuman = this.levelUpHuman(this.props.human) - this.props.saveHuman(leveledUpHuman); - this.props.toggleFightMode(); - }, 3000); - } - } - humanTurn(); - } - - changeActiveCardBorder() { - if (this.state.class === 'black') { - this.setState({ - class: 'green' - }) - } else { - this.setState({ - class: 'black', - }) - } - } - - render() { - return ( -
-

Battle Screen

-

This human is trying to get glory. If you win, you level up and you get to enjoy your picnic. If you lose, say goodbye to your HP and your peaceful afternoon.

-
-
- -
-
- -
-
- -

{this.state.winner}

-
- ) - } -} - -function mapStateToProps({ fightingDragon, human}) { - return { fightingDragon, human }; -} - -export default connect(mapStateToProps, { callHuman, saveHuman })(Fight); diff --git a/src/controllers/get_random_dragon.css b/src/controllers/get_random_dragon.css deleted file mode 100644 index a0f8667..0000000 --- a/src/controllers/get_random_dragon.css +++ /dev/null @@ -1,3 +0,0 @@ -.random-dragon-choices .btn { - margin: 0 4px; -} diff --git a/src/controllers/get_random_dragon.js b/src/controllers/get_random_dragon.js deleted file mode 100644 index 48455c2..0000000 --- a/src/controllers/get_random_dragon.js +++ /dev/null @@ -1,69 +0,0 @@ -import React, { Component} from 'react'; -import { connect } from 'react-redux'; -import DragonCard from '../controllers/dragon_card.js'; -import { getRandomDragon } from '../actions'; -import { addToUserDragons } from '../actions'; -import './get_random_dragon.css'; - -class GetRandomDragon extends Component { - constructor(props) { - super(props); - - this.state = { - randomMode: true, - } - - this.getNewDragon = this.getNewDragon.bind(this); - this.addDragonToCollection = this.addDragonToCollection.bind(this); - this.generateDragonId = this.generateDragonId.bind(this); - } - - componentDidMount() { - this.props.getRandomDragon(1); - } - - getNewDragon() { - this.props.getRandomDragon(1); - } - - generateDragonId() { - const randomNum = Math.floor(Math.random() * 1000); - return `${randomNum}_${new Date().getTime()}` - } - - addDragonToCollection() { - this.props.randomDragon.dragonId = this.generateDragonId(); - this.props.addToUserDragons(this.props.randomDragon) - this.props.acceptDragon(); - } - - - render() { - return ( -
- -
- - -
-
- ); - } -} - - -function mapStateToProps({ dragons, randomDragon }) { - return { dragons, randomDragon }; -}; - -export default connect(mapStateToProps, { getRandomDragon, addToUserDragons })(GetRandomDragon); diff --git a/src/controllers/human.js b/src/controllers/human.js deleted file mode 100644 index 05a448d..0000000 --- a/src/controllers/human.js +++ /dev/null @@ -1,19 +0,0 @@ -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import HumanCard from './Components/human_card'; - -function Human () { - - return ( -
- -
- ) -}