diff --git a/src/components/CollectionDB.js b/src/components/CollectionDB.js index 8ab24be..3924237 100644 --- a/src/components/CollectionDB.js +++ b/src/components/CollectionDB.js @@ -80,7 +80,11 @@ export default class CollectionDB { } - setupMugic(tribe) { - + // Portal or Cards + setupMugic(tribe="Generic") { + this.setup(this.api.urls.Mugic[tribe], (data) => { + this.mugic.insert(data); + this.built.push("mugic_"+tribe); + }); } } diff --git a/src/components/portal/Category/Creatures.js b/src/components/portal/Category/Creatures.js index 3ef7c7d..379a2f5 100644 --- a/src/components/portal/Category/Creatures.js +++ b/src/components/portal/Category/Creatures.js @@ -4,7 +4,6 @@ import { Link } from 'react-router'; import PageNotFound from '../../PageNotFound'; import API from '../../SpreadsheetData'; import s from '../../../styles/app.style'; -import UnderConstruction from '../../UnderConstruction'; import {observer, inject} from 'mobx-react'; @inject((stores, props, context) => props) @observer @@ -45,12 +44,12 @@ export default class Creatures extends React.Component { >Danian
Overworld + to="/portal/Creatures/OverWorld" + >OverWorld
Underworld + to="/portal/Creatures/UnderWorld" + >UnderWorld
props) @observer export default class Mugic extends React.Component { render() { if (this.props.children) { return (
{this.props.children}
); } - return ( - - ); + const store = API; + + let path = this.props.location.pathname.split("/"); + if (path[path.length-1] == "") path.pop(); // Remove trailing backslash + + let tribe = (() => { + if (path.length !== 4) return "None"; + if (path[2] === "Mugic") return path[3]; + if (path[3] === "Mugic") return path[2]; + })(); + + if (store.urls === null || + store.portal === null || + store.cards === null) { + return (Loading...); + } + + // If there isn't a supported tribe, + // Displays list of tribes + if (!store.urls.Mugic.hasOwnProperty(tribe)) { + return( +
+ Generic +
+ Danian +
+ OverWorld +
+ UnderWorld +
+ Mipedian +
+ ); + } + + if (!store.cards.built.includes("mugic_Cards")) { + store.cards.setupMugic("Cards"); + return (Loading...); + } + + if (!store.portal.built.includes("mugic_"+tribe)) { + store.portal.setupMugic(tribe); + return (Loading...); + } + + const mugic = store.portal.mugic.find({'gsx$tribe': tribe}); + const output = mugic.map((single_mugic, i) => { + const card_data = store.cards.mugic.findOne({'gsx$name': single_mugic.gsx$name}); + return ( +
+ + {single_mugic.gsx$name}
+ {/* TODO */} +
+
+ ); + }); + + return (
{output}
); } fakerender() { diff --git a/src/components/portal/Home.js b/src/components/portal/Home.js index 1f093ca..642bb13 100644 --- a/src/components/portal/Home.js +++ b/src/components/portal/Home.js @@ -10,6 +10,9 @@ export default function PortalHome() { to="/portal/Creatures" >Creatures

+ Mugic ); } diff --git a/src/components/portal/Single/Mugic.js b/src/components/portal/Single/Mugic.js index e69de29..430bb60 100644 --- a/src/components/portal/Single/Mugic.js +++ b/src/components/portal/Single/Mugic.js @@ -0,0 +1,18 @@ +import React from 'react'; +import Interactive from 'react-interactive'; +import { Link } from 'react-router'; +import PageNotFound from '../../PageNotFound'; +import API from '../../SpreadsheetData'; +import s from '../../../styles/app.style'; +import {observer, inject} from 'mobx-react'; +import UnderConstruction from '../../UnderConstruction'; + +@inject((stores, props, context) => props) @observer +export default class SingleCreature extends React.Component { + + render() { + return ( + + ); + } +} diff --git a/src/index.js b/src/index.js index 34e87fd..9415fc5 100644 --- a/src/index.js +++ b/src/index.js @@ -20,16 +20,17 @@ import CollectionHome from './components/collection/Home'; /* Portal */ import PortalHome from './components/portal/Home'; // import Attacks from './components/portal/Category/Attacks'; -// import Battlegear from './components/portal/Category/Battlegear'; -import Creatures from './components/portal/Category/Creatures'; -// import Locations from './components/portal/Category/Locations'; -import Mugic from './components/portal/Category/Mugic'; -import Tribes from './components/portal/Category/Tribes'; // import SingleAttack from './components/portal/Category/Attacks'; +// import Battlegear from './components/portal/Category/Battlegear'; // import SingleBattlegear from './components/portal/Category/Battlegear'; +import Creatures from './components/portal/Category/Creatures'; import SingleCreature from './components/portal/Single/Creature'; +// import Locations from './components/portal/Category/Locations'; // import SingleLocation from './components/portal/Category/Locations'; -// import SingleMugic from './components/portal/Category/Mugic'; +import Mugic from './components/portal/Category/Mugic'; +import SingleMugic from './components/portal/Single/Mugic'; +import Tribes from './components/portal/Category/Tribes'; + const routes = ( @@ -55,111 +56,111 @@ const routes = ( {/* Attacks */} - + {/* Battlegear */} - + {/* Locations */} - + {/* Creatures */} - - + + - + - + - + {/* Mugic */} - - - + + + - - + + - - + + - - + + - + + + + + + {/* OverWorld */} + + + + + - {/* Overworld */} - - + {/* UnderWorld */} + + - - - - - - {/* Underworld */} - - - - - + {/* Mipedian */} - - + + - + {/* Danian */} - - + + - + {/* M'arrillian */} - - + + - + {/* Generic */} - - + + - + @@ -171,6 +172,11 @@ const routes = ( ); +function mapMenuTitle(location, depth=1) { + let path = location.pathname.split("/"); + if (path[path.length-1] == "") path.pop(); // Remove trailing backslash + return path[depth]; +} render(