Kaynağa Gözat

Something I'm too lazy to check right now

Reddo 5 yıl önce
ebeveyn
işleme
c21c0bb201

+ 1 - 1
app/World/Classes/RandomDungeons/RegionRandom.ts

@@ -105,7 +105,7 @@ class RegionRandom extends Region {
         code : runner => {
             let region = <RegionRandom> runner.noun;
             let placedRooms = Region.InRelation.getAllRightTypes(region, RoomRandom).filter((room : RoomRandom) => {
-                return room.randomizable && room.placed;
+                return room.placed;
             });
 
             placedRooms.forEach((room : RoomRandom) => {

+ 22 - 1
app/World/Classes/RandomDungeons/RoomRandom.ts

@@ -23,7 +23,7 @@ class RoomRandom extends Room {
     public randomizable = true; // non-randomizable rooms don't get placed automatically
     public placed = false;
     public appearChance = 75;
-    public extraConnectionChance = 75;
+    public extraConnectionChance = 15;
     public backgroundImage = "tomato";
 
     public lastMap : RoomRandomMap;
@@ -50,6 +50,7 @@ class RoomRandom extends Room {
                     }
                 }
             }
+            console.warn("Room background " + this.backgroundImage + " not found.");
             return false;
         } catch (e) {
             console.warn("Unable to read image");
@@ -121,6 +122,26 @@ class RoomRandom extends Room {
         }
     }
 
+    /**
+     * Returns the closest direction we have in North, South, etc.
+     * @param coordinates
+     */
+    public getOverallDirectionTo (coordinates) {
+        let myCoordinates = this.lastMap.getCoordinates(this);
+        let dy = (coordinates[1] - myCoordinates[1]);
+        let dx = (coordinates[0] - myCoordinates[0]);
+        let theta = Math.atan2(dy, dx); // range (-PI, PI]
+        theta *= 180 / Math.PI; // rads to degs, range (-180, 180];
+        theta = Math.round(theta / 45);
+        if (theta < 0) {
+            theta = 8 + theta;
+        }
+
+        let directions = [Direction.EAST, Direction.NORTHEAST, Direction.NORTH, Direction.NORTHWEST, Direction.WEST, Direction.SOUTHWEST, Direction.SOUTH, Direction.SOUTHEAST];
+        return directions[theta];
+        //if (theta < 0) theta = 360 + theta; // range [0, 360)
+    }
+
     /**
      * This implementation is sufficiently fast for constant use.
      * @param pathEnd

+ 55 - 0
app/World/Classes/Reputation.ts

@@ -0,0 +1,55 @@
+enum Reputations {
+    HATED,      // Pretty much Kill-on-sight
+    NEUTRAL,    // Doesn't care much
+    ACCEPTED,   // The player has done something that they liked
+    ADORED,     // The player is a hero to them
+    SLUT2,      // The player is known for being a slut among them
+    SLUT1,      // The player is known for being a little slutty among them
+    PRUDE1,     // The player is known for rejecting sexual advances often
+    PRUDE2,     // The player is expected to reject all sexual advances
+}
+
+/**
+ * Never never use this in a permanent manne. Reputation must be generated and discarded after use.
+ */
+class Reputation {
+    private values : Array<Reputations> = [Reputations.NEUTRAL, undefined];
+
+    constructor (...values : Array<Reputations>) {
+        for (let i = 0; i < values.length; i++) {
+            this.add(values[i]);
+        }
+    }
+
+    public add (value : Reputations) {
+        let mutual1 = [Reputations.HATED, Reputations.NEUTRAL, Reputations.ACCEPTED, Reputations.ADORED];
+        let mutual2 = [Reputations.SLUT1, Reputations.SLUT2, Reputations.PRUDE1, Reputations.PRUDE2];
+        if (mutual2.includes(value)) {
+            this.values[1] = value;
+        } else if (mutual1.includes(value)) {
+            this.values[0] = value;
+        }
+        return this;
+    }
+
+    public contains (...values : Array<Reputations>) {
+        for (let i = 0; i < values.length; i++) {
+            if (!this.values.includes(values[i])) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public is (value : Reputations) {
+        return this.values.includes(value);
+    }
+
+    public isPrude () {
+        return this.values.includes(Reputations.PRUDE1) || this.values.includes(Reputations.PRUDE2);
+    }
+
+    public isSlut () {
+        return this.values.includes(Reputations.SLUT1) || this.values.includes(Reputations.SLUT2);
+    }
+}