Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {observable} from 'mobx';
import {identifier, reference, serializable} from 'serializr';
import {v4 as uuid} from 'uuid';
import {StaticState} from '../StaticState';
import {HeirloomType, ItemInfo, ItemType} from './ItemInfo';
import {IStatsSource, Stats} from './Stats';
import {cmp} from '../../lib/Helpers';
export type ItemId = string;
export class Item implements IStatsSource {
@serializable(identifier()) id: ItemId = uuid();
@serializable @observable level: number = 1;
@serializable(reference(ItemInfo, StaticState.lookup((i) => i.items)))
info: ItemInfo;
get name () { return this.info.name; }
statsSourceName: string = 'Item';
get statsScale () {
const maxItemLevel = StaticState.instance.getUpgradeEffects(['blacksmith']).level;
return 1 + ((this.level - 1) / maxItemLevel);
}
get stats () {
const scaledStats = new Stats();
scaledStats.add(this.info.stats);
scaledStats.scale(this.statsScale);
return scaledStats;
}
import {Experienced} from './Experienced';
import {identifier, reference, serializable} from 'serializr';
import {v4 as uuid} from 'uuid';
import {StaticState} from '../StaticState';
import {DungeonInfo} from './DungeonInfo';
export type DungeonId = string;
export class Dungeon extends Experienced {
@serializable(identifier()) id: DungeonId = uuid();
@serializable(reference(DungeonInfo, StaticState.lookup((i) => i.dungeons)))
info: DungeonInfo;
static fromInfo (info: DungeonInfo) {
const dungeon = new Dungeon();
dungeon.info = info;
return dungeon;
}
}
import {randomizeItem} from '../../lib/Helpers';
export type CharacterId = string;
export class Character extends Experienced {
@serializable(identifier()) id: CharacterId = uuid();
@serializable @observable name: string;
@serializable(reference(CharacterClassInfo, StaticState.lookup((i) => i.classes)))
classInfo: CharacterClassInfo;
@serializable(reference(QuirkInfo, StaticState.lookup((i) => i.quirks)))
affliction: QuirkInfo = null;
@serializable(list(reference(QuirkInfo, StaticState.lookup((i) => i.quirks))))
quirks: QuirkInfo[] = [];
@computed get perks () {
return Object.freeze(
this.quirks.filter((q) => !q.isDisease && q.isPositive)
);
}
@computed get flaws () {
return Object.freeze(
this.quirks.filter((q) => !q.isDisease && q.isNegative)
);
}
@computed get diseases () {
return Object.freeze(
@observable
graveyard: Hero[] = [];
@serializable(list(object(Quest)))
@observable
quests: Quest[] = [];
@serializable(list(object(Item)))
@observable
items: Item[] = [];
@serializable(list(object(Dungeon)))
@observable
allDungeons: Dungeon[] = [];
@serializable(list(reference(BuildingUpgradeInfo, StaticState.lookup((i) => i.buildingUpgrades))))
@observable
buildingUpgrades: BuildingUpgradeInfo[] = [];
@computed get selectableDungeons () {
return this.allDungeons.filter((d) => !d.info.isStartingDungeon);
}
@computed get startingDungeons () {
return this.allDungeons.filter((d) => d.info.isStartingDungeon);
}
get heirloomConversionRate () {
return 1.5;
}
@computed get heirloomCounts () {
import {BuildingInfoId} from './BuildingInfo';
import {Skill} from './Skill';
import {ItemType} from './ItemInfo';
import {randomizeItem} from '../../lib/Helpers';
export type CharacterId = string;
export class Character extends Experienced {
@serializable(identifier()) id: CharacterId = uuid();
@serializable @observable name: string;
@serializable(reference(CharacterClassInfo, StaticState.lookup((i) => i.classes)))
classInfo: CharacterClassInfo;
@serializable(reference(QuirkInfo, StaticState.lookup((i) => i.quirks)))
affliction: QuirkInfo = null;
@serializable(list(reference(QuirkInfo, StaticState.lookup((i) => i.quirks))))
quirks: QuirkInfo[] = [];
@computed get perks () {
return Object.freeze(
this.quirks.filter((q) => !q.isDisease && q.isPositive)
);
}
@computed get flaws () {
return Object.freeze(
this.quirks.filter((q) => !q.isDisease && q.isNegative)
);
}
import {Stats, TurnStats} from './Stats';
import {cap, contains, removeItem, without} from '../../lib/Helpers';
import {v4 as uuid} from 'uuid';
import {BuildingInfoId} from './BuildingInfo';
import {Skill} from './Skill';
import {ItemType} from './ItemInfo';
import {randomizeItem} from '../../lib/Helpers';
export type CharacterId = string;
export class Character extends Experienced {
@serializable(identifier()) id: CharacterId = uuid();
@serializable @observable name: string;
@serializable(reference(CharacterClassInfo, StaticState.lookup((i) => i.classes)))
classInfo: CharacterClassInfo;
@serializable(reference(QuirkInfo, StaticState.lookup((i) => i.quirks)))
affliction: QuirkInfo = null;
@serializable(list(reference(QuirkInfo, StaticState.lookup((i) => i.quirks))))
quirks: QuirkInfo[] = [];
@computed get perks () {
return Object.freeze(
this.quirks.filter((q) => !q.isDisease && q.isPositive)
);
}
@computed get flaws () {
return Object.freeze(