11 Commits b0714751cc ... 783cd43d0b

Autor SHA1 Mensagem Data
  Reddo 783cd43d0b Remove left window 5 anos atrás
  Reddo d49b2c5261 30 levels? I think this code is broken, because it's failing when it shouldn't. THe inform code didn't fail. Maybe I should rewrite it without the optimizations, since they're not needed here anyway. 5 anos atrás
  Reddo 5fd918f636 Smaller links 5 anos atrás
  Reddo c21c0bb201 Something I'm too lazy to check right now 5 anos atrás
  Reddo 1cbf39121b remove debug 5 anos atrás
  Reddo 5617ba8f8c For some reason still not triggering on 100% chance all the time, no idea why 5 anos atrás
  Reddo ab3ba0e9d7 More flexibility 5 anos atrás
  Reddo 0b55ae58cf More utility 5 anos atrás
  Reddo b445603ad6 oopsie 5 anos atrás
  Reddo 367aace317 Can't clear that too often or it can't be used inside dialogues themselves... 5 anos atrás
  Reddo 3de6691577 Dialogues can return values!!!!!! Is there anything they can't do? 5 anos atrás

+ 24 - 19
The Obelisk.haml

@@ -48,9 +48,6 @@
           #sceneAnimation
           #leftWindow
             .topBottomFlex
-              #appearanceTab.noshrinkFlex.scrollbar
-                %p.appearanceHeader="Appearance:"
-                #appearanceTarget
               .growingFlex
               #inventoryTab.noshrinkFlex.scrollbar
                 -#inventoryTab.noshrinkFlex
@@ -63,29 +60,37 @@
                   #forceTurnToBottom.growingFlex
                   #currentTurnTab.noshrinkFlex
                   #forceTurnToTop.growingFlex
-              #currentRoomTab.noshrinkFlex
-                %p.roomName#roomName
-                #roomDescription
-              #hyperlinksTab.noshrinkFlex
-                #commonActionsTab
-                #linkTarget
-                #linkActions
-              #fakeparserTab.noshrinkFlex
-                %a#currentCommand>
-                %a#fakeParserThingy="_"
+              #bottomNoTurn.noshrinkFlex
+                .leftRightFlex
+                  .growingFlex
+                    #leftBottom.topBottomFlex
+                      #currentRoomTab.noshrinkFlex
+                        %p.roomName#roomName
+                        #roomDescription
+                      #hyperlinksTab.noshrinkFlex
+                        #commonActionsTab
+                        #linkTarget
+                        #linkActions
+                      #fakeparserTab.noshrinkFlex
+                        %a#currentCommand>
+                        %a#fakeParserThingy="_"
+                  #roomExitsHolder
+                    %p.roomExitsHeader="Exits:"
+                    #roomExits
           #rightWindow
             .topBottomFlex
-              #mapTab.growingFlex.scrollbar
+              .growingFlex
+              #mapTab.noshrinkFlex.scrollbar
                 #mapTarget
-              #roomExitsHolder
-                %p.roomExitsHeader="Exits:"
-                #roomExits
+              #appearanceTab.noshrinkFlex.scrollbar
+                %p.appearanceHeader="Appearance:"
+                #appearanceTarget
     -###########
     -# Relative File for Debugging
-    -#%script{:type => "text/javascript", :charset=>"utf8", :src => "../js/Application.js"}
+    %script{:type => "text/javascript", :charset=>"utf8", :src => "../js/Application.js"}
     -###########
     -# Optimized No Debug Data URL
-    = "<script id=\"ApplicationJS\" type=\"text/javascript\", charset=\"utf8\", src=\"data:application/javascript," + (URI.encode("(function(){\n" + (File.read "js/Application.js").encode!('UTF-8', 'UTF-8', :invalid => :replace).gsub("console.debug(", "//")) + "\n})()") + "\"></script>";
+    -#= "<script id=\"ApplicationJS\" type=\"text/javascript\", charset=\"utf8\", src=\"data:application/javascript," + (URI.encode("(function(){\n" + (File.read "js/Application.js").encode!('UTF-8', 'UTF-8', :invalid => :replace).gsub("console.debug(", "//")) + "\n})()") + "\"></script>";
     -###########
     %style{:media=>"screen", :type=>"text/css"}
       = File.read "stylesheets/fonts.css"

+ 1 - 1
app/Elements/Modules/RoomHandler.ts

@@ -75,7 +75,7 @@ module Elements.RoomHandler {
                     p.appendChild(link);
 
                     let directionResult = ": ";
-                    if (WorldState.isRoomRemembered(value)) {
+                    if (value.visited || await WorldState.isRoomRemembered(value)) {
                         directionResult += value.getPrintedName();
                     } else {
                         directionResult += "A new place";

+ 2 - 1
app/World/Classes/Action/ActionInventory.ts

@@ -25,6 +25,7 @@ class ActionInventory extends Action {
     public static async createButton (thing : Thing, resolve : (t : Thing) => void) {
         let p = document.createElement("p");
         p.classList.add("choice");
+        p.classList.add("small");
         let elements = await ((new Say(thing)).getPureElements());
         elements.forEach(ele => {
             p.appendChild(ele);
@@ -52,7 +53,7 @@ class ActionInventory extends Action {
                 Controls.KeyHandler.reset();
                 let say = new Say();
                 if (wielded.length > 0) {
-                    say.add(new SayBold("Wielded:"), Say.LINE_BREAK);
+                    say.add(new SayBold("Wielded:"), Say.PARAGRAPH_BREAK);
                     for (let i = 0; i < wielded.length; i++) {
                         say.add(await ActionInventory.createButton(wielded[i], resolve));
                     }

+ 4 - 0
app/World/Classes/Dialogue/DialogueTree.ts

@@ -7,6 +7,8 @@ class DialogueTree {
     private lastPrintedChoice : Array<HTMLElement>;
     private executedCount : StoredVariable<number>;
 
+    public static ReturnValue : any = undefined; // Use this to mimic a return value if using a dialogue tree to find a value.
+
     public constructor (id : string) {
         this.id = id;
         this.executedCount = new StoredVariable({id: "DialogueTree " + id, value : 0});
@@ -56,6 +58,7 @@ class DialogueTree {
         console.debug(Rulebook.getIndentation() + "[DialogueTree] Running " + this.id);
         Rulebook.increaseIndentation(this);
 
+        DialogueTree.ReturnValue = undefined;
         let node : DialogueNode;
         if (startId == undefined) {
             node = this.startNode;
@@ -74,6 +77,7 @@ class DialogueTree {
             node = nextNode;
         }
         Rulebook.decreaseIndentation();
+        return (DialogueTree.ReturnValue);
     }
 
     public async processNode (node : DialogueNode, previousNode : DialogueNode) {

+ 24 - 5
app/World/Classes/RandomDungeons/RegionRandom.ts

@@ -105,23 +105,42 @@ 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) => {
                 let myCoordinates = region.map.getCoordinates(room);
                 let directionShuffler = new Shuffler<number>(room.connectableOn.slice(0), RegionRandom.rng);
-                for (let direction = directionShuffler.getOne(); direction != undefined && (RegionRandom.rng() * 100) <= room.extraConnectionChance; direction = directionShuffler.getOne()) {
+                // use greater connection chance
+                for (let direction = directionShuffler.getOne(); direction != undefined; direction = directionShuffler.getOne()) {
+                    let chance1 = room.extraConnectionChance;
                     if (room.connections[direction] == undefined) {
                         let otherCoordinates = Room.shift(myCoordinates, direction);
                         let otherRoom = region.map.getRoom(otherCoordinates[0], otherCoordinates[1]);
                         if (otherRoom != undefined && otherRoom.randomizable
                             && otherRoom.isConnectableOn(OppositeDirection[Direction[direction]])
-                            && (RegionRandom.rng() * 100) <= otherRoom.extraConnectionChance) {
-                            room.mapRoom(otherRoom, direction);
+                        ) {
+                            let chance2 = otherRoom.extraConnectionChance;
+                            let chance = (chance1 == 0 || chance2 == 0) ? 0 : Math.max(chance1, chance2);
+                            if ((RegionRandom.rng() * 100) <= chance) {
+                                room.mapRoom(otherRoom, direction);
+                            }
                         }
                     }
                 }
+
+
+                // for (let direction = directionShuffler.getOne(); direction != undefined && (RegionRandom.rng() * 100) <= room.extraConnectionChance; direction = directionShuffler.getOne()) {
+                //     if (room.connections[direction] == undefined) {
+                //         let otherCoordinates = Room.shift(myCoordinates, direction);
+                //         let otherRoom = region.map.getRoom(otherCoordinates[0], otherCoordinates[1]);
+                //         if (otherRoom != undefined && otherRoom.randomizable
+                //             && otherRoom.isConnectableOn(OppositeDirection[Direction[direction]])
+                //             && (RegionRandom.rng() * 100) <= otherRoom.extraConnectionChance) {
+                //             room.mapRoom(otherRoom, direction);
+                //         }
+                //     }
+                // }
             });
         }
     });
@@ -248,7 +267,7 @@ class RegionRandom extends Region {
                 }
             };
 
-            for (let fodderLevel = 1; fodderLevel < 40; fodderLevel++) {
+            for (let fodderLevel = 1; fodderLevel < 30; fodderLevel++) {
                 roomShuffler.restart();
                 for (let connectableRoom = roomShuffler.getOne(); connectableRoom != undefined; connectableRoom = roomShuffler.getOne()) {
                     let tricky = connectableThroughFodder(fodderLevel, connectableRoom);

+ 27 - 2
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; // Requires two successes
+    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");
@@ -108,8 +109,12 @@ class RoomRandom extends Room {
     }
 
     public getDistanceTo (room : RoomRandom) {
-        let myCoordinates = this.lastMap.getCoordinates(this);
         let otherCoordinates = this.lastMap.getCoordinates(room);
+        return this.getDistanceToCoordinates(otherCoordinates);
+    }
+
+    public getDistanceToCoordinates (otherCoordinates) {
+        let myCoordinates = this.lastMap.getCoordinates(this);
         if (myCoordinates != undefined && otherCoordinates != undefined) {
             let c1 = myCoordinates;
             let c2 = otherCoordinates;
@@ -117,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

+ 2 - 2
app/World/Classes/RandomDungeons/RoomRandomFodder.ts

@@ -11,7 +11,7 @@ enum RandomLootType {
 
 interface FodderPossibility {
     name : string;
-    description : Say | string;
+    description : Say | string | (() => Say | string | (() => 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
@@ -26,7 +26,7 @@ class RoomRandomFodder extends RoomRandom {
 
     public cloneInterface (pos : FodderPossibility) {
         this.name = pos.name;
-        this.description = typeof pos.description == "string" ? new Say(pos.description) : pos.description;
+        this.description = !(pos.description instanceof Say)? new Say(pos.description) : pos.description;
         if (pos.objects != undefined) {
             for (let i = 0; i < pos.objects.length; i++) {
                 let object = pos.objects[i];

+ 11 - 0
app/World/Classes/RandomDungeons/RoomRandomMap.ts

@@ -80,6 +80,17 @@ class RoomRandomMap {
         return (this.positionTable[x] == undefined || this.positionTable[x][y] === undefined);
     }
 
+    public isFreeSquare (centerX : number, centerY : number, distanceFromCenter : number) {
+        for (let x = centerX - distanceFromCenter; x <= centerX + distanceFromCenter; x++) {
+            for (let y = centerY - distanceFromCenter; y <= centerY + distanceFromCenter; y++) {
+                if (!this.isFree(x,y)) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
     public block (x : number, y : number) {
         if (this.isFree(x, y)) {
             if (this.positionTable[x] == undefined) {

+ 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);
+    }
+}

+ 1 - 1
sass/_mainMenu.scss

@@ -3,7 +3,7 @@
 }
 
 #mainPage.mainmenu  {
-  & #statusLine , #statusLine , #rightWindow , #currentRoomTab , #fakeparserTab , #hyperlinksTab, #leftWindow{
+  & #statusLine , #statusLine , #rightWindow , #currentRoomTab , #fakeparserTab , #hyperlinksTab, #leftWindow, #bottomNoTurn{
     display: none;
   }
 

+ 26 - 11
sass/_page.scss

@@ -133,8 +133,12 @@ body {
   background-color: #fff;
 }
 
+#leftWindow {
+  display: none;
+}
+
 #centerWindow {
-  max-width: 60%;
+  max-width: 75%;
   flex: 1 1 auto;
   flex-grow: 4;
 }
@@ -166,8 +170,8 @@ body {
   to   { opacity: 1; }
 }
 
-#leftWindow {
-  background: linear-gradient(to right, rgba(0,0,0, $dark1) 0%, rgba(0,0,0, $dark2) 50%,rgba(0,0,0, $dark3) 100%);
+#rightWindow {
+  background: linear-gradient(to bottom left, rgba(0,0,0, $dark1) 0%, rgba(0,0,0, $dark2) 50%,rgba(0,0,0, $dark3) 100%);
 }
 
 #appearanceTab {
@@ -180,18 +184,19 @@ body {
 #inventoryTab {
   overflow-y: auto;
   flex-shrink: 1;
+  min-height: 12rem;
   //overflow: hidden;
   //background: linear-gradient(to left, rgba(0,0,0, $dark1) 0%, rgba(0,0,0, $dark2) 50%,rgba(0,0,0, $dark3) 100%);
 }
 
 #currentRoomTab {
   overflow: hidden;
-  background: linear-gradient(to bottom, rgba(0,0,0, $dark3) 75%,rgba(0,0,0, $dark4) 100%);
+  //background: linear-gradient(to bottom, rgba(0,0,0, $dark3) 75%,rgba(0,0,0, $dark4) 100%);
   padding: 0.8rem;
 }
 
 #hyperlinksTab {
-  background: rgba(0,0,0, $dark4);
+  //background: rgba(0,0,0, $dark4);
   text-indent: 1em;
 }
 
@@ -201,7 +206,7 @@ body {
 
 #fakeparserTab {
   overflow: visible;
-  background: rgba(0,0,0, $dark4);
+  //background: rgba(0,0,0, $dark4);
   padding: 0.8rem;
   font-family: $fixedWidthFont;
 
@@ -222,20 +227,30 @@ body {
 
 #rememberedRoomsTab, #mapTab {
   overflow-y: auto;
-  background: linear-gradient(to bottom left, rgba(0,0,0, $dark1) 0%, rgba(0,0,0, $dark2) 50%,rgba(0,0,0, $dark3) 100%);
+  //background: linear-gradient(to bottom left, rgba(0,0,0, $dark1) 0%, rgba(0,0,0, $dark2) 50%,rgba(0,0,0, $dark3) 100%);
   padding: 0.8rem;
+  position: relative;
 }
 
 // #mainPage.mobile
 #roomExitsHolder {
   @extend .noshrinkFlex;
-  background: linear-gradient(to top left, rgba(0,0,0, $dark1) 0%, rgba(0,0,0, $dark2) 50%,rgba(0,0,0, $dark3) 100%);
-  padding: 2ex;
-  padding-top: 0px;
+  width: 30%;
+  //background: linear-gradient(to top left, rgba(0,0,0, $dark1) 0%, rgba(0,0,0, $dark2) 50%,rgba(0,0,0, $dark3) 100%);
+  padding: 0px 2ex;
 }
 
 #exitsTab {
   overflow: hidden;
-  background-color: rgba(0,0,0, $dark4);
+  //background-color: rgba(0,0,0, $dark4);
   padding: 0.8rem;
 }
+
+
+#leftBottom {
+  position: relative;
+}
+
+#bottomNoTurn {
+  background: linear-gradient(to bottom, rgba(0,0,0, $dark3) 75%,rgba(0,0,0, $dark4) 100%);
+}

+ 1 - 2
sass/text/_say.scss

@@ -74,8 +74,7 @@ p.choice {
   &.small {
     display: inline-block;
     padding-right: 1rem;
-    margin: 0px;
-    margin-right: 0.5rem;
+    margin-right: 0.25rem;
   }
 }