);
-}
+};
export default class Home extends React.Component {
state = { lore: []};
@@ -40,10 +40,9 @@ export default class Home extends React.Component {
})
.then((lore) => {
this.setState({ "lore": lore });
- return;
})
.catch(() => {
- this.setState({ "lore": [{ "block": "Unable to load lore...", "text": []}]})
+ this.setState({ "lore": [{ "block": "Unable to load lore...", "text": []}]});
});
}
@@ -62,7 +61,7 @@ export default class Home extends React.Component {
Do you like the site? You can donate to support it!
-
We were unsatisfied with the options on how to search for cards. I took the design of the old Chaotic website and added my own modernizations. With an extensive lists of search options in the collection, you'll find deck building mores streamlined than ever before. Chaotic is full of rich lore, but unfortunately the best database of official lore disapeared when the Portal to Perim disapeared along with the site. You can again explore the official lore and information of Creatures!
+
We were unsatisfied with the options on how to search for cards. I took the design of the old Chaotic website and added my own modernizations. With an extensive lists of search options in the collection, you'll find deck building mores streamlined than ever before. Chaotic is full of rich lore, but unfortunately the best database of official lore disapeared when the Portal to Perim disapeared along with the official site. You can again explore the official lore and information!
{this.state.lore.length > 0
diff --git a/src/components/mugicplayer/mugicparser.spec.ts b/src/components/mugicplayer/mugicparser.spec.ts
index 4e0c7de..a986acc 100644
--- a/src/components/mugicplayer/mugicparser.spec.ts
+++ b/src/components/mugicplayer/mugicparser.spec.ts
@@ -4,21 +4,21 @@ import { expect } from 'chai';
import { parseTune, output } from './mugicparser';
const cases = {
- "Canon of Casuality": {
- input: "2Eb 2F 2D 2G 2Bb 1A 3D",
- output: ["2Eb4", "2F4", "2D4", "2G4", "2Bb5", "1A5", "3D5"]
- },
- "Fortissimo": {
- input: "2G#4 1C#5 2E5 2C#5 2D#5 1G#4 4F#5",
- output: ["2G#4", "1C#5", "2E5", "2C#5", "2D#5", "1G#4", "4F#5"]
- }
-}
+ "Canon of Casuality": {
+ input: "2Eb 2F 2D 2G 2Bb 1A 3D",
+ output: ["2Eb4", "2F4", "2D4", "2G4", "2Bb5", "1A5", "3D5"]
+ },
+ "Fortissimo": {
+ input: "2G#4 1C#5 2E5 2C#5 2D#5 1G#4 4F#5",
+ output: ["2G#4", "1C#5", "2E5", "2C#5", "2D#5", "1G#4", "4F#5"]
+ }
+};
Object.entries(cases).forEach(([key, value]) => {
- describe(key, () => {
- it(`should return ${value.output}`, () => {
- const tune = output(parseTune(value.input));
- expect(tune).to.deep.equal(value.output);
- });
+ describe(key, () => {
+ it(`should return ${value.output}`, () => {
+ const tune = output(parseTune(value.input));
+ expect(tune).to.deep.equal(value.output);
});
+ });
});
diff --git a/src/components/mugicplayer/mugicparser.ts b/src/components/mugicplayer/mugicparser.ts
index af91537..339abb6 100644
--- a/src/components/mugicplayer/mugicparser.ts
+++ b/src/components/mugicplayer/mugicparser.ts
@@ -6,61 +6,61 @@ export class Note {
velocity: number;
constructor(duration: number, time: number, value: {pitch: string, octave: number}, velocity?: number) {
- this.duration = duration;
- this.time = time;
- this.pitch = value.pitch;
- this.octave = value.octave;
- if (velocity) this.velocity = velocity;
+ this.duration = duration;
+ this.time = time;
+ this.pitch = value.pitch;
+ this.octave = value.octave;
+ if (velocity) this.velocity = velocity;
}
}
export const output = (seq: Note[]) => {
- return seq.map(n => n.duration + n.pitch + n.octave.toString())
-}
+ return seq.map(n => n.duration + n.pitch + n.octave.toString());
+};
// db notation uses duration (quarter notes) and pitch
// 2Eb => E flat for 2 quarter notes
export const parseTune = (input: string): Note[] => {
- const seq: Note[] = [];
- let time = 0;
- console.log(input.split(" "));
- input.split(" ").forEach((note) => {
- const splitter = /(?:[1-8]{1})/;
+ const seq: Note[] = [];
+ let time = 0;
+ console.log(input.split(" "));
+ input.split(" ").forEach((note) => {
+ const splitter = /(?:[1-8]{1})/;
- const match = note.match(splitter);
- if (match === null) throw new Error("invalid_input");
+ const match = note.match(splitter);
+ if (match === null) throw new Error("invalid_input");
- const dur = parseInt(match[0]);
- const pitch = note.split(splitter)[1];
+ const dur = parseInt(match[0]);
+ const pitch = note.split(splitter)[1];
- const full_note = /[1-8]{1}[A-Za-z#]{1,2}([1-8]{1})/;
- if (full_note.test(note)) {
- const sp = note.match(full_note);
- if (sp === null) throw new Error("invalid_input");
- seq.push(new Note(dur, time, { pitch, octave: parseInt(sp[1]) }));
- }
- else {
- seq.push(new Note(dur, time, parseNote(pitch, seq)));
- }
+ const full_note = /[1-8]{1}[A-Za-z#]{1,2}([1-8]{1})/;
+ if (full_note.test(note)) {
+ const sp = note.match(full_note);
+ if (sp === null) throw new Error("invalid_input");
+ seq.push(new Note(dur, time, { pitch, octave: parseInt(sp[1]) }));
+ }
+ else {
+ seq.push(new Note(dur, time, parseNote(pitch, seq)));
+ }
- time += dur;
- });
+ time += dur;
+ });
- // If a note is repeated at the same octave, look at trend of last two notes
- // for (let i = 2; i < seq.length; i++) {
- // const note = seq[i];
- // const comp = seq[i-2];
- // if (note.pitch === comp.pitch && note.octave === comp.octave) {
- // const pitch = letter_to_number(note.pitch);
- // seq[i].octave = trend(pitch, i, seq);
- // }
- // }
+ // If a note is repeated at the same octave, look at trend of last two notes
+ // for (let i = 2; i < seq.length; i++) {
+ // const note = seq[i];
+ // const comp = seq[i-2];
+ // if (note.pitch === comp.pitch && note.octave === comp.octave) {
+ // const pitch = letter_to_number(note.pitch);
+ // seq[i].octave = trend(pitch, i, seq);
+ // }
+ // }
- console.log(output(seq));
+ console.log(output(seq));
- return seq;
-}
+ return seq;
+};
/*
We have an array of previous notes; for the first to cases the octave is middle (4).
@@ -74,63 +74,63 @@ export const parseTune = (input: string): Note[] => {
* @note The note's
*/
const parseNote = (pitch: string, seq: Note[]): {pitch: string, octave: number} => {
- let octave: number = (() => {
- // If its the first note its "middle octave"
- if (seq.length === 0) return 4;
+ let octave: number = (() => {
+ // If its the first note its "middle octave"
+ if (seq.length === 0) return 4;
- const l = seq.length - 1;
- const { octave } = seq[l];
+ const l = seq.length - 1;
+ const { octave } = seq[l];
- const current = pitchValue(pitch, octave);
- const previous = pitchValue(seq[l]);
- const distance = compare(previous, current);
+ const current = pitchValue(pitch, octave);
+ const previous = pitchValue(seq[l]);
+ const distance = compare(previous, current);
- // If its less than 3 pitches of the previous note, use the closest pitch
- if (distance < 3) {
- if (distance === 0) return octave;
+ // If its less than 3 pitches of the previous note, use the closest pitch
+ if (distance < 3) {
+ if (distance === 0) return octave;
- if (previous > pitchValue(5, octave)) {
- if (current < pitchValue(3, octave)) {
- return octave + 1;
- }
- else {
- return octave;
- }
- }
- else if (previous < pitchValue(3, octave)) {
- if (current > pitchValue(5, octave)) {
- return octave - 1;
- }
- else {
- return octave;
- }
- }
- return octave;
- } else if (l === 0) {
- if (distance === 3) {
- if (current > previous) {
- return octave;
- }
- else {
- return octave + 1;
- }
- }
- else if (current > previous) {
- return octave;
- }
- else if (current < previous) {
- return octave - 1;
- }
+ if (previous > pitchValue(5, octave)) {
+ if (current < pitchValue(3, octave)) {
+ return octave + 1;
}
+ else {
+ return octave;
+ }
+ }
+ else if (previous < pitchValue(3, octave)) {
+ if (current > pitchValue(5, octave)) {
+ return octave - 1;
+ }
+ else {
+ return octave;
+ }
+ }
+ return octave;
+ } else if (l === 0) {
+ if (distance === 3) {
+ if (current > previous) {
+ return octave;
+ }
+ else {
+ return octave + 1;
+ }
+ }
+ else if (current > previous) {
+ return octave;
+ }
+ else if (current < previous) {
+ return octave - 1;
+ }
+ }
- // If its further away, look at the previous notes for a trend
- return trend(current, l, seq);
- })();
+ // If its further away, look at the previous notes for a trend
+ return trend(current, l, seq);
+ })();
- if (octave > 5) octave = 5;
+ if (octave > 5) octave = 5;
- return { pitch, octave };
-}
+ return { pitch, octave };
+};
/*
* Is the last note a step down from the note before?
@@ -146,106 +146,106 @@ const parseNote = (pitch: string, seq: Note[]): {pitch: string, octave: number}
* @param l The index of the array to be compared
*/
const trend = (current: number, l: number, seq: Note[]): number => {
- if (l < 1) return seq[l].octave;
+ if (l < 1) return seq[l].octave;
- const prev = pitchValue(seq[l]);
- const prev2 = pitchValue(seq[l-1]);
- console.log(prev2, prev, current);
+ const prev = pitchValue(seq[l]);
+ const prev2 = pitchValue(seq[l-1]);
+ console.log(prev2, prev, current);
- // downward trend
- if (prev2 > prev) {
- if (prev < current) {
- return seq[l].octave;
- }
- return seq[l].octave - 1;
+ // downward trend
+ if (prev2 > prev) {
+ if (prev < current) {
+ return seq[l].octave;
}
- // upward trend
- else if (prev2 < prev) {
- if (prev < current) {
- return seq[l].octave;
- }
- return seq[l].octave + 1;
+ return seq[l].octave - 1;
+ }
+ // upward trend
+ else if (prev2 < prev) {
+ if (prev < current) {
+ return seq[l].octave;
}
- // same notes
- else {
- return trend(current, l-1, seq);
- }
-}
+ return seq[l].octave + 1;
+ }
+ // same notes
+ else {
+ return trend(current, l-1, seq);
+ }
+};
/**
* Takes two pitches and returns the distance between them
*/
const compare = (one: number, two: number): number => {
- const res = Math.abs(one - two);
- if (res < 4) {
- return res;
- }
- else if (res > 3.5) {
- return res - 1;
- }
- else if (res > 4.5) {
- return res - 2;
- }
- else if (res > 5.5) {
- return res - 3;
- }
- else if (res > 6.5) {
- return res - 4;
- }
-
+ const res = Math.abs(one - two);
+ if (res < 4) {
return res;
-}
+ }
+ else if (res > 3.5) {
+ return res - 1;
+ }
+ else if (res > 4.5) {
+ return res - 2;
+ }
+ else if (res > 5.5) {
+ return res - 3;
+ }
+ else if (res > 6.5) {
+ return res - 4;
+ }
+
+ return res;
+};
function pitchValue(note: Note): number;
function pitchValue(letter: number, octave: number): number;
function pitchValue(pitch: string, octave: number): number;
function pitchValue(arg1: number | string | Note, arg2?: number): number {
- let pitch: number;
- let octave: number;
- if (arg1 instanceof Note) {
- pitch = letter_to_number(arg1.pitch);
- octave = arg1.octave;
- } else {
- pitch = (typeof arg1 === 'number') ? arg1 : letter_to_number(arg1);
- octave = arg2 as number;
- }
- return pitch + (octave - 1) * 8;
+ let pitch: number;
+ let octave: number;
+ if (arg1 instanceof Note) {
+ pitch = letter_to_number(arg1.pitch);
+ octave = arg1.octave;
+ } else {
+ pitch = (typeof arg1 === 'number') ? arg1 : letter_to_number(arg1);
+ octave = arg2 as number;
+ }
+ return pitch + (octave - 1) * 8;
}
/**
* Converts a pitch to numerical value for calculations
*/
const letter_to_number = (pitch: string): number => {
- let num: number;
- switch (pitch.charAt(0).toUpperCase()) {
- case "A":
- num = 1;
- break;
- case "B":
- num = 2;
- break;
- case "C":
- num = 3;
- break;
- case "D":
- num = 4;
- break;
- case "E":
- num = 5;
- break;
- case "F":
- num = 6;
- break;
- case "G":
- num = 7;
- break;
- // In the case of incorrect input, coerce note to a C
- default:
- num = 3;
- }
- if (pitch.length > 1) {
- if (pitch.charAt(1).toLowerCase() === "b") num -= .5;
- else if (pitch.charAt(1) === "#") num += .5;
- }
- return num;
-}
+ let num: number;
+ switch (pitch.charAt(0).toUpperCase()) {
+ case "A":
+ num = 1;
+ break;
+ case "B":
+ num = 2;
+ break;
+ case "C":
+ num = 3;
+ break;
+ case "D":
+ num = 4;
+ break;
+ case "E":
+ num = 5;
+ break;
+ case "F":
+ num = 6;
+ break;
+ case "G":
+ num = 7;
+ break;
+ // In the case of incorrect input, coerce note to a C
+ default:
+ num = 3;
+ }
+ if (pitch.length > 1) {
+ if (pitch.charAt(1).toLowerCase() === "b") num -= .5;
+ else if (pitch.charAt(1) === "#") num += .5;
+ }
+ return num;
+};
diff --git a/src/components/mugicplayer/mugicplayer.ts b/src/components/mugicplayer/mugicplayer.ts
index d726573..bed8fcd 100644
--- a/src/components/mugicplayer/mugicplayer.ts
+++ b/src/components/mugicplayer/mugicplayer.ts
@@ -14,19 +14,19 @@ interface note_value {
}
class Note_Value extends Note {
- constructor(note: Note) {
- const { duration, time, pitch, octave, velocity } = note;
- super(duration, time, { pitch, octave }, velocity);
- }
+ constructor(note: Note) {
+ const { duration, time, pitch, octave, velocity } = note;
+ super(duration, time, { pitch, octave }, velocity);
+ }
- get value(): note_value {
- return {
- time: Time(this.time).quantize("4n") / 4,
- pitch: this.pitch + this.octave.toString(),
- duration: Time(this.duration).quantize("4n") / 4,
- velocity: this.velocity,
- }
- }
+ get value(): note_value {
+ return {
+ time: Time(this.time).quantize("4n") / 4,
+ pitch: this.pitch + this.octave.toString(),
+ duration: Time(this.duration).quantize("4n") / 4,
+ velocity: this.velocity,
+ };
+ }
}
export class MugicPlayer {
@@ -36,29 +36,29 @@ export class MugicPlayer {
// Singleton
static getInstance() {
- if (!MugicPlayer.instance) MugicPlayer.instance = new MugicPlayer();
- return MugicPlayer.instance;
+ if (!MugicPlayer.instance) MugicPlayer.instance = new MugicPlayer();
+ return MugicPlayer.instance;
}
constructor() {
- const options = {
- frequency: 440,
- oscillator: {
- type: "sine" as any
- },
- envelope: {
- attack: 0.40,
- decay: 0.10,
- release: 0.5,
- sustain: 1,
- attackCurve: "cosine" as EnvelopeCurve,
- releaseCurve: "exponential" as EnvelopeCurve,
- decayCurve: "exponential" as BasicEnvelopeCurve
- },
- pitchDecay: 0.05
- };
- this.synth = new Synth(options).toDestination();
- Transport.bpm.value = 140;
+ const options = {
+ frequency: 440,
+ oscillator: {
+ type: "sine" as any
+ },
+ envelope: {
+ attack: 0.40,
+ decay: 0.10,
+ release: 0.5,
+ sustain: 1,
+ attackCurve: "cosine" as EnvelopeCurve,
+ releaseCurve: "exponential" as EnvelopeCurve,
+ decayCurve: "exponential" as BasicEnvelopeCurve
+ },
+ pitchDecay: 0.05
+ };
+ this.synth = new Synth(options).toDestination();
+ Transport.bpm.value = 140;
}
/**
@@ -69,25 +69,25 @@ export class MugicPlayer {
// 2Eb 2F 2D 2G 2Bb 1A 3D
// up down up up down up
play(input: string) {
- Transport.stop();
- if (this.part) this.part.dispose();
+ Transport.stop();
+ if (this.part) this.part.dispose();
- try {
- const tune = parseTune(input).map(note => new Note_Value(note));
- this.part = new Part(
- (time, val) => {
- this.synth.triggerAttackRelease(val.pitch, val.duration, time, val.velocity);
- },
- tune.map((n) => n.value)
- ).start();
+ try {
+ const tune = parseTune(input).map(note => new Note_Value(note));
+ this.part = new Part(
+ (time, val) => {
+ this.synth.triggerAttackRelease(val.pitch, val.duration, time, val.velocity);
+ },
+ tune.map((n) => n.value)
+ ).start();
- Transport.start();
- }
- catch (error) {
- console.log(error);
- // TODO show user the error
- return;
- }
+ Transport.start();
+ }
+ catch (error) {
+ console.log(error);
+ // TODO show user the error
+ return;
+ }
}
diff --git a/src/components/mugicplayer/playbutton.tsx b/src/components/mugicplayer/playbutton.tsx
index 635f9df..d8d5900 100644
--- a/src/components/mugicplayer/playbutton.tsx
+++ b/src/components/mugicplayer/playbutton.tsx
@@ -4,8 +4,8 @@ import { MugicPlayer } from './mugicplayer';
const player = MugicPlayer.getInstance();
export default (props: any) => {
- const play = debounced(200, () => { player.play(props.notes); });
- return (
- { play() }} />
- );
+ const play = debounced(200, () => { player.play(props.notes) });
+ return (
+ { play() }} />
+ );
};
diff --git a/src/components/portal/Category.js b/src/components/portal/Category.js
index 6b06a15..011da5a 100644
--- a/src/components/portal/Category.js
+++ b/src/components/portal/Category.js
@@ -25,11 +25,14 @@ export default class Category extends React.Component {
API.LoadDB([{ 'cards': this.type }, { 'portal': this.type }])
.then(() => {
this.loaded = true;
- });
+ })
+ .catch(() => {});
return ();
}
- const create_link = (card, data, i, url) => {
+ const create_link = (card, i, url) => {
+ const data = API.cards[this.type].findOne({ 'gsx$name': card.gsx$name });
+
// Prevent site from crashing due to misspelled/missing data
if (!data) return ();
@@ -37,7 +40,7 @@ export default class Category extends React.Component {
+ >
{card.gsx$name.split(",")[0]}
@@ -49,7 +52,7 @@ export default class Category extends React.Component {
let top_content = ();
let bottom_nav = [];
- let path = this.props.location.pathname.split("/");
+ const path = this.props.location.pathname.split("/");
if (path[path.length-1] == "") path.pop(); // Remove trailing backslash
// ** Process the tribe ** //
@@ -87,13 +90,12 @@ export default class Category extends React.Component {
:
API.portal[this.type].chain().simplesort('gsx$name').data()
).map((card_portal, i) => {
- let card_data = API.cards[this.type].findOne({ 'gsx$name': card_portal.gsx$name });
- let url = ((tribe) ?
+ const url = ((tribe) ?
`/portal/${this.props.type}/${card_portal.gsx$tribe}/${encodeURIComponent(card_portal.gsx$name)}`
:
`/portal/${this.props.type}/${encodeURIComponent(card_portal.gsx$name)}`
);
- return create_link(card_portal, card_data, i, url);
+ return create_link(card_portal, i, url);
});
}
else {
@@ -107,8 +109,7 @@ export default class Category extends React.Component {
bottom_nav = API.portal[this.type].data
.sort((a, b) => (a.gsx$name > b.gsx$name) ? 1 : -1)
.map((card_portal, i) => {
- let card_data = API.cards[this.type].findOne({ 'gsx$name': card_portal.gsx$name });
- return create_link(card_portal, card_data, i);
+ return create_link(card_portal, i);
});
}
diff --git a/src/components/portal/Home.js b/src/components/portal/Home.js
index 326446f..e8904b0 100644
--- a/src/components/portal/Home.js
+++ b/src/components/portal/Home.js
@@ -17,28 +17,28 @@ export default class Home extends React.Component {
const ctx = canvas.getContext('2d');
- let Logo = new Image();
+ const Logo = new Image();
Logo.src = "/src/img/portal.png";
- let Creatures = (() => {
- let Chaor = new Image();
+ const Creatures = (() => {
+ const Chaor = new Image();
Chaor.src = API.base_image + "0B6oyUfwoM3u1LWtvNUZ2NVdjTGc";
- Chaor.onload = (() => { ctx.drawImage(Chaor, 50, 350); });
+ Chaor.onload = (() => { ctx.drawImage(Chaor, 50, 350) });
- let Iflar = new Image();
+ const Iflar = new Image();
Iflar.src = API.base_image + "0B6oyUfwoM3u1bFVIclZscHlHTVE";
- Iflar.onload = (() => { ctx.drawImage(Iflar, canvas.width - 300, 350); });
+ Iflar.onload = (() => { ctx.drawImage(Iflar, canvas.width - 300, 350) });
- let Illexia = new Image();
+ const Illexia = new Image();
Illexia.src = API.base_image + "0B6oyUfwoM3u1YzNhLUdSMHlmdFE";
- Illexia.onload = (() => { ctx.drawImage(Illexia, canvas.width - 350, Logo.height + 10); });
+ Illexia.onload = (() => { ctx.drawImage(Illexia, canvas.width - 350, Logo.height + 10) });
- let Maxxor = new Image();
+ const Maxxor = new Image();
Maxxor.src = API.base_image + "0B6oyUfwoM3u1MVVqQlpqYldsVDQ";
- Maxxor.onload = (() => { ctx.drawImage(Maxxor, 50, Logo.height + 10); });
+ Maxxor.onload = (() => { ctx.drawImage(Maxxor, 50, Logo.height + 10) });
});
- let background = new Image();
+ const background = new Image();
// background.src = API.base_image + "0B6oyUfwoM3u1VXZOdV9QUXlCclU"; // lighter
background.src = API.base_image + "1iu0GFaJQ0UsSN8yYWi77VY1cXsQpM4o7"; //darker
background.onload = (() => {
@@ -96,10 +96,10 @@ export default class Home extends React.Component {
};
that.render = function () {
- let s_width = that.width / w_frames;
- let s_height = that.height / h_frames;
- let c_width = canvas.width/2 - s_width/2;
- let c_height = canvas.height/2 - s_height/2;
+ const s_width = that.width / w_frames;
+ const s_height = that.height / h_frames;
+ const c_width = canvas.width/2 - s_width/2;
+ const c_height = canvas.height/2 - s_height/2;
// Clear the canvas
that.context.clearRect(c_width, c_height, s_width, s_height);
@@ -127,7 +127,7 @@ export default class Home extends React.Component {
this.coin.update();
this.coin.render();
}
- }
+ };
// Create sprite sheet
const coinImage = new Image();
diff --git a/src/components/portal/Search.js b/src/components/portal/Search.js
index cba789a..08c6485 100644
--- a/src/components/portal/Search.js
+++ b/src/components/portal/Search.js
@@ -20,13 +20,13 @@ export default class SearchPortal extends React.Component {
}
render() {
- return (
-
-
-
);
+ return (
+
+
+
);
}
search = (event) => {
@@ -55,58 +55,56 @@ class DBSearch extends React.Component {
]).then(() => {
this.loaded = true;
})
- .catch(() => {})
+ .catch(() => {});
return (Loading...);
}
- let { string } = this.props;
+ const { string } = this.props;
// No search
if (string == "") {
return ();
}
- const makeLink = (card, i) => {
- let link = "/portal";
- switch (card.gsx$type) {
- case "Attacks":
- link += '/Attacks/' + encodeURIComponent(card.gsx$name);
- break;
- case "Battlegear":
- link += '/Battlegear/' + encodeURIComponent(card.gsx$name);
- break;
- case "Creatures":
- link += '/Creatures/' + encodeURIComponent(card.gsx$name);
- break;
- case "Locations":
- link += '/Locations/' + encodeURIComponent(card.gsx$name);
- break;
- case "Mugic":
- link += '/Mugic/' + encodeURIComponent(card.gsx$name);
- break;
+ const text_link = (card, i) => {
+ let url;
+ if (["Attacks", "Battlegear", "Creatures", "Locations", "Mugic"].includes(card.gsx$type)) {
+ url = `/portal/${card.gsx$type}/${card.gsx$name}`;
}
+
+ if (!url) return ();
+
return (
- {card.gsx$name}
+ {card.gsx$name}
);
};
- const create_link = (card, data, i, url) => {
+ const thumb_link = (card, i) => {
+ let url;
+ let data;
+ if (["Attacks", "Battlegear", "Creatures", "Locations", "Mugic"].includes(card.gsx$type)) {
+ url = `/portal/${card.gsx$type}/${card.gsx$name}`;
+ data = API.cards[card.gsx$type.toLowerCase()].findOne({ 'gsx$name': card.gsx$name });
+ }
+
// Prevent site from crashing due to misspelled/missing data
- if (!data) return ();
+ if (!data || !url) return ();
+
+ const name = card.gsx$name.split(",")[0].replace(/\(Unused\)/, "");
return (
- {card.gsx$name.split(",")[0]}
-
+ >
+ {name}
+
);
};
- let filter = this.filter.addCollection('filter');
+ const filter = this.filter.addCollection('filter');
var pview = filter.addDynamicView('filter');
pview.applySimpleSort('gsx$name');
@@ -170,13 +168,13 @@ class DBSearch extends React.Component {
temp.forEach(function(v){ delete v.$loki });
filter.insert(temp);
- let content = pview.data().map(makeLink);
+ let content = pview.data().map(text_link);
this.filter.removeCollection('filter');
let header;
// This prioritizes names in the results
- let names = [].concat(
+ const names = [].concat(
API.portal.attacks.find({ 'gsx$name': { '$regex': new RegExp(string, 'i') }}),
API.portal.battlegear.find({ 'gsx$name': { '$regex': new RegExp(string, 'i') }}),
API.portal.creatures.find({ 'gsx$name': { '$regex': new RegExp(string, 'i') }}),
@@ -199,15 +197,16 @@ class DBSearch extends React.Component {
.find({ 'gsx$name': { '$regex': new RegExp(string, 'i') }})
.where((obj) => {return (obj.gsx$splash != ('') )}).data()
).sort((a, b) => {
- a = a.gsx$name.toLowerCase();
- b = b.gsx$name.toLowerCase();
- if (a < b) return -1;
- else if (a > b) return 1;
- else return 0;
- }).map(makeLink);
+ a = a.gsx$name.toLowerCase();
+ b = b.gsx$name.toLowerCase();
+ if (a < b) return -1;
+ else if (a > b) return 1;
+ else return 0;
+ }).map(thumb_link);
+ // Check Artists
if (content.length == 0) {
- let artists = [].concat(
+ const artists = [].concat(
API.cards.attacks.chain()
.find({ 'gsx$artist': { '$regex': new RegExp(string, 'i') }})
.where((obj) => {return (obj.gsx$splash != ('') )}).data(),
@@ -229,7 +228,7 @@ class DBSearch extends React.Component {
if (a < b) return -1;
else if (a > b) return 1;
else return 0;
- }).map(makeLink);
+ }).map(text_link);
if (artists.length > 0) {
header = `Art contributed by ${string}:`;
@@ -247,7 +246,7 @@ class DBSearch extends React.Component {
{names.length > 0 && <>
Entries
- {names}
+
{names}
>}
{header}
diff --git a/src/components/portal/Single/Attack.js b/src/components/portal/Single/Attack.js
index c44c5fe..f31be67 100644
--- a/src/components/portal/Single/Attack.js
+++ b/src/components/portal/Single/Attack.js
@@ -10,15 +10,15 @@ export default class SingleAttack extends React.Component {
render() {
- let path = this.props.location.pathname.split("/");
+ const path = this.props.location.pathname.split("/");
if (path[path.length-1] == "") path.pop(); // Remove trailing backslash
// Path too long
if ( path.length !== 4 ) {
- return();
+ return ();
}
- let name = decodeURIComponent(path[3]);
+ const name = decodeURIComponent(path[3]);
const attack = API.portal.attacks.findOne({ 'gsx$name': name });
const card_data = API.cards.attacks.findOne({ 'gsx$name': name });
@@ -42,7 +42,7 @@ export default class SingleAttack extends React.Component {
{attack.gsx$details}
>}
- />
+ />
);
}
else if (card_data) {
@@ -51,6 +51,6 @@ export default class SingleAttack extends React.Component {
}
}
- return();
+ return ();
}
}
diff --git a/src/components/portal/Single/Battlegear.js b/src/components/portal/Single/Battlegear.js
index bf0501f..e37ed65 100644
--- a/src/components/portal/Single/Battlegear.js
+++ b/src/components/portal/Single/Battlegear.js
@@ -10,19 +10,19 @@ export default class SingleBattlegear extends React.Component {
render() {
- let path = this.props.location.pathname.split("/");
+ const path = this.props.location.pathname.split("/");
if (path[path.length-1] == "") path.pop(); // Remove trailing backslash
// Path too long
if ( path.length !== 4 ) {
- return();
+ return ();
}
- let name = decodeURIComponent(path[3]);
+ const name = decodeURIComponent(path[3]);
const battlegear = API.portal.battlegear.findOne({ 'gsx$name': name });
const card_data = API.cards.battlegear.findOne({ 'gsx$name': name });
-
+
if (battlegear) {
return ();
+ return ();
}
}
diff --git a/src/components/portal/Single/Creature.js b/src/components/portal/Single/Creature.js
index 102a3e1..c497e1a 100644
--- a/src/components/portal/Single/Creature.js
+++ b/src/components/portal/Single/Creature.js
@@ -8,11 +8,11 @@ import Single from './_base';
import { PageNotFound, Element, Mugic, Discipline, Ability, Tribe } from '../../Snippets';
function Artist(props) {
- let artists = [];
+ const artists = [];
props.artist.split(/(?=, )/).forEach((artist, i) => {
artists.push({artist});
});
- return (
{artists}
)
+ return (
{artists}
);
}
@inject((stores, props, context) => props) @observer
@@ -24,7 +24,7 @@ export default class SingleCreature extends React.Component {
// The first / gets counted
render() {
- let path = this.props.location.pathname.split("/");
+ const path = this.props.location.pathname.split("/");
if (path[path.length-1] == "") path.pop(); // Remove trailing backslash
const name = (() => {
@@ -35,7 +35,7 @@ export default class SingleCreature extends React.Component {
const creature = API.portal.creatures.findOne({ 'gsx$name': name });
if (!creature) {
- return();
+ return ();
}
const tribe = creature.gsx$tribe;
@@ -50,12 +50,12 @@ export default class SingleCreature extends React.Component {
return
{item}
;
});
- let mugic = [];
+ const mugic = [];
for (let i = 0; i < card_data.gsx$mugicability; i++) {
mugic.push();
}
- // TODO readd creature to Portal Search after rewrite
+ // TODO readd creature to Portal Search after rewrite
return ();
+ return ();
}
- let name = decodeURIComponent(path[3]);
+ const name = decodeURIComponent(path[3]);
const location = API.portal.locations.findOne({ 'gsx$name': name });
const card_data = API.cards.locations.findOne({ 'gsx$name': name });
@@ -63,6 +63,6 @@ export default class SingleLocation extends React.Component {
}
}
- return();
+ return ();
}
}
diff --git a/src/components/portal/Single/Mugic.js b/src/components/portal/Single/Mugic.js
index 97e3f4d..2df99d3 100644
--- a/src/components/portal/Single/Mugic.js
+++ b/src/components/portal/Single/Mugic.js
@@ -14,7 +14,7 @@ export default class SingleMugic extends React.Component {
// The first / gets counted
render() {
- let path = this.props.location.pathname.split("/");
+ const path = this.props.location.pathname.split("/");
if (path[path.length-1] == "") path.pop(); // Remove trailing backslash
const name = (() => {
@@ -26,7 +26,7 @@ export default class SingleMugic extends React.Component {
const card_data = API.cards.mugic.findOne({ 'gsx$name': name });
const cost = () => {
- let cost = [];
+ const cost = [];
if (card_data.gsx$cost == 0) {
cost.push(0);
}
@@ -39,7 +39,7 @@ export default class SingleMugic extends React.Component {
}
}
return cost;
- }
+ };
if (mugic) {
return ();
+ return ();
}
}
diff --git a/src/components/portal/Single/_base.js b/src/components/portal/Single/_base.js
index fe6209c..a65c7d3 100644
--- a/src/components/portal/Single/_base.js
+++ b/src/components/portal/Single/_base.js
@@ -8,21 +8,21 @@ import s from '../../../styles/app.style';
// own "name" display function
function Name(props) {
- let name = props.name.split(",");
- return (<>
- {name[0]}
- { name.length > 1 &&
- {name[1].trim()}
- }
- >);
+ const name = props.name.split(",");
+ return (<>
+ {name[0]}
+ { name.length > 1 &&
+ {name[1].trim()}
+ }
+ >);
}
function Artist(props) {
- let artists = [];
- props.artist.split(/(?=, )/).forEach((artist, i) => {
- artists.push({artist});
- });
- return (