Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {list, object, serializable} from 'serializr';
import {QuestRoom} from './QuestRoom';
import {Bounds} from '../../Bounds';
import {Dungeon} from './Dungeon';
import {Difficulty} from './Difficulty';
export class QuestMap {
@serializable(list(object(QuestRoom))) rooms: QuestRoom[];
@serializable(object(QuestRoom)) entrance: QuestRoom;
@serializable size: MapSize = MapSize.Short;
get bounds () {
return QuestMap.findBoundingBox(this.rooms);
}
static generate (dungeon: Dungeon, difficulty: Difficulty, size: MapSize) {
const memory = new Map();
const m = new QuestMap();
m.size = size;
m.entrance = QuestRoom.walk(
dungeon, memory, difficulty, size,
(room, coords) => !(coords.x === 0 && coords.y === 0) // No monsters in the entrance
);
m.rooms = Array.from(memory.values());
return m;
import {Vector} from './Vector';
import {identifier, list, object, serializable} from 'serializr';
import {v4 as uuid} from 'uuid';
import {Character} from './Character';
import {generateCurio, generateMonster} from '../Generators';
import {observable} from 'mobx';
import {count} from '../../lib/Helpers';
import {Curio} from './Curio';
import {Dungeon} from './Dungeon';
import {Difficulty} from './Difficulty';
export type MapLocationId = string;
export class QuestRoom {
@serializable(identifier()) id: MapLocationId = uuid();
@serializable(object(Vector)) coordinates: Vector;
@serializable roomImageIndex: number = 0;
// Mutable
@serializable(list(object(Character))) @observable monsters: Character[] = [];
@serializable @observable isScouted: boolean = false;
@serializable(list(object(Curio))) @observable curios: Curio[] = [];
isConnectedTo (other: QuestRoom) {
return this.coordinates.distance(other.coordinates) === 1;
}
static walk (
dungeon: Dungeon,
memory: Map = new Map(),
difficulty: Difficulty,
stepsLeft: number = 10,
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;
@serializable(list(object(Hero)))
@observable
coach: Hero[] = [];
function object(s) {
return s ? serializr_1.object(s) : _default();
}
function list(s) {
@observable
coach: Hero[] = [];
@serializable(list(object(Hero)))
@observable
roster: Hero[] = [];
@serializable(list(object(Hero)))
@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 () {
import {Character} from './Character';
import {object, serializable} from 'serializr';
import {observable, transaction} from 'mobx';
import {HeroResidentInfo} from './HeroResidentInfo';
import {BuildingInfoId} from './BuildingInfo';
import {cmp} from '../../lib/Helpers';
export class Hero extends Character {
@serializable @observable rosterIndex: number = 0;
@serializable @observable lineupIndex: number = -1;
@serializable @observable inLineup: boolean;
@serializable(object(HeroResidentInfo))
@observable
residentInfo: HeroResidentInfo = null;
changeName (newName: string) {
this.name = newName;
}
leaveLineup () {
this.inLineup = false;
this.lineupIndex = -1;
}
enterResidence (buildingId: BuildingInfoId, slotIndex: number) {
transaction(() => {
this.residentInfo = new HeroResidentInfo();
this.residentInfo.buildingId = buildingId;