12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- /// <reference path="RoomRandom.ts" />
- /**
- * Fodder is exactly the same as a random room, except:
- * 1 - It must be created as needed by a RegionRandom as it attempts to place Tricky rooms.
- * 2 - It doesn't count towards a player's maximum remembered rooms
- */
- enum RandomLootType {
- DROPPED_ITEM,
- CHEST
- }
- interface FodderPossibility {
- name : string;
- description : Say | string;
- objects? : Array<Thing>; // Always has these objects
- randomLootChance? : number; // 0 to 100, chance of having loot on top of the objects
- randomLootType? : RandomLootType; // if randomLootChance succeeds, this will be the type of loot in the room
- chestType? : Array<Thing | typeof Thing>; // if randomLootType is chest, chest will be generated using this
- maxLootRarity? : number;
- minLootRarity? : number; // Level of the random loot generated, from 1 to 10
- }
- class RoomRandomFodder extends RoomRandom {
- public constructor (id? : string) {
- super(id, true);
- }
- public cloneInterface (pos : FodderPossibility) {
- this.name = pos.name;
- this.description = typeof pos.description == "string" ? new Say(pos.description) : pos.description;
- if (pos.objects != undefined) {
- for (let i = 0; i < pos.objects.length; i++) {
- let object = pos.objects[i];
- if (object instanceof Thing) {
- this.place(object);
- } else if (object == Thing || (<any>object).prototype instanceof Thing) {
- this.place(new (<any>object)());
- } else if (typeof object == "function") {
- object = (<Function> object)();
- if (object instanceof Thing) {
- this.place(object);
- }
- }
- }
- }
- if (pos.randomLootChance != undefined && (Math.random() * 100) <= pos.randomLootChance) {
- // TODO: Add the loot.
- }
- }
- }
|