From e6e87457dabee4ffe000f326f9470b8147327d71 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Mon, 16 Nov 2015 00:52:29 -0500 Subject: [PATCH] Nearly done, jsut need to clean up the json file and add local storage support --- client/naturalCrit/encounter/encounter.jsx | 60 ++++++++++++++++--- client/naturalCrit/encounter/encounter.less | 30 +++++++++- .../monsterCard/attackSlot/attackSlot.jsx | 4 +- .../encounter/monsterCard/monsterCard.jsx | 8 +-- .../encounter/monsterCard/monsterCard.less | 35 ++++++++++- client/naturalCrit/naturalCrit.jsx | 16 +++-- client/naturalCrit/naturalCrit.less | 3 + client/naturalCrit/sidebar/sidebar.jsx | 16 +++-- client/naturalCrit/sidebar/sidebar.less | 45 ++++++++++---- .../jsonFileEditor/jsonFileEditor.jsx | 36 ++++++++++- .../jsonFileEditor/jsonFileEditor.less | 5 ++ 11 files changed, 214 insertions(+), 44 deletions(-) diff --git a/client/naturalCrit/encounter/encounter.jsx b/client/naturalCrit/encounter/encounter.jsx index 479bda8bd..cfee03b53 100644 --- a/client/naturalCrit/encounter/encounter.jsx +++ b/client/naturalCrit/encounter/encounter.jsx @@ -16,9 +16,9 @@ var Encounter = React.createClass({ desc : '', reward : '', enemies : [], + players : '', index : {}, - monsterManual : {} }; }, @@ -67,34 +67,60 @@ var Encounter = React.createClass({ }, + getPlayerObjects : function(){ + return _.map(this.props.players.split('\n'), function(line){ + var parts = line.split(' '); + if(parts.length != 2) return null; + return { + name : parts[0], + initiative : parts[1] * 1, + isPC : true + } + }) + }, + + renderEnemies : function(){ var self = this; - var sortedEnemies = _.sortBy(this.state.enemies, function(e){ - return -e.initiative; + var sortedEnemies = _.sortBy(_.union(_.values(this.state.enemies), this.getPlayerObjects()), function(e){ + if(e.initiative) return -e.initiative; + return 0; }); return _.map(sortedEnemies, function(enemy){ + if(enemy.isPC){ + return + } + return + remove={self.removeEnemy.bind(self, enemy.id)} + /> }) }, render : function(){ var self = this; + var reward; + if(this.props.reward){ + reward =
+ + {this.props.reward} +
+ } return( -
- +
- {this.props.name} +

{this.props.name}

+

{this.props.desc}

+ {reward}
-
{this.renderEnemies()}
@@ -104,3 +130,21 @@ var Encounter = React.createClass({ }); module.exports = Encounter; + + +var PlayerCard = React.createClass({ + + getDefaultProps: function() { + return { + name : '', + initiative : 0 + }; + }, + render : function(){ + return
+ {_.startCase(this.props.name)} + {this.props.initiative} +
+ }, + +}) \ No newline at end of file diff --git a/client/naturalCrit/encounter/encounter.less b/client/naturalCrit/encounter/encounter.less index 7cbd2ba32..74106895e 100644 --- a/client/naturalCrit/encounter/encounter.less +++ b/client/naturalCrit/encounter/encounter.less @@ -1,3 +1,31 @@ -.encounter{ + +.mainEncounter{ + box-sizing : border-box; + overflow : hidden; + width : auto; + + &>.info{ + + margin-left: 10px; + h1{ + font-size: 2em; + font-weight: 800; + margin-bottom: 5px; + } + p{ + font-size: 0.8em; + } + .reward{ + font-size: 0.8em; + font-weight: 800; + margin-top: 5px; + i{ + margin-right: 5px; + } + } + + } + + } \ No newline at end of file diff --git a/client/naturalCrit/encounter/monsterCard/attackSlot/attackSlot.jsx b/client/naturalCrit/encounter/monsterCard/attackSlot/attackSlot.jsx index c22d3e3a4..f2dcd9bde 100644 --- a/client/naturalCrit/encounter/monsterCard/attackSlot/attackSlot.jsx +++ b/client/naturalCrit/encounter/monsterCard/attackSlot/attackSlot.jsx @@ -83,11 +83,11 @@ var AttackSlot = React.createClass({ {self.props[type]} - {self.state.lastRoll[type] || ''} + {self.state.lastRoll[type]}
}) diff --git a/client/naturalCrit/encounter/monsterCard/monsterCard.jsx b/client/naturalCrit/encounter/monsterCard/monsterCard.jsx index 52e4bda16..47965800b 100644 --- a/client/naturalCrit/encounter/monsterCard/monsterCard.jsx +++ b/client/naturalCrit/encounter/monsterCard/monsterCard.jsx @@ -87,6 +87,7 @@ var MonsterCard = React.createClass({ renderHPBox : function(){ + var self = this; var tempHP if(this.state.tempHP){ @@ -98,17 +99,17 @@ var MonsterCard = React.createClass({
{tempHP} {this.props.currentHP}
-
{this.props.hp}
+ {self.renderStats()}
}, renderStats : function(){ var stats = { 'fa fa-shield' : this.props.ac, - 'fa fa-hourglass-2' : this.props.initiative, + //'fa fa-hourglass-2' : this.props.initiative, } return _.map(stats, function(val, icon){ - return {val} + return
{val}
}) }, @@ -164,7 +165,6 @@ var MonsterCard = React.createClass({ {this.renderHPBox()}
{this.props.name} - {this.renderStats()}
diff --git a/client/naturalCrit/encounter/monsterCard/monsterCard.less b/client/naturalCrit/encounter/monsterCard/monsterCard.less index 923174c0f..553edc465 100644 --- a/client/naturalCrit/encounter/monsterCard/monsterCard.less +++ b/client/naturalCrit/encounter/monsterCard/monsterCard.less @@ -7,13 +7,42 @@ -ms-user-select : none; user-select : none; } + +@marginSize : 10px; + +.playerCard{ + display : inline-block; + box-sizing : border-box; + margin : @marginSize; + padding : 10px; + background-color : white; + border : 1px solid #bbb; + + .name{ + margin-right: 20px; + } + .initiative{ + font-size: 0.8em; + i{ + font-size: 0.8em; + } + } + + &:nth-child(5n + 1){ background-color: fade(@blue, 25%); } + &:nth-child(5n + 2){ background-color: fade(@purple, 25%); } + &:nth-child(5n + 3){ background-color: fade(@steel, 25%); } + &:nth-child(5n + 4){ background-color: fade(@green, 25%); } + &:nth-child(5n + 5){ background-color: fade(@orange, 25%); } +} + + .monsterCard{ position : relative; display : inline-block; vertical-align : top; box-sizing : border-box; - width : 250px; - margin : 30px; + width : 220px; + margin : @marginSize; padding : 10px; background-color : white; border : 1px solid #bbb; @@ -81,7 +110,7 @@ line-height : 0.8em; } } - .maxHP{ + .stat{ font-size : 0.8em; } .hpText{ diff --git a/client/naturalCrit/naturalCrit.jsx b/client/naturalCrit/naturalCrit.jsx index 30fac0a13..8870ba66b 100644 --- a/client/naturalCrit/naturalCrit.jsx +++ b/client/naturalCrit/naturalCrit.jsx @@ -105,6 +105,8 @@ var NaturalCrit = React.createClass({ encounters : encounters, monsterManual : MonsterManual, + players : 'jasper 13' + }; }, @@ -142,19 +144,21 @@ var NaturalCrit = React.createClass({ handleJSONChange : function(encounterIndex, json){ - this.state.encounters[encounterIndex] = json; this.setState({ encounters : this.state.encounters }) - }, - handleEncounterChange : function(encounterIndex){ this.setState({ selectedEncounterIndex : encounterIndex }); }, + handlePlayerChange : function(e){ + this.setState({ + players : e.target.value + }); + }, renderSelectedEncounter : function(){ @@ -169,6 +173,7 @@ var NaturalCrit = React.createClass({ key={selectedEncounter.name} {...selectedEncounter} monsterManual={this.state.monsterManual} + players={this.state.players} /> } @@ -187,14 +192,15 @@ var NaturalCrit = React.createClass({ selectedEncounter={this.state.selectedEncounterIndex} encounters={this.state.encounters} monsterManual={this.state.monsterManual} + players={this.state.players} onSelectEncounter={this.handleEncounterChange} onJSONChange={this.handleJSONChange} + onPlayerChange={this.handlePlayerChange} /> -
+ {this.renderSelectedEncounter()} -
); diff --git a/client/naturalCrit/naturalCrit.less b/client/naturalCrit/naturalCrit.less index a2aa886d4..94ccc122f 100644 --- a/client/naturalCrit/naturalCrit.less +++ b/client/naturalCrit/naturalCrit.less @@ -3,6 +3,9 @@ @import 'naturalCrit/animations.less'; @import 'naturalCrit/colors.less'; + +@sidebarWidth : 250px; + body{ background-color : #eee; font-family : 'Open Sans', sans-serif; diff --git a/client/naturalCrit/sidebar/sidebar.jsx b/client/naturalCrit/sidebar/sidebar.jsx index 833fef9ba..894ef965a 100644 --- a/client/naturalCrit/sidebar/sidebar.jsx +++ b/client/naturalCrit/sidebar/sidebar.jsx @@ -14,8 +14,9 @@ var Sidebar = React.createClass({ encounters : [], onSelectEncounter : function(){}, - onJSONChange : function(encounterIndex, json){}, + + onPlayerChange : function(){}, }; }, @@ -48,7 +49,6 @@ var Sidebar = React.createClass({ var self = this; return _.map(this.props.encounters, function(encounter, index){ - console.log(self.props.selectedEncounter, index); var isSelected = self.props.selectedEncounter == index; return
@@ -85,13 +85,17 @@ var Sidebar = React.createClass({
-

encounters

+

Encounters

{this.renderEncounters()} -
-
+
+ +
-
+
+

Players

+ +