Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {v4 as uuid} from 'uuid';
import {QuestMap} from './QuestMap';
import {QuestObjective} from './QuestObjective';
import {Item} from './Item';
import {autorun, computed, intercept, observable, reaction, when} from 'mobx';
import {QuestInfo} from './QuestInfo';
import {DungeonId} from './Dungeon';
import {MapLocationId} from './QuestRoom';
import {cap, moveItem, removeItem} from '../../lib/Helpers';
import {Hero} from './Hero';
import {Battler} from './Battler';
export type QuestId = string;
export class Quest extends Battler {
@serializable(identifier()) id: QuestId = uuid();
@serializable bonfires: number = 0;
@serializable dungeonId: DungeonId;
@serializable isEscapable?: boolean = true;
@serializable(object(QuestMap))
map: QuestMap;
@serializable(object(QuestObjective))
objective: QuestObjective = new QuestObjective();
@serializable(list(object(Item)))
rewards: Item[] = [];
@serializable(list(object(Hero)))
@observable
party: Hero[] = [];
import {HeirloomType} from './ItemInfo';
import {BuildingInfoId} from './BuildingInfo';
import {Stats} from './Stats';
import {HeroResidentInfo} from './HeroResidentInfo';
import {Skill} from './Skill';
import {MapSize} from './QuestMap';
import {Difficulty} from './Difficulty';
import {v4 as uuid} from 'uuid';
export type ProfileId = string;
const nullEstateEvent = new EstateEvent();
nullEstateEvent.shown = true;
export class Profile {
@serializable(identifier()) id: ProfileId = uuid();
@serializable difficulty: Difficulty;
@serializable @observable isNameFinalized: boolean = false;
@serializable @observable name: string = '';
@serializable(object(Path)) @observable path: Path;
@serializable @observable week: number = 0;
@serializable(date()) @observable dateOfLastSave: Date = new Date();
@serializable @observable selectedQuestId?: QuestId;
@serializable @observable gold: number = 0;
@observable debt: number = 0;
@computed get goldAfterDebt () { return this.gold - this.debt; }
@serializable(object(EstateEvent))
@observable
estateEvent = nullEstateEvent;
import {BuildingUpgradeEffects} from './BuildingUpgradeEffects';
import {identifier, serializable} from 'serializr';
import {HeirloomType} from './ItemInfo';
import {createId} from './BuildingInfo';
export class BuildingUpgradeInfo {
@serializable(identifier()) id: string;
cost = new Map();
effects = new BuildingUpgradeEffects();
get isFree () {
let sum = 0;
this.cost.forEach((amount, type) => sum += amount);
return sum === 0;
}
get description () {
const effectStrings = [];
for (const key in this.effects) {
const val = (this.effects as any)[key];
if (val !== 0) {
const sign = val > 0 ? '+' : '-';
return new SkillTarget(spots, object);
}
static anyOne (type: SkillTargetObject) {
return SkillTarget.oneOf([true, true, true, true], type);
}
static backline = [true, true, false, false];
static frontline = [false, false, true, true];
static midline = [false, true, true, false];
}
export type SkillId = string;
export class SkillInfo implements IStatsSource {
@serializable(identifier()) id: SkillId;
name: string;
iconUrl: string;
statsSourceName: string = 'Skill';
stats: Stats = new Stats();
position: [boolean, boolean, boolean, boolean] = [true, true, true, true];
damageScale: number = 1;
movement: number = 0;
statusTurns: number = 3;
target: SkillTarget;
buff: TurnStats;
canUse (actor: Character, allies: Character[], enemies: Character[]) {
allies = forceLength(allies, 4);
enemies = forceLength(enemies, 4);
const actorPosition = allies.indexOf(actor);
identifier: function identifier$$1() {
return identifier();
},
field: function field() {
import {identifier, serializable} from 'serializr';
export class StatInfo {
@serializable(identifier()) id: string;
constructor (
public shortName: string,
public longName: string = shortName,
public isPercentage: boolean = false
) {
this.id = shortName;
}
public static lookup = new Map();
static declare (shortName: string, longName: string, isPercentage?: boolean) {
const id = shortName;
let info = StatInfo.lookup.get(id);
if (info) {
return info;
Armor = 'A',
Trinket = 'T',
Treasure = 'TR',
Consumable = 'C',
Heirloom = 'H'
}
export enum HeirloomType {
Bust,
Portrait,
Deed,
Crest
}
export class ItemInfo {
@serializable(identifier()) id: string;
name: string = '[single name]';
pluralName: string = '[plural name]';
iconUrl?: string;
itemUrl?: string;
description: string = '';
type: ItemType = ItemType.Consumable;
heirloomType?: HeirloomType;
value: number = 0;
sellValueScale: number = 1;
stats: Stats = new Stats();
resetHunger: boolean;
removeBuffs: boolean;
offsetLight: number = 0;
buff?: TurnStats;
getStoreCount?: (q: Quest) => number;
import {identifier, list, object, serializable} from 'serializr';
import {v4 as uuid} from 'uuid';
import {Item} from './Item';
import {TurnStats} from './Stats';
import {observable} from 'mobx';
export type CurioId = string;
export class Curio {
@serializable(identifier()) id: CurioId = uuid();
@serializable name: string = '';
@serializable(object(TurnStats)) buff: TurnStats = null;
@serializable(list(object(Item))) @observable items: Item[] = [];
@serializable @observable hasBeenInteractedWith: boolean = false;
@serializable replaceQuirk: boolean;
}
import {identifier, serializable} from 'serializr';
export class LevelInfo {
@serializable(identifier()) id: number;
name: string;
number: number;
experience: number;
constructor (
public previous?: LevelInfo,
public next?: LevelInfo
) {}
get isMax () {
return !this.next;
}
get relativeExperience () {
const from = this.previous ? this.previous.experience : 0;
return this.experience - from;
import {identifier, serializable} from 'serializr';
import {IStatsSource, Stats} from './Stats';
import {BuildingInfoId} from './BuildingInfo';
export type QuirkId = string;
export class QuirkInfo implements IStatsSource {
@serializable(identifier()) id: QuirkId;
public name: string;
public treatmentCostScale = 1.5;
public stats: Stats = new Stats();
public forcedTreatmentIds: BuildingInfoId[] = [];
public bannedTreatmentIds: BuildingInfoId[] = [];
public isDisease: boolean;
public isAffliction: boolean;
statsSourceName: string = 'Quirk';
get isForcedOrBanned () {
return this.forcedTreatmentIds.length > 0 || this.bannedTreatmentIds.length > 0;
}
get isPositive () {
return !this.isForcedOrBanned && this.stats.isPositive;
}