12345678910111213141516171819202122232425262728293031323334353637 |
- class CharacterOrigin {
- public id : string;
- public name : string;
- public description : string | Say;
- public bonusStats : string;
- public confirmPicked : (() => void) = () => {};
- public constructor (id : string) {
- this.id = id;
- CharacterOrigin.storeOrigin(this);
- }
- public static origins : {[id : string] : CharacterOrigin} = {};
- public static storeOrigin (origin : CharacterOrigin) {
- CharacterOrigin.origins[origin.id] = origin;
- }
- public static getOrigin (id : string) {
- return CharacterOrigin.origins[id];
- }
- public static getOrigins () : Array<CharacterOrigin> {
- let origins = [];
- for (let id in CharacterOrigin.origins) {
- origins.push(CharacterOrigin.origins[id]);
- }
- origins.sort((a : CharacterOrigin, b : CharacterOrigin) => {
- let na = a.name.toUpperCase();
- let nb = b.name.toUpperCase();
- if (na < nb) return -1;
- if (na > nb) return 1;
- return 0;
- });
- return origins;
- }
- }
|