mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-28 15:42:38 +00:00
Workign on the homebrew
This commit is contained in:
23
shared/naturalCrit/combat.actions.js
Normal file
23
shared/naturalCrit/combat.actions.js
Normal file
@@ -0,0 +1,23 @@
|
||||
var dispatch = require('pico-flux').dispatch;
|
||||
|
||||
module.exports = {
|
||||
updateMonsterManual : function(json){
|
||||
dispatch('UDPATE_MONSTER_MANUAL', json);
|
||||
},
|
||||
addEncounter : function(){
|
||||
dispatch('ADD_ENCOUNTER');
|
||||
},
|
||||
updateEncounter : function(index, json){
|
||||
dispatch('UPDATE_ENCOUNTER', index, json);
|
||||
},
|
||||
removeEncounter : function(index){
|
||||
dispatch('REMOVE_ENCOUNTER', index);
|
||||
},
|
||||
updatePlayers : function(text){
|
||||
dispatch('UPDATE_PLAYERS', text);
|
||||
},
|
||||
selectEncounter : function(index){
|
||||
dispatch('SELECT_ENCOUNTER', index);
|
||||
},
|
||||
|
||||
}
|
||||
69
shared/naturalCrit/combat.store.js
Normal file
69
shared/naturalCrit/combat.store.js
Normal file
@@ -0,0 +1,69 @@
|
||||
var flux = require('pico-flux');
|
||||
var _ = require('lodash');
|
||||
|
||||
var defaultMonsterManual = require('naturalCrit/defaultMonsterManual.js');
|
||||
var GetRandomEncounter = require('naturalCrit/randomEncounter.js');
|
||||
|
||||
var Store = {
|
||||
selectedEncounterIndex : 0,
|
||||
encounters : JSON.parse(localStorage.getItem('encounters')) || [GetRandomEncounter()],
|
||||
monsterManual : JSON.parse(localStorage.getItem('monsterManual')) || defaultMonsterManual,
|
||||
players : localStorage.getItem('players') || 'jasper 13\nzatch 19',
|
||||
};
|
||||
|
||||
|
||||
module.exports = flux.createStore({
|
||||
UDPATE_MONSTER_MANUAL : function(json){
|
||||
Store.monsterManual = json;
|
||||
return true;
|
||||
},
|
||||
ADD_ENCOUNTER : function(){
|
||||
Store.encounters.push(GetRandomEncounter());
|
||||
return true;
|
||||
},
|
||||
UPDATE_ENCOUNTER : function(index, json){
|
||||
Store.encounters[index] = json;
|
||||
return true;
|
||||
},
|
||||
REMOVE_ENCOUNTER : function(index){
|
||||
Store.encounters.splice(index, 1);
|
||||
return true;
|
||||
},
|
||||
UPDATE_PLAYERS : function(text){
|
||||
Store.players = text;
|
||||
return true;
|
||||
},
|
||||
SELECT_ENCOUNTER : function(index){
|
||||
Store.selectedEncounterIndex = index;
|
||||
return true;
|
||||
},
|
||||
|
||||
},{
|
||||
getMonsterManual : function(){
|
||||
return Store.monsterManual;
|
||||
},
|
||||
getSelectedEncounterIndex : function(){
|
||||
return Store.selectedEncounterIndex;
|
||||
},
|
||||
getSelectedEncounter : function(){
|
||||
return Store.encounters[Store.selectedEncounterIndex];
|
||||
},
|
||||
getEncounter : function(index){
|
||||
return Store.encounters[index];
|
||||
},
|
||||
getEncounters : function(index){
|
||||
return Store.encounters;
|
||||
},
|
||||
getPlayersText : function(){
|
||||
return Store.players;
|
||||
},
|
||||
getPlayers : function(){
|
||||
return _.reduce(Store.players.split('\n'), function(r, line){
|
||||
var idx = line.lastIndexOf(' ');
|
||||
if(idx !== -1){
|
||||
r[line.substring(0, idx)] = line.substring(idx)*1;
|
||||
}
|
||||
return r;
|
||||
}, {})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user