Updated babel, fixing data flow in ListStore

Transferring all Actions to ListStore to regain unidirectional data flow for all stores. Other Stores only will store section-specific data e.g. filters.
This commit is contained in:
Lukas Obermann
2016-11-02 02:23:02 +01:00
parent 9a6566c3ca
commit 7c229853e7
1280 changed files with 3336 additions and 10126 deletions
+2434 -2606
View File
File diff suppressed because it is too large Load Diff
-37
View File
@@ -1,37 +0,0 @@
var AppDispatcher = require('../dispatcher/AppDispatcher');
var EventEmitter = require('events').EventEmitter;
var ActionTypes = require('../constants/ActionTypes');
var DisAdvStore = Object.assign({}, EventEmitter.prototype, {
emitChange: function() {
this.emit('change');
},
addChangeListener: function(callback) {
this.on('change', callback);
},
removeChangeListener: function(callback) {
this.removeListener('change', callback);
}
});
DisAdvStore.dispatchToken = AppDispatcher.register( function( payload ) {
switch( payload.actionType ) {
case 'TEST':
break;
default:
return true;
}
DisAdvStore.emitChange();
return true;
});
module.exports = DisAdvStore;
-6
View File
@@ -1,6 +0,0 @@
import AppDispatcher from '../dispatcher/AppDispatcher';
import ActionTypes from '../constants/ActionTypes';
var HelpActions = {};
export default HelpActions;
-37
View File
@@ -1,37 +0,0 @@
var AppDispatcher = require('../dispatcher/AppDispatcher');
var EventEmitter = require('events').EventEmitter;
var ActionTypes = require('../constants/ActionTypes');
var HelpStore = Object.assign({}, EventEmitter.prototype, {
emitChange: function() {
this.emit('change');
},
addChangeListener: function(callback) {
this.on('change', callback);
},
removeChangeListener: function(callback) {
this.removeListener('change', callback);
}
});
HelpStore.dispatchToken = AppDispatcher.register( function( payload ) {
switch( payload.actionType ) {
case 'TEST':
break;
default:
return true;
}
HelpStore.emitChange();
return true;
});
module.exports = HelpStore;
-42
View File
@@ -1,42 +0,0 @@
var HeaderDropdown = require('../HeaderDropdown');
var HeroActions = require('../../../actions/HeroActions');
var React = require('react');
var TextField = require('../../layout/TextField');
class HeroesCreate extends React.Component {
static propTypes = {
isOpen: React.PropTypes.bool
};
state = {
name: ''
};
constructor(props) {
super(props);
}
_changeName = event => this.setState({ name: event.target.value });
_createNewHero = event => {
if (event.charCode === 13 && this.state.name != '') {
HeroActions.create(this.state.heroname);
}
};
render() {
return (
<HeaderDropdown isOpen={this.props.isOpen}>
<TextField
hint="Name des Helden"
value={this.state.name}
onChange={this._changeName}
onKeyPress={this._createNewHero}
/>
</HeaderDropdown>
);
}
}
module.exports = HeroesCreate;
-23
View File
@@ -1,23 +0,0 @@
import AppDispatcher from '../dispatcher/AppDispatcher';
import ActionTypes from '../constants/ActionTypes';
var PaneActions = {
showHeroList: function() {
AppDispatcher.dispatch({
actionType: ActionTypes.HEROES_SHOW
});
},
hideHeroList: function() {
AppDispatcher.dispatch({
actionType: ActionTypes.HEROES_HIDE
});
},
handleCollapse: function(id) {
AppDispatcher.dispatch({
actionType: ActionTypes.COLLAPSE_HEROES,
id
});
}
};
export default PaneActions;
-80
View File
@@ -1,80 +0,0 @@
var React = require('react');
var PaneActions = require('../../../actions/PaneActions');
var Collapse = require('../../layout/Collapse');
var PaneHeroesItem = require('./PaneHeroesItem');
var PaneTabsItem = require('../tabs/PaneTabsItem');
class PaneHeroesContent extends React.Component {
static propTypes = {
tab: React.PropTypes.string.isRequired,
own: React.PropTypes.array.isRequired,
mastered: React.PropTypes.array.isRequired,
other: React.PropTypes.array.isRequired,
collapse: React.PropTypes.array.isRequired,
heroid: React.PropTypes.any.isRequired
};
constructor(props) {
super(props);
}
handleCollapse = (id) => PaneActions.handleCollapse(id);
render() {
const heroListItems = this.props.own.length > 0 ? this.props.own.map( (hero) => {
return <PaneHeroesItem key={hero.id} id={hero.id} name={hero.name} prof={hero.prof} ap={hero.ap} active={this.props.heroid} img="" />;
}) : (
<div className="no-heroes">Keine Helden verfügbar.</div>
);
const ownHeroes = this.props.own.length > 0 ? this.props.own.map( (hero) => {
return <PaneHeroesItem key={hero.id} id={hero.id} name={hero.name} prof={hero.prof} ap={hero.ap} active={this.props.heroid} img="" />;
}) : (
<div className="no-heroes">Keine Helden in dieser Kategorie.</div>
);
return (
<div className="pane-bottomcontent">
<Collapse title="Eigene"
switch={this.handleCollapse.bind(null, 0)}
expanded={this.props.collapse[0]}
height={this.props.own.length > 0 ? this.props.own.length * 48 + 44 : 80}
>{ownHeroes}</Collapse>
<Collapse title="Gemeisterte"
switch={this.handleCollapse.bind(null, 1)}
expanded={this.props.collapse[1]}
height={this.props.mastered.length > 0 ? this.props.mastered.length * 48 + 116 : 162}
>
<PaneTabsItem isOpen={this.props.tab} tag="groups" label="Gruppen" />
<PaneTabsItem isOpen={this.props.tab} tag="ingame" label="InGame-Verwaltung" />
{
this.props.mastered.length > 0 ? this.props.mastered.map( (hero) => {
return <PaneHeroesItem key={hero.id} id={hero.id} name={hero.name} player={hero.player} prof={hero.prof} ap={hero.ap} active={this.props.heroid} img="" />;
}) : (
<div className="no-heroes">Keine Helden in dieser Kategorie.</div>
)
}
</Collapse>
<Collapse title="Andere"
id="other"
switch={this.handleCollapse.bind(null, 2)}
expanded={this.props.collapse[2]}
height={this.props.other.length > 0 ? this.props.other.length * 48 + 44 : 80}
>
{
this.props.other.length > 0 ? this.props.other.map( (hero) => {
return <PaneHeroesItem key={hero.id} id={hero.id} name={hero.name} player={hero.player} prof={hero.prof} ap={hero.ap} active={this.props.heroid} img="" />;
}) : (
<div className="no-heroes">Keine Helden in dieser Kategorie.</div>
)
}
</Collapse>
</div>
);
}
}
module.exports = PaneHeroesContent;
-47
View File
@@ -1,47 +0,0 @@
var HeroActions = require('../../../actions/HeroActions');
var React = require('react');
var classNames = require('classnames');
class PaneHeroesItem extends React.Component {
static propTypes = {
id: React.PropTypes.any.isRequired,
name: React.PropTypes.string.isRequired,
player: React.PropTypes.string,
prof: React.PropTypes.string,
ap: React.PropTypes.any,
img: React.PropTypes.string
};
constructor(props) {
super(props);
}
handleClick = () => HeroActions.load(this.props.id);
render() {
const className = classNames( 'pane-heroes-item', this.props.id === this.props.active && 'active' );
return (
<div className={className} onClick={this.handleClick}>
<div className="avatar">
<div className="avatar-inner">
<img src={this.props.img} alt="" />
</div>
</div>
<div className="main">
<span className="name">{this.props.name}{this.props.player ? ' [' + this.props.player + ']' : null}</span>
<div className="add">
<span className="prof">Testprofession</span>
<span className="ap">1234 AP</span>
</div>
</div>
</div>
);
// <span className="prof">{this.props.prof}</span>
// <span className="ap">{this.props.ap}</span>
}
}
module.exports = PaneHeroesItem;
-45
View File
@@ -1,45 +0,0 @@
var classNames = require('classnames');
var React = require('react');
class PaneHint extends React.Component {
constructor(props) {
super(props);
}
render() {
const className = classNames('pane-hint', this.props.className);
const TextElement = this.props.subLabel ? (
<div className="pane-hint-name pane-hint-name-ext" onClick={this.props.onClickText}>
<span className="pane-hint-name-main">{this.props.label}</span>
<span className="pane-hint-name-sub">{this.props.subLabel}</span>
</div>
) : (
<div className="pane-hint-name" onClick={this.props.onClickText}>
{this.props.label}
</div>
);
const IconElement = this.props.subLabel ? (
<div className="pane-hint-icon" onClick={this.props.onClickIcon}>{this.props.icon}</div>
) : null;
return (
<div className={className} onClick={this.props.onClick}>
{TextElement}
{IconElement}
</div>
);
}
}
PaneHint.propTypes = {
label: React.PropTypes.string.isRequired,
subLabel: React.PropTypes.string.isRequired,
icon: React.PropTypes.string.isRequired,
onClick: React.PropTypes.func,
onClickText: React.PropTypes.func,
onClickIcon: React.PropTypes.func
};
-52
View File
@@ -1,52 +0,0 @@
var React = require('react');
var PaneActions = require('../../../actions/PaneActions');
var PaneTabsItem = require('./PaneTabsItem');
class PaneTabsContent extends React.Component {
static propTypes = {
tab: React.PropTypes.string.isRequired,
phase: React.PropTypes.number.isRequired
};
constructor(props) {
super(props);
}
shouldComponentUpdate(nextProps) {
return nextProps.tab !== this.props.tab || nextProps.phase !== this.props.phase;
}
render() {
const TABS = ['Basis', 'Rasse, Kultur & Profession', 'Aussehen & Hintergrund', 'Eigenschaften', 'Vor- & Nachteile', 'Sonderfertigkeiten', 'Talente', 'Zauber', 'Liturgien', 'Ausrüstung', 'Inventar', 'Charakterbogen'];
const TAGS = ['charbase', 'rcp', 'details', 'attributes', 'disadv', 'specialabilities', 'skills', 'spells', 'liturgies', 'equipment', 'inventory', 'sheets'];
const PHASES = [
[true, false, false, false, false, false, false, false, false, false, false, false],
[false, true, false, false, false, false, false, false, false, false, false, false],
[false, false, true, false, false, false, false, false, false, false, false, false],
[false, false, false, true, true, true, true, true, true, false, false, false],
[true, true, false, true, true, true, true, true, true, true, true, true]
];
return (
<div className="pane-bottomcontent">
<PaneHint label="Zurück" subLabel="zur Heldenliste" icon="&#xE241;" onClick={PaneActions.showHeroList} className="orange" />
{TABS.map((tabname, index) => (
<PaneTabsItem
isOpen={this.props.tab}
tag={TAGS[index]}
label={tabname}
key={'maintab-' + TAGS[index]}
disabled={!PHASES[this.props.phase][index]}
/>
))}
</div>
);
}
}
module.exports = PaneTabsContent;
-35
View File
@@ -1,35 +0,0 @@
var React = require('react');
var HeroActions = require('../../../actions/HeroActions');
var PaneContentHeaderButton = require('../PaneContentHeaderButton');
var PaneContentHeaderDropdown = require('../PaneContentHeaderDropdown');
class PaneTabsHeader extends React.Component {
static propTypes = {
heroname: React.PropTypes.string
};
constructor(props) {
super(props);
}
shouldComponentUpdate(nextProps) {
return nextProps.heroname !== this.props.heroname;
}
render() {
return (
<div className="pane-bottomheader">
<div className="pane-bottomheader-titlebar">
<span>{this.props.heroname}</span>
<PaneContentHeaderButton icon="edit" func={() => { alert('FEATURE MISSING: Editor'); }} />
<PaneContentHeaderButton icon="save" func={HeroActions.save} />
</div>
</div>
);
}
}
module.exports = PaneTabsHeader;
-37
View File
@@ -1,37 +0,0 @@
var AppDispatcher = require('../dispatcher/AppDispatcher');
var EventEmitter = require('events').EventEmitter;
var ActionTypes = require('../constants/ActionTypes');
var RCPStore = Object.assign({}, EventEmitter.prototype, {
emitChange: function() {
this.emit('change');
},
addChangeListener: function(callback) {
this.on('change', callback);
},
removeChangeListener: function(callback) {
this.removeListener('change', callback);
}
});
RCPStore.dispatchToken = AppDispatcher.register( function( payload ) {
switch( payload.actionType ) {
case 'TEST':
break;
default:
return true;
}
RCPStore.emitChange();
return true;
});
module.exports = RCPStore;
-38
View File
@@ -1,38 +0,0 @@
var HeaderDropdown = require('../HeaderDropdown');
var HeroesActions = require('../../../actions/HeroesActions');
var React = require('react');
var RadioButtonGroup = require('../../layout/RadioButtonGroup');
var sortOptions = [
{
name: 'Alphabetisch sortieren',
value: 'name'
},
{
name: 'Nach AP sortieren',
value: 'ap'
}
];
class SortHeroes extends React.Component {
static propTypes = {
isOpen: React.PropTypes.bool
};
constructor(props) {
super(props);
}
sort = option => HeroesActions.sort(option);
render() {
return (
<HeaderDropdown isOpen={this.props.isOpen}>
<RadioButtonGroup active={this.props.sortBy} onClick={this.sort} array={sortOptions} />
</HeaderDropdown>
);
}
}
module.exports = SortHeroes;
-37
View File
@@ -1,37 +0,0 @@
var AppDispatcher = require('../dispatcher/AppDispatcher');
var EventEmitter = require('events').EventEmitter;
var ActionTypes = require('../constants/ActionTypes');
var SpecialAbilitiesStore = Object.assign({}, EventEmitter.prototype, {
emitChange: function() {
this.emit('change');
},
addChangeListener: function(callback) {
this.on('change', callback);
},
removeChangeListener: function(callback) {
this.removeListener('change', callback);
}
});
SpecialAbilitiesStore.dispatchToken = AppDispatcher.register( function( payload ) {
switch( payload.actionType ) {
case 'TEST':
break;
default:
return true;
}
SpecialAbilitiesStore.emitChange();
return true;
});
module.exports = SpecialAbilitiesStore;
-47
View File
@@ -1,47 +0,0 @@
import AppDispatcher from '../dispatcher/AppDispatcher';
import ActionTypes from '../constants/ActionTypes';
var CharbaseActions = {
selectRules: function(value) {
AppDispatcher.dispatch({
actionType: ActionTypes.SET_RULES,
data: { value }
});
},
selectGender: function(value) {
AppDispatcher.dispatch({
actionType: ActionTypes.SET_GENDER,
data: { value }
});
},
changeMaxGP: function(event) {
AppDispatcher.dispatch({
actionType: ActionTypes.SET_GP_MAXIMUM,
data: { value: parseInt(event.target.value) }
});
},
changeAttrGP: function(event) {
AppDispatcher.dispatch({
actionType: ActionTypes.SET_GP_FOR_ATTRIBUTES,
data: { value: parseInt(event.target.value) }
});
},
changeAttrMax: function(event) {
AppDispatcher.dispatch({
actionType: ActionTypes.SET_ATTRIBUTE_MAXIMUM,
data: { value: parseInt(event.target.value) }
});
}
};
export default CharbaseActions;
-10
View File
@@ -36,16 +36,6 @@ var CultureActions = {
actionType: ActionTypes.CHANGE_CULTURE_VIEW,
view
});
},
changePackage: function() {
AppDispatcher.dispatch({
actionType: ActionTypes.CHANGE_CULTURE_PACKAGE
});
},
changeLiteracy: function() {
AppDispatcher.dispatch({
actionType: ActionTypes.CHANGE_CULTURE_LITERACY
});
}
};
-101
View File
@@ -1,101 +0,0 @@
import AppDispatcher from '../dispatcher/AppDispatcher';
import ActionTypes from '../constants/ActionTypes';
import WebAPIUtils from '../utils/WebAPIUtils';
import reactAlert from '../utils/reactAlert';
var HeroActions = {
create: function(heroname) {
AppDispatcher.dispatch({
actionType: ActionTypes.WAIT_START
});
WebAPIUtils.createNewHero(heroname)
.then(function(callback) {
if ( callback == 'false' ) {
reactAlert('Da hat etwas nicht geklappt', 'Dies darf nicht passieren! Melde dies bitte als Fehler! Wir versuchen, das Problem schnellstmöglich zu beheben!');
AppDispatcher.dispatch({
actionType: ActionTypes.WAIT_END
});
} else {
AppDispatcher.dispatch({
actionType: ActionTypes.CREATE_HERO,
heroid: callback,
heroname
});
}
})
.catch(function(){
AppDispatcher.dispatch({
actionType: ActionTypes.WAIT_END
});
});
},
load: function(id) {
AppDispatcher.dispatch({
actionType: ActionTypes.WAIT_START
});
WebAPIUtils.getHero(id).then(function(callback) {
if ( callback == 'false' ) {
reactAlert('Da hat etwas nicht geklappt', 'Dies darf nicht passieren! Melde dies bitte als Fehler! Wir versuchen, das Problem schnellstmöglich zu beheben!');
AppDispatcher.dispatch({
actionType: ActionTypes.WAIT_END
});
} else {
AppDispatcher.dispatch({
actionType: ActionTypes.RECEIVE_HERO,
id
});
}
}).catch(function(){
AppDispatcher.dispatch({
actionType: ActionTypes.WAIT_END
});
});
},
save: function() {
},
clear: function() {
AppDispatcher.dispatch({
actionType: ActionTypes.CLEAR_HERO
});
},
nextPhase: function() {
AppDispatcher.dispatch({
actionType: ActionTypes.INCREASE_PHASE
});
},
rename: function(event) {
AppDispatcher.dispatch({
actionType: ActionTypes.UPDATE_HERONAME,
heroname: event.target.value
});
}
};
export default HeroActions;
-17
View File
@@ -1,17 +0,0 @@
import AppDispatcher from '../dispatcher/AppDispatcher';
import ActionTypes from '../constants/ActionTypes';
var PhaseActions = {
increasePhase: function() {
AppDispatcher.dispatch({
actionType: ActionTypes.INCREASE_PHASE
});
},
resetPhase: function() {
AppDispatcher.dispatch({
actionType: ActionTypes.RESET_PHASE
});
}
};
export default PhaseActions;
-47
View File
@@ -16,53 +16,6 @@ var TabActions = {
actionType: ActionTypes.SHOW_TAB_SECTION,
section
});
},
saveHero: function() {
let currentAccountID = AccountStore.getID();
if (currentAccountID === null) {
reactAlert('Speichern nicht möglich', 'Um einen Charakter zu speichern, musst du angemeldet sein. Dein Fortschritt geht jedoch nicht verloren. Du kannst den Charakter nach der Anmeldung speichern, solange du diese Seite nicht verlässt oder neu lädst.');
} else {
saveHero();
}
},
clearCurrentHero: function() {
AppDispatcher.dispatch({
actionType: ActionTypes.CLEAR_HERO
});
},
deleteCurrentHero: function() {
WebAPIUtils.deleteHero(PaneStore.getUser().id, ControllerStore.getHeroCore().id)
.then(function(callback) {
if ( callback == 'false' ) {
reactAlert('Da hat etwas nicht geklappt', 'Dies darf nicht passieren! Melde dies bitte als Fehler! Wir versuchen, das Problem schnellstmöglich zu beheben!');
AppDispatcher.dispatch({
actionType: ActionTypes.SET_SECTION,
data: { section: 'list' }
});
} else if ( callback == 'true' ) {
AppDispatcher.dispatch({
actionType: ActionTypes.CLEAR_HERO
});
}
})
.catch(function(){
AppDispatcher.dispatch({
actionType: ActionTypes.SET_SECTION,
data: { section: 'list' }
});
});
}
};
-12
View File
@@ -1,12 +0,0 @@
import AppDispatcher from '../dispatcher/AppDispatcher';
import ActionTypes from '../constants/ActionTypes';
var WaitActions = {
end: function() {
AppDispatcher.dispatch({
actionType: ActionTypes.WAIT_END
});
}
};
export default WaitActions;
+13
View File
@@ -114,6 +114,19 @@ class About extends Component {
<br/>
------------------------------------------------------------<br/>
<br/>
babel<br/>
MIT License
<br/>
Copyright (c) 2014-2016 Sebastian McKenzie (sebmck@gmail.com)<br/>
<br/>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:<br/>
<br/>
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.<br/>
<br/>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br/>
<br/>
------------------------------------------------------------<br/>
<br/>
browserify<br/>
Some pieces from builtins/ taken from node core under this license:<br/>
<br/>
+18 -20
View File
@@ -17,6 +17,7 @@ import ProfileStore from '../../../stores/ProfileStore';
import React, { Component } from 'react';
import Scroll from '../../layout/Scroll';
import TextField from '../../layout/TextField';
import calcEL from '../../../utils/calcEL';
class Overview extends Component {
@@ -70,6 +71,7 @@ class Overview extends Component {
rerollWeight = () => ProfileActions.rerollWeight();
endCharacterCreation = () => ProfileActions.endCharacterCreation();
deleteHero = () => ProfileActions.deleteHero();
render() {
@@ -89,19 +91,8 @@ class Overview extends Component {
const sex = this.state.sex === 'm' ? 'Männlich' : 'Weiblich';
const elAp = [ 900, 1000, 1100, 1200, 1400, 1700, 2100 ], ap = APStore.get();
var currentEL = 6;
for (let i = 0; i < elAp.length; i++) {
if (elAp[i] === ap) {
currentEL = i;
break;
} else if (elAp[i] > ap) {
currentEL = i - 1;
break;
}
}
const ap = APStore.get();
const currentEL = calcEL(ap);
const nameElement = editName ? (
<OverviewNameChange
@@ -132,7 +123,7 @@ class Overview extends Component {
}
</div>
<div className="el">
{ELStore.get(`EL_${currentEL + 1}`).name} &middot; {ap} AP
{ELStore.get(currentEL).name} &middot; {ap} AP
</div>
</div>
</div>
@@ -232,12 +223,14 @@ class Overview extends Component {
</div>
{
phase === 2 ? (
<BorderButton
className="end-char-creation"
label="Heldenerstellung beenden"
onClick={this.endCharacterCreation}
primary
/>
<div>
<BorderButton
className="end-char-creation"
label="Heldenerstellung beenden"
onClick={this.endCharacterCreation}
primary
/>
</div>
) : null
}
{
@@ -247,6 +240,11 @@ class Overview extends Component {
<OverviewConstSkills list={this.state.advActive} />
<h3>Nachteile</h3>
<OverviewConstSkills list={this.state.disadvActive} />
<BorderButton
className="delete-char"
label="Held löschen"
onClick={this.deleteHero}
/>
</div>
) : null
}
+4
View File
@@ -156,6 +156,10 @@ var APStore = Object.assign({}, EventEmitter.prototype, {
return _max - _used;
},
getAvailable: function() {
return _max - _used;
},
getForDisAdv: function() {
return {
adv: [_adv, _adv_mag, _adv_kar],
+8 -4
View File
@@ -1,9 +1,9 @@
import AppDispatcher from '../../dispatcher/AppDispatcher';
import AppDispatcher from '../dispatcher/AppDispatcher';
import { EventEmitter } from 'events';
import ActionTypes from '../../constants/ActionTypes';
import ActionTypes from '../constants/ActionTypes';
var _id = 4;
var _name = 'Elytherion';
var _id = null;
var _name = '';
function updateAll(id, name) {
_id = id;
@@ -66,6 +66,10 @@ AccountStore.dispatchToken = AppDispatcher.register( function( payload ) {
reset();
break;
case ActionTypes.RECEIVE_RAW_LISTS:
updateAll(4, 'Elytherion');
break;
default:
return true;
}
+2 -39
View File
@@ -17,14 +17,6 @@ var _sk = 0;
var _zk = 0;
var _gs = 0;
function _addPoint(id) {
ListStore.addAttrPoint(id);
}
function _removePoint(id) {
ListStore.removeAttrPoint(id);
}
function _addMaxEnergyPoint(id) {
switch (id) {
case 'LE':
@@ -40,11 +32,6 @@ function _addMaxEnergyPoint(id) {
}
function _clear() {
ListStore.getAllByCategory(CATEGORY).forEach(e => {
ListStore.setProperty(e.id, 'value', 8);
ListStore.setProperty(e.id, 'mod', 0);
ListStore.setProperty(e.id, 'dependencies', []);
});
_le = 0;
_le_add = 0;
_ae_add = 0;
@@ -55,10 +42,6 @@ function _clear() {
}
function _updateAll(obj) {
obj.values.forEach(e => {
ListStore.setProperty(e[0], 'value', e[1]);
ListStore.setProperty(e[0], 'mod', e[2]);
});
_le = obj._le;
_le_add = obj._le_add;
_ae_add = obj._ae_add;
@@ -68,27 +51,15 @@ function _updateAll(obj) {
_gs = obj._gs;
}
function _assignRCP(selections) {
let currentRace = RaceStore.getCurrent() || {};
let mod = 0;
mod = currentRace.attr_sel[0];
function _assignRCP() {
let currentRace = RaceStore.getCurrent() || { le: 0, sk: 0, zk: 0, gs: 0 };
_le = currentRace.le;
_sk = currentRace.sk;
_zk = currentRace.zk;
_gs = currentRace.gs;
ListStore.addToProperty(selections.attrSel, 'mod', mod);
}
var AttributeStore = Object.assign({}, EventEmitter.prototype, {
init: function(rawAttributes) {
for (let id in rawAttributes) {
rawAttributes[id].category = CATEGORY;
}
ListStore.init(rawAttributes);
},
emitChange: function() {
this.emit('change');
@@ -191,11 +162,7 @@ AttributeStore.dispatchToken = AppDispatcher.register( function( payload ) {
break;
case ActionTypes.ADD_ATTRIBUTE_POINT:
_addPoint(payload.id);
break;
case ActionTypes.REMOVE_ATTRIBUTE_POINT:
_removePoint(payload.id);
break;
case ActionTypes.ADD_MAX_ENERGY_POINT:
@@ -205,10 +172,6 @@ AttributeStore.dispatchToken = AppDispatcher.register( function( payload ) {
case ActionTypes.ASSIGN_RCP_ENTRIES:
_assignRCP(payload.selections);
break;
case ActionTypes.RECEIVE_RAW_LISTS:
AttributeStore.init(payload.attributes);
break;
default:
return true;
+2 -71
View File
@@ -3,8 +3,6 @@ import { EventEmitter } from 'events';
import ELStore from './ELStore';
import ListStore from './ListStore';
import PhaseStore from './PhaseStore';
import ProfessionStore from './ProfessionStore';
import ProfessionVariantStore from './ProfessionVariantStore';
import ActionTypes from '../constants/ActionTypes';
import Categories from '../constants/Categories';
@@ -13,14 +11,6 @@ const CATEGORY = Categories.COMBAT_TECHNIQUES;
var _filter = '';
var _sortOrder = 'name';
function _addPoint(id) {
ListStore.addPoint(id);
}
function _removePoint(id) {
ListStore.removePoint(id);
}
function _updateFilterText(text) {
_filter = text;
}
@@ -28,46 +18,8 @@ function _updateFilterText(text) {
function _updateSortOrder(option) {
_sortOrder = option;
}
function _clear() {
ListStore.getAllByCategory(CATEGORY).forEach(e => {
ListStore.setSR(e.id, 6);
ListStore.setProperty(e.id, 'dependencies', []);
});
}
function _updateAll(obj) {
obj.active.forEach(e => {
ListStore.setSR(...e);
});
}
function _assignRCP(selections) {
var list = [];
if ([null, 'P_0'].indexOf(ProfessionStore.getCurrentID()) === -1)
list.push(...ProfessionStore.getCurrent().combattech);
if (ProfessionVariantStore.getCurrentID() !== null)
list.push(...ProfessionVariantStore.getCurrent().combattech);
list.forEach(e => ListStore.addSR(e[0], e[1]));
Array.from(selections.combattech).forEach(e => {
ListStore.activate(e);
ListStore.addSR(e, selections.map.get('ct')[1]);
});
}
var CombatTechniquesStore = Object.assign({}, EventEmitter.prototype, {
init: function(rawTechniques) {
for (let id in rawTechniques) {
rawTechniques[id].fw = 6;
rawTechniques[id].category = CATEGORY;
rawTechniques[id].dependencies = [];
}
ListStore.init(rawTechniques);
},
emitChange: function() {
this.emit('change');
@@ -187,13 +139,8 @@ CombatTechniquesStore.dispatchToken = AppDispatcher.register( function( payload
switch( payload.actionType ) {
case ActionTypes.CLEAR_HERO:
case ActionTypes.CREATE_NEW_HERO:
_clear();
break;
case ActionTypes.RECEIVE_HERO:
_updateAll(payload.ct);
case ActionTypes.ADD_COMBATTECHNIQUE_POINT:
case ActionTypes.REMOVE_COMBATTECHNIQUE_POINT:
break;
case ActionTypes.FILTER_COMBATTECHNIQUES:
@@ -203,22 +150,6 @@ CombatTechniquesStore.dispatchToken = AppDispatcher.register( function( payload
case ActionTypes.SORT_COMBATTECHNIQUES:
_updateSortOrder(payload.option);
break;
case ActionTypes.ADD_COMBATTECHNIQUE_POINT:
_addPoint(payload.id);
break;
case ActionTypes.REMOVE_COMBATTECHNIQUE_POINT:
_removePoint(payload.id);
break;
case ActionTypes.ASSIGN_RCP_ENTRIES:
_assignRCP(payload.selections);
break;
case ActionTypes.RECEIVE_RAW_LISTS:
CombatTechniquesStore.init(payload.combattech);
break;
default:
return true;
+2 -2
View File
@@ -1,7 +1,7 @@
import AppDispatcher from '../../dispatcher/AppDispatcher';
import AppDispatcher from '../dispatcher/AppDispatcher';
import { EventEmitter } from 'events';
import RaceStore from './RaceStore';
import ActionTypes from '../../constants/ActionTypes';
import ActionTypes from '../constants/ActionTypes';
var _currentID = null;
var _cultures = {};
+4
View File
@@ -37,6 +37,10 @@ var ELStore = Object.assign({}, EventEmitter.prototype, {
return _el[id];
},
getAll: function() {
return _el;
},
getStartID: function() {
return _start;
},
+3 -3
View File
@@ -1,6 +1,6 @@
import AppDispatcher from '../../dispatcher/AppDispatcher';
import AppDispatcher from '../dispatcher/AppDispatcher';
import { EventEmitter } from 'events';
import ActionTypes from '../../constants/ActionTypes';
import ActionTypes from '../constants/ActionTypes';
var _heroes = {
'H_1': {
@@ -139,7 +139,7 @@ HerolistStore.dispatchToken = AppDispatcher.register( function( payload ) {
case ActionTypes.RECEIVE_ACCOUNT:
case ActionTypes.RECEIVE_RAW_HEROES:
_updateHeroes(payload.rawHeroes);
_updateHeroes(payload.heroes);
break;
default:
+214 -65
View File
@@ -1,6 +1,11 @@
import AppDispatcher from '../dispatcher/AppDispatcher';
import { EventEmitter } from 'events';
import CultureStore from './CultureStore';
import ProfessionStore from './ProfessionStore';
import ProfessionVariantStore from './ProfessionVariantStore';
import RaceStore from './RaceStore';
import ActionTypes from '../constants/ActionTypes';
import Categories from '../constants/Categories';
var _list = {};
@@ -13,21 +18,21 @@ function _deactivate(id) {
}
function _addPoint(id) {
_list[id].fw++;
}
function _removePoint(id) {
_list[id].fw--;
}
function _addAttrPoint(id) {
_list[id].value++;
}
function _removeAttrPoint(id) {
function _removePoint(id) {
_list[id].value--;
}
function _setValue(id, value) {
_list[id].value = value;
}
function _addSR(id, amount) {
_list[id].value += amount;
}
function _addDependencies(reqs, sel) {
reqs.forEach(req => {
let [ id, value, option ] = req;
@@ -91,12 +96,147 @@ function _removeDependencies(reqs, sel) {
}
});
}
function _init({ attributes, talents, combattech, spells, liturgies }) {
for (let id in attributes) {
_list[id] = attributes[id];
_list[id].category = Categories.ATTRIBUTES;
_list[id].dependencies = [];
}
for (let id in talents) {
_list[id] = talents[id];
_list[id].value = 0;
_list[id].category = Categories.TALENTS;
_list[id].dependencies = [];
}
for (let id in combattech) {
_list[id] = combattech[id];
_list[id].value = 6;
_list[id].category = Categories.COMBAT_TECHNIQUES;
_list[id].dependencies = [];
}
for (let id in spells) {
_list[id] = spells[id];
_list[id].value = 0;
_list[id].check = _list[id].check.map((e,i) => i < 3 ? `ATTR_${e}` : e);
_list[id].active = false;
_list[id].category = Categories.SPELLS;
_list[id].dependencies = [];
}
for (let id in liturgies) {
_list[id] = liturgies[id];
_list[id].value = 0;
_list[id].check = _list[id].check.map((e,i) => i < 3 ? `ATTR_${e}` : e);
_list[id].active = false;
_list[id].category = Categories.CHANTS;
_list[id].dependencies = [];
}
}
function _updateAll({ attr, talents, ct, spells, chants }) {
attr.values.forEach(e => {
let [ id, value, mod ] = e;
_setValue(id, value);
_list[id].mod = mod;
});
talents.active.forEach(e => {
_setValue(...e);
});
ct.active.forEach(e => {
_setValue(...e);
});
spells.active.forEach(e => {
_activate(e[0]);
if (_list[e[0]].gr !== 5) {
_setValue(...e);
}
});
chants.active.forEach(e => {
_activate(e[0]);
if (_list[e[0]].gr !== 3) {
_setValue(...e);
}
});
}
function _assignRCP(selections) {
let currentRace = RaceStore.getCurrent() || {};
_list[selections.attrSel].mod = currentRace.attr_sel[0] || 0;
var addSRList = [];
var addSRActivateList = [];
if (selections.useCulturePackage) {
addSRList.push(...CultureStore.getCurrent().talents);
}
if ([null, 'P_0'].indexOf(ProfessionStore.getCurrentID()) === -1) {
addSRList.push(...ProfessionStore.getCurrent().talents);
addSRList.push(...ProfessionStore.getCurrent().combattech);
addSRActivateList.push(...ProfessionStore.getCurrent().spells);
addSRActivateList.push(...ProfessionStore.getCurrent().chants);
}
if (ProfessionVariantStore.getCurrentID() !== null) {
addSRList.push(...ProfessionVariantStore.getCurrent().talents);
addSRList.push(...ProfessionVariantStore.getCurrent().combattech);
}
Array.from(selections.combattech).forEach(e => {
addSRList.push([e, selections.map.get('ct')[1]]);
});
Array.from(selections.cantrips).forEach(e => {
addSRList.push([e, null]);
});
Array.from(selections.curses).forEach(e => {
addSRList.push(e);
});
addSRList.forEach(e => _addSR(...e));
addSRActivateList.forEach(e => {
_activate(e[0]);
if (e[1] !== null) {
_setValue(e[0], e[1]);
}
});
}
function _clear() {
for (let id in _list) {
let e = _list[id];
switch (e.category) {
case Categories.ATTRIBUTES:
e.value = 8;
e.value = 0;
e.dependencies = [];
break;
case Categories.TALENTS:
e.value = 0;
e.dependencies = [];
break;
case Categories.COMBAT_TECHNIQUES:
e.value = 6;
e.dependencies = [];
break;
case Categories.SPELLS:
e.active = false;
e.value = 0;
e.dependencies = [];
break;
case Categories.CHANTS:
e.active = false;
e.value = 0;
e.dependencies = [];
break;
}
}
}
var ListStore = Object.assign({}, EventEmitter.prototype, {
init: function(...obj) {
_list = Object.assign(_list, ...obj);
},
init: function() {},
emitChange: function() {
this.emit('change');
@@ -110,60 +250,12 @@ var ListStore = Object.assign({}, EventEmitter.prototype, {
this.removeListener('change', callback);
},
set: function(id, obj) {
_list[id] = obj;
addDependencies: function(...props) {
_addDependencies(...props);
},
setSR: function(id, value) {
_list[id].fw = value;
},
setProperty: function(id, property, value) {
if (value === undefined) {
delete _list[id][property];
} else {
_list[id][property] = value;
}
},
addToProperty: function(id, property, value) {
_list[id][property] += value;
},
addSR: function(id, value) {
this.addToProperty(id, 'fw', value);
},
addDependencies: function(reqs, sel) {
_addDependencies(reqs, sel);
},
removeDependencies: function(reqs, sel) {
_removeDependencies(reqs, sel);
},
activate: function(id) {
_activate(id);
},
deactivate: function(id) {
_deactivate(id);
},
addPoint: function(id) {
_addPoint(id);
},
removePoint: function(id) {
_removePoint(id);
},
addAttrPoint: function(id) {
_addAttrPoint(id);
},
removeAttrPoint: function(id) {
_removeAttrPoint(id);
removeDependencies: function(...props) {
_removeDependencies(...props);
},
get: function(id) {
@@ -252,4 +344,61 @@ var ListStore = Object.assign({}, EventEmitter.prototype, {
});
ListStore.dispatchToken = AppDispatcher.register( function( payload ) {
switch( payload.actionType ) {
case ActionTypes.RECEIVE_RAW_LISTS:
_init(payload);
break;
case ActionTypes.RECEIVE_HERO:
_updateAll(payload);
break;
case ActionTypes.ASSIGN_RCP_ENTRIES:
_assignRCP(payload.selections);
break;
case ActionTypes.CLEAR_HERO:
case ActionTypes.CREATE_NEW_HERO:
_clear();
break;
case ActionTypes.ACTIVATE_SPELL:
case ActionTypes.ACTIVATE_LITURGY:
_activate(payload.id);
break;
case ActionTypes.DEACTIVATE_SPELL:
case ActionTypes.DEACTIVATE_LITURGY:
_deactivate(payload.id);
break;
case ActionTypes.ADD_ATTRIBUTE_POINT:
case ActionTypes.ADD_TALENT_POINT:
case ActionTypes.ADD_COMBATTECHNIQUE_POINT:
case ActionTypes.ADD_SPELL_POINT:
case ActionTypes.ADD_LITURGY_POINT:
_addPoint(payload.id);
break;
case ActionTypes.REMOVE_ATTRIBUTE_POINT:
case ActionTypes.REMOVE_TALENT_POINT:
case ActionTypes.REMOVE_COMBATTECHNIQUE_POINT:
case ActionTypes.REMOVE_SPELL_POINT:
case ActionTypes.REMOVE_LITURGY_POINT:
_removePoint(payload.id);
break;
default:
return true;
}
ListStore.emitChange();
return true;
});
export default ListStore;
+4 -89
View File
@@ -3,7 +3,6 @@ import { EventEmitter } from 'events';
import ELStore from './ELStore';
import ListStore from './ListStore';
import PhaseStore from './PhaseStore';
import ProfessionStore from './ProfessionStore';
import ActionTypes from '../constants/ActionTypes';
import Categories from '../constants/Categories';
@@ -12,22 +11,6 @@ const CATEGORY = Categories.CHANTS;
var _filter = '';
var _sortOrder = 'name';
function _activate(id) {
ListStore.activate(id);
}
function _deactivate(id) {
ListStore.deactivate(id);
}
function _addPoint(id) {
ListStore.addPoint(id);
}
function _removePoint(id) {
ListStore.removePoint(id);
}
function _updateFilterText(text) {
_filter = text;
}
@@ -36,36 +19,6 @@ function _updateSortOrder(option) {
_sortOrder = option;
}
function _clear() {
ListStore.getAllByCategory(CATEGORY).forEach(e => {
ListStore.deactivate(e.id);
ListStore.setSR(e.id, 0);
ListStore.setProperty(e.id, 'dependencies', []);
});
}
function _updateAll(obj) {
obj.active.forEach(e => {
ListStore.activate(e[0]);
if (ListStore.get(e[0]).gr !== 3) {
ListStore.setSR(...e);
}
});
}
function _assignRCP() {
var list = [];
if ([null, 'P_0'].indexOf(ProfessionStore.getCurrentID()) === -1)
list.push(...ProfessionStore.getCurrent().chants);
list.forEach(e => {
ListStore.activate(e[0]);
if (e[1] !== null)
ListStore.setSR(e[0], e[1]);
});
}
function _filterAndSort(array) {
if (_filter !== '') {
let filter = _filter.toLowerCase();
@@ -102,17 +55,6 @@ function _filterAndSort(array) {
}
var LiturgiesStore = Object.assign({}, EventEmitter.prototype, {
init: function(obj) {
for (let id in obj) {
obj[id].fw = 0;
obj[id].check = obj[id].check.map((e,i) => i < 3 ? `ATTR_${e}` : e);
obj[id].active = false;
obj[id].category = CATEGORY;
obj[id].dependencies = [];
}
ListStore.init(obj);
},
emitChange: function() {
this.emit('change');
@@ -238,13 +180,10 @@ LiturgiesStore.dispatchToken = AppDispatcher.register( function( payload ) {
switch( payload.actionType ) {
case ActionTypes.CLEAR_HERO:
case ActionTypes.CREATE_NEW_HERO:
_clear();
break;
case ActionTypes.RECEIVE_HERO:
_updateAll(payload.chants);
case ActionTypes.ACTIVATE_LITURGY:
case ActionTypes.DEACTIVATE_LITURGY:
case ActionTypes.ADD_LITURGY_POINT:
case ActionTypes.REMOVE_LITURGY_POINT:
break;
case ActionTypes.FILTER_LITURGIES:
@@ -254,30 +193,6 @@ LiturgiesStore.dispatchToken = AppDispatcher.register( function( payload ) {
case ActionTypes.SORT_LITURGIES:
_updateSortOrder(payload.option);
break;
case ActionTypes.ACTIVATE_LITURGY:
_activate(payload.id);
break;
case ActionTypes.DEACTIVATE_LITURGY:
_deactivate(payload.id);
break;
case ActionTypes.ADD_LITURGY_POINT:
_addPoint(payload.id);
break;
case ActionTypes.REMOVE_LITURGY_POINT:
_removePoint(payload.id);
break;
case ActionTypes.ASSIGN_RCP_ENTRIES:
_assignRCP(payload.selections);
break;
case ActionTypes.RECEIVE_RAW_LISTS:
LiturgiesStore.init(payload.liturgies);
break;
default:
return true;
+3 -3
View File
@@ -1,9 +1,9 @@
import AppDispatcher from '../../dispatcher/AppDispatcher';
import AppDispatcher from '../dispatcher/AppDispatcher';
import CultureStore from './CultureStore';
import ELStore from '../ELStore';
import ELStore from './ELStore';
import RaceStore from './RaceStore';
import { EventEmitter } from 'events';
import ActionTypes from '../../constants/ActionTypes';
import ActionTypes from '../constants/ActionTypes';
var _currentID = null;
var _professions = {};
+3 -3
View File
@@ -1,9 +1,9 @@
import AppDispatcher from '../../dispatcher/AppDispatcher';
import AppDispatcher from '../dispatcher/AppDispatcher';
import CultureStore from './CultureStore';
import { EventEmitter } from 'events';
import ProfessionStore from './ProfessionStore';
import ProfileStore from '../ProfileStore';
import ActionTypes from '../../constants/ActionTypes';
import ProfileStore from './ProfileStore';
import ActionTypes from '../constants/ActionTypes';
var _currentID = null;
var _professionVariants = [];
+2 -2
View File
@@ -1,6 +1,6 @@
import AppDispatcher from '../../dispatcher/AppDispatcher';
import AppDispatcher from '../dispatcher/AppDispatcher';
import { EventEmitter } from 'events';
import ActionTypes from '../../constants/ActionTypes';
import ActionTypes from '../constants/ActionTypes';
var _currentID = 'R_1';
var _races = {};
+4 -96
View File
@@ -14,22 +14,6 @@ const TRADITIONS = ['Allgemein', 'Gildenmagier', 'Hexen', 'Elfen'];
var _filter = '';
var _sortOrder = 'name';
function _activate(id) {
ListStore.activate(id);
}
function _deactivate(id) {
ListStore.deactivate(id);
}
function _addPoint(id) {
ListStore.addPoint(id);
}
function _removePoint(id) {
ListStore.removePoint(id);
}
function _updateFilterText(text) {
_filter = text;
}
@@ -38,44 +22,6 @@ function _updateSortOrder(option) {
_sortOrder = option;
}
function _clear() {
ListStore.getAllByCategory(CATEGORY).forEach(e => {
ListStore.deactivate(e.id);
ListStore.setSR(e.id, 0);
ListStore.setProperty(e.id, 'dependencies', []);
});
}
function _updateAll(obj) {
obj.active.forEach(e => {
ListStore.activate(e[0]);
if (ListStore.get(e[0]).gr !== 5) {
ListStore.setSR(...e);
}
});
}
function _assignRCP(selections) {
var list = [];
if ([null, 'P_0'].indexOf(ProfessionStore.getCurrentID()) === -1)
list.push(...ProfessionStore.getCurrent().spells);
list.forEach(e => {
ListStore.activate(e[0]);
ListStore.setSR(e[0], e[1]);
});
Array.from(selections.cantrips).forEach(e => {
ListStore.activate(e);
});
for (let [key, value] of selections.curses) {
ListStore.activate(key);
ListStore.setSR(key, value);
}
}
function _filterAndSort(array) {
if (_filter !== '') {
let filter = _filter.toLowerCase();
@@ -129,17 +75,6 @@ function _filterAndSort(array) {
}
var SpellsStore = Object.assign({}, EventEmitter.prototype, {
init: function(obj) {
for (let id in obj) {
obj[id].fw = 0;
obj[id].check = obj[id].check.map((e,i) => i < 3 ? `ATTR_${e}` : e);
obj[id].active = false;
obj[id].category = CATEGORY;
obj[id].dependencies = [];
}
ListStore.init(obj);
},
emitChange: function() {
this.emit('change');
@@ -273,13 +208,10 @@ SpellsStore.dispatchToken = AppDispatcher.register( function( payload ) {
switch( payload.actionType ) {
case ActionTypes.CLEAR_HERO:
case ActionTypes.CREATE_NEW_HERO:
_clear();
break;
case ActionTypes.RECEIVE_HERO:
_updateAll(payload.spells);
case ActionTypes.ACTIVATE_SPELL:
case ActionTypes.DEACTIVATE_SPELL:
case ActionTypes.ADD_SPELL_POINT:
case ActionTypes.REMOVE_SPELL_POINT:
break;
case ActionTypes.FILTER_SPELLS:
@@ -289,30 +221,6 @@ SpellsStore.dispatchToken = AppDispatcher.register( function( payload ) {
case ActionTypes.SORT_SPELLS:
_updateSortOrder(payload.option);
break;
case ActionTypes.ACTIVATE_SPELL:
_activate(payload.id);
break;
case ActionTypes.DEACTIVATE_SPELL:
_deactivate(payload.id);
break;
case ActionTypes.ADD_SPELL_POINT:
_addPoint(payload.id);
break;
case ActionTypes.REMOVE_SPELL_POINT:
_removePoint(payload.id);
break;
case ActionTypes.ASSIGN_RCP_ENTRIES:
_assignRCP(payload.selections);
break;
case ActionTypes.RECEIVE_RAW_LISTS:
SpellsStore.init(payload.spells);
break;
default:
return true;
+3 -3
View File
@@ -1,8 +1,8 @@
import AppDispatcher from '../../dispatcher/AppDispatcher';
import AppDispatcher from '../dispatcher/AppDispatcher';
import { EventEmitter } from 'events';
import ActionTypes from '../../constants/ActionTypes';
import ActionTypes from '../constants/ActionTypes';
import AccountStore from './AccountStore';
import PhaseStore from '../PhaseStore';
import PhaseStore from './PhaseStore';
var _currentTab = 'herolist';
var _currentSection = 'main';
+6 -74
View File
@@ -1,11 +1,8 @@
import AppDispatcher from '../dispatcher/AppDispatcher';
import { EventEmitter } from 'events';
import CultureStore from './CultureStore';
import ELStore from './ELStore';
import ListStore from './ListStore';
import PhaseStore from './PhaseStore';
import ProfessionStore from './ProfessionStore';
import ProfessionVariantStore from './ProfessionVariantStore';
import ActionTypes from '../constants/ActionTypes';
import Categories from '../constants/Categories';
@@ -15,14 +12,6 @@ var _filter = '';
var _sortOrder = 'groups';
var _talentRating = true;
function _addPoint(id) {
ListStore.addPoint(id);
}
function _removePoint(id) {
ListStore.removePoint(id);
}
function _updateFilterText(text) {
_filter = text;
}
@@ -34,48 +23,8 @@ function _updateSortOrder(option) {
function _updateTalentRating() {
_talentRating = !_talentRating;
}
function _clear() {
ListStore.getAllByCategory(CATEGORY).forEach(e => {
ListStore.setSR(e.id, 0);
ListStore.setProperty(e.id, 'dependencies', []);
});
}
function _updateAll(obj) {
obj.active.forEach(e => {
ListStore.setSR(...e);
});
_talentRating = obj._talentRating;
}
function _assignRCP(selections) {
var list = [];
if (selections.useCulturePackage)
list.push(...CultureStore.getCurrent().talents);
if ([null, 'P_0'].indexOf(ProfessionStore.getCurrentID()) === -1)
list.push(...ProfessionStore.getCurrent().talents);
if (ProfessionVariantStore.getCurrentID() !== null)
list.push(...ProfessionVariantStore.getCurrent().talents);
list.forEach(e => ListStore.addSR(e[0], e[1]));
}
var TalentsStore = Object.assign({}, EventEmitter.prototype, {
init: function(rawTalents) {
for (let id in rawTalents) {
rawTalents[id].fw = 0;
rawTalents[id].category = CATEGORY;
rawTalents[id].dependencies = [];
}
ListStore.init(rawTalents);
},
getNameByID: function(id) {
return ListStore.get(id).name;
},
emitChange: function() {
this.emit('change');
@@ -108,6 +57,10 @@ var TalentsStore = Object.assign({}, EventEmitter.prototype, {
return ListStore.get(id);
},
getNameByID: function(id) {
return ListStore.get(id).name;
},
getAllForView: function() {
var phase = PhaseStore.get();
@@ -187,13 +140,8 @@ TalentsStore.dispatchToken = AppDispatcher.register( function( payload ) {
switch( payload.actionType ) {
case ActionTypes.CLEAR_HERO:
case ActionTypes.CREATE_NEW_HERO:
_clear();
break;
case ActionTypes.RECEIVE_HERO:
_updateAll(payload.talents);
case ActionTypes.ADD_TALENT_POINT:
case ActionTypes.REMOVE_TALENT_POINT:
break;
case ActionTypes.FILTER_TALENTS:
@@ -207,22 +155,6 @@ TalentsStore.dispatchToken = AppDispatcher.register( function( payload ) {
case ActionTypes.CHANGE_TALENT_RATING:
_updateTalentRating();
break;
case ActionTypes.ADD_TALENT_POINT:
_addPoint(payload.id);
break;
case ActionTypes.REMOVE_TALENT_POINT:
_removePoint(payload.id);
break;
case ActionTypes.ASSIGN_RCP_ENTRIES:
_assignRCP(payload.selections);
break;
case ActionTypes.RECEIVE_RAW_LISTS:
TalentsStore.init(payload.talents);
break;
default:
return true;
+2 -2
View File
@@ -1,6 +1,6 @@
import AppDispatcher from '../../dispatcher/AppDispatcher';
import AppDispatcher from '../dispatcher/AppDispatcher';
import { EventEmitter } from 'events';
import ActionTypes from '../../constants/ActionTypes';
import ActionTypes from '../constants/ActionTypes';
var _waiting = true;
+24
View File
@@ -0,0 +1,24 @@
jest.mock('../../dispatcher/AppDispatcher');
import AccountStore from '../AccountStore';
import ActionTypes from '../../constants/ActionTypes';
import AppDispatcher from '../../dispatcher/AppDispatcher';
describe('AccountStore', () => {
const callback = AppDispatcher.register.mock.calls[0][0];
it('initializes with empty data fields', () => {
const account = AccountStore.getAll();
expect(account).toEqual({ id: null, name: '' });
});
it('receives new account', () => {
callback({
actionType: ActionTypes.RECEIVE_ACCOUNT,
id: 4,
name: 'Elytherion'
});
const account = AccountStore.getAll();
expect(account).toEqual({ id: 4, name: 'Elytherion' });
});
});
+6 -5
View File
@@ -131,7 +131,7 @@ var WebAPIUtils = {
}
},
loadHero: async function(id) {
try {
// try {
ServerActions.startLoading();
ServerActions.loadHeroSuccess(id, `{
"sex":"m",
@@ -176,7 +176,8 @@ var WebAPIUtils = {
},
"talents":{
"active":[["TAL_8",6],["TAL_10",4],["TAL_18",7],["TAL_20",5],["TAL_21",4],["TAL_25",4],["TAL_28",9],["TAL_29",7],["TAL_34",4],["TAL_38",5],["TAL_39",3],["TAL_40",2],["TAL_47",5],["TAL_48",8],["TAL_50",7],["TAL_51",1],["TAL_55",1],["TAL_59",1]],
"_talentRating":true},
"_talentRating":true
},
"ct":{
"active":[["CT_3",8],["CT_5",8]]
},
@@ -193,9 +194,9 @@ var WebAPIUtils = {
}`);
// let result = await request.get('php/gethero.php?hid=' + id);
// ServerActions.loadHeroSuccess(id, result);
} catch(e) {
ServerActions.connectionError(e);
}
// } catch(e) {
// ServerActions.connectionError(e);
// }
},
createNewHero: async function(heroname) {
try {
+17 -2
View File
@@ -1,13 +1,28 @@
import { getAC, getIC } from '../iccalc';
jest.mock('../../stores/APStore');
import APStore from '../../stores/APStore';
import iccalc, { getIC } from '../iccalc';
describe('iccalc', () => {
APStore.getAvailable.mockReturnValue(24);
it('returns 45 ap cost for SR 16 IC 5', () => {
const ap = getIC(5, 16);
expect(ap).toBe(45);
});
it('returns 4 ap cost for activating IC 4', () => {
const ap = getAC(4);
const ap = getIC(4, 0);
expect(ap).toBe(4);
});
it('accepts to get 15 AP back', () => {
const valid = iccalc(-15);
expect(valid).toBe(true);
});
it('fails to buy IC 4 SR 18', () => {
const valid = iccalc(4, 18);
expect(valid).toBe(false);
});
});
+16
View File
@@ -0,0 +1,16 @@
import ELStore from '../stores/ELStore';
export default ap => {
const els = ELStore.getAll();
let ids = [];
let tiers = [];
for (let id in els) {
ids.push(id);
tiers.push(els[id].ap);
}
for (let i = 0; i < tiers.length; i++) {
if (ap <= tiers[i])
return ids[i];
}
};
+26 -5
View File
@@ -1,10 +1,8 @@
import APStore from '../stores/APStore';
// AC = Activation Cost
// IC = Improvement Cost
export function getAC(ic) {
return ic === 5 ? 15 : ic;
}
export function getIC(ic, sr) {
const f = ic === 5 ? 15 : ic;
if (sr < 12 || (ic === 5 && sr < 14)) {
@@ -14,4 +12,27 @@ export function getIC(ic, sr) {
}
}
export default { getAC, getIC };
export function final(ic, sr) {
if (sr) {
let add = 1;
if (ic < 0) {
ic = Math.abs(ic);
add = -1;
}
return getIC(ic, sr) * add;
} else {
return ic;
}
}
export function check(cost) {
if (cost > 0) {
let available = APStore.getAvailable();
return cost <= available;
}
return true;
}
export const validate = (ic, sr) => check(final(ic, sr));
export default validate;
@@ -1,18 +1,21 @@
{
"_args": [
[
"babel-code-frame@^6.16.0",
"C:\\Users\\Lukas Obermann\\Projekte\\Cha5App\\code\\git\\node_modules\\babel-plugin-transform-es2015-block-scoping\\node_modules\\babel-traverse"
],
[
"babel-code-frame@^6.16.0",
{
"raw": "babel-code-frame@^6.16.0",
"scope": null,
"escapedName": "babel-code-frame",
"name": "babel-code-frame",
"rawSpec": "^6.16.0",
"spec": ">=6.16.0 <7.0.0",
"type": "range"
},
"C:\\Users\\Lukas Obermann\\Projekte\\Cha5App\\code\\git\\node_modules\\babel-plugin-transform-es2015-classes\\node_modules\\babel-traverse"
]
],
"_from": "babel-code-frame@>=6.16.0 <7.0.0",
"_id": "babel-code-frame@6.16.0",
"_inCache": true,
"_installable": true,
"_location": "/babel-plugin-transform-es2015-classes/babel-code-frame",
"_nodeVersion": "5.11.1",
"_npmOperationalInternal": {
@@ -20,28 +23,31 @@
"tmp": "tmp/babel-code-frame-6.16.0.tgz_1475091527344_0.9727453696541488"
},
"_npmUser": {
"email": "hi@henryzoo.com",
"name": "hzoo"
"name": "hzoo",
"email": "hi@henryzoo.com"
},
"_npmVersion": "3.10.8",
"_phantomChildren": {},
"_requested": {
"name": "babel-code-frame",
"raw": "babel-code-frame@^6.16.0",
"rawSpec": "^6.16.0",
"scope": null,
"escapedName": "babel-code-frame",
"name": "babel-code-frame",
"rawSpec": "^6.16.0",
"spec": ">=6.16.0 <7.0.0",
"type": "range"
},
"_requiredBy": [
"/babel-plugin-transform-es2015-classes/babel-traverse"
],
"_resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.16.0.tgz",
"_shasum": "f90e60da0862909d3ce098733b5d3987c97cb8de",
"_shrinkwrap": null,
"_spec": "babel-code-frame@^6.16.0",
"_where": "C:\\Users\\Lukas Obermann\\Projekte\\Cha5App\\code\\git\\node_modules\\babel-plugin-transform-es2015-classes\\node_modules\\babel-traverse",
"author": {
"email": "sebmck@gmail.com",
"name": "Sebastian McKenzie"
"name": "Sebastian McKenzie",
"email": "sebmck@gmail.com"
},
"dependencies": {
"chalk": "^1.1.0",
@@ -60,28 +66,28 @@
"main": "lib/index.js",
"maintainers": [
{
"email": "amjad.masad@gmail.com",
"name": "amasad"
"name": "amasad",
"email": "amjad.masad@gmail.com"
},
{
"email": "hi@henryzoo.com",
"name": "hzoo"
"name": "hzoo",
"email": "hi@henryzoo.com"
},
{
"email": "npm-public@jessemccarthy.net",
"name": "jmm"
"name": "jmm",
"email": "npm-public@jessemccarthy.net"
},
{
"email": "loganfsmyth@gmail.com",
"name": "loganfsmyth"
"name": "loganfsmyth",
"email": "loganfsmyth@gmail.com"
},
{
"email": "sebmck@gmail.com",
"name": "sebmck"
"name": "sebmck",
"email": "sebmck@gmail.com"
},
{
"email": "me@thejameskyle.com",
"name": "thejameskyle"
"name": "thejameskyle",
"email": "me@thejameskyle.com"
}
],
"name": "babel-code-frame",
@@ -1,2 +0,0 @@
scripts
node_modules
@@ -1,2 +0,0 @@
# babel-runtime
@@ -1,4 +0,0 @@
module.exports = {
"default": require("core-js/library"),
__esModule: true
};
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/concat"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/copy-within"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/entries"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/every"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/fill"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/filter"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/find-index"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/find"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/for-each"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/from"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/includes"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/index-of"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/join"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/keys"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/last-index-of"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/map"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/of"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/pop"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/push"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/reduce-right"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/reduce"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/reverse"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/shift"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/slice"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/some"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/sort"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/splice"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/unshift"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/array/values"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/asap"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/clear-immediate"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/error/is-error"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/get-iterator"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/is-iterable"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/json/stringify"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/map"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/acosh"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/asinh"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/atanh"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/cbrt"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/clz32"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/cosh"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/expm1"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/fround"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/hypot"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/iaddh"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/imul"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/imulh"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/isubh"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/log10"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/log1p"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/log2"), __esModule: true };
@@ -1 +0,0 @@
module.exports = { "default": require("core-js/library/fn/math/sign"), __esModule: true };

Some files were not shown because too many files have changed in this diff Show More