Permalink
Browse files

Add lance data and parse lances when loading a Unit

  • Loading branch information...
markerikson committed Dec 30, 2017
1 parent 5485b10 commit 14cd310d006bd16467f2ff2a30128696cb0a28ee
Showing with 26 additions and 2 deletions.
  1. +23 −1 src/data/sampleData.js
  2. +3 −1 src/features/unitInfo/Unit.js
View
@@ -4,7 +4,29 @@ const sampleData = {
name : "Black Widow Company",
affiliation : "wd",
color : "black",
lances : [],
lances : [
{
id : 1,
name : "Command Lance",
pilots : [
1, 2, 3, 4
]
},
{
id : 2,
name : "Fire Lance",
pilots : [
5, 6, 7, 8
]
},
{
id : 3,
name : "Recon Lance",
pilots : [
9, 10, 11, 12
]
}
],
pilots : [
{
id : 1,
@@ -9,15 +9,17 @@ export default class Unit extends Model {
name : attr(),
affiliation : fk("Faction"),
color : attr(),
lances : many("Lance"),
pilots : many("Pilot"),
mechs : many("Mech")
};
static parse(unitData) {
const {Pilot, Mech} = this.session;
const {Pilot, Mech, Lance} = this.session;
const parsedData = {
...unitData,
lances : unitData.lances.map(lanceEntry => Lance.parse(lanceEntry)),
pilots : unitData.pilots.map(pilotEntry => Pilot.parse(pilotEntry)),
mechs : unitData.mechs.map(mechEntry => Mech.parse(mechEntry)),
};

0 comments on commit 14cd310

Please sign in to comment.