Implement scoring
authorJason Self <j@jxself.org>
Tue, 31 May 2022 00:28:19 +0000 (17:28 -0700)
committerJason Self <j@jxself.org>
Tue, 31 May 2022 00:28:19 +0000 (17:28 -0700)
src/snowed-in.inf

index 6c262e23711d6a95b40e8aac984d5425e306ea51..3bdf7102f3e4ca6dccf4ec40769c2f687babec95 100644 (file)
@@ -17,7 +17,7 @@ Global body_temperature = 20;
 Global cabin_has_electricity = 1;
 Global forest_location = 1;
 Global snowmobile_location = 0;
 Global cabin_has_electricity = 1;
 Global forest_location = 1;
 Global snowmobile_location = 0;
-Constant NO_SCORE;
+Constant MAX_SCORE = 7;
 Constant DEATH_MENTION_UNDO;
 Constant Story "Snowed In";
 Constant Headline 
 Constant DEATH_MENTION_UNDO;
 Constant Story "Snowed In";
 Constant Headline 
@@ -38,7 +38,7 @@ Constant Headline
 Include "parser";
 Include "verblib";
 Release 1;
 Include "parser";
 Include "verblib";
 Release 1;
-Serial "220530";
+Serial "220531";
 
 Object  mainroom "Main Room"
   with  description 
 
 Object  mainroom "Main Room"
   with  description 
@@ -169,6 +169,7 @@ Object  television "flat-screen TV" mainroom
             print_ret (The) self, " is firmly mounted to the wall.";
           SwitchOn:
             if (television hasnt visited) {
             print_ret (The) self, " is firmly mounted to the wall.";
           SwitchOn:
             if (television hasnt visited) {
+                score = score + 1;
                 print 
                     "Despite the significant damage, the television 
                     comes to life in one last valiant attempt to be 
                 print 
                     "Despite the significant damage, the television 
                     comes to life in one last valiant attempt to be 
@@ -266,6 +267,10 @@ Object  office "Office"
                         "You can't fit through the window while 
                         wearing the snow shoes.";
             }
                         "You can't fit through the window while 
                         wearing the snow shoes.";
             }
+            if (eastofcabin hasnt visited) {
+                score = score + 1;
+                give office visited;
+            }
         ],
         w_to mainroom,
         e_to window,
         ],
         w_to mainroom,
         e_to window,
@@ -312,6 +317,7 @@ Object  computer "computer" desk
             print_ret (The) self, " is too heavy for that.";
           SwitchOn:
             if (computer hasnt visited) {
             print_ret (The) self, " is too heavy for that.";
           SwitchOn:
             if (computer hasnt visited) {
+                score = score + 1;
                 print 
                     "The computer makes some concerning noises while 
                     lights on the front also illuminate. The last 
                 print 
                     "The computer makes some concerning noises while 
                     lights on the front also illuminate. The last 
@@ -464,6 +470,11 @@ Object  snowsuit "snowsuit" suitcase
             "The snowsuit is blue, decorated with white and purple 
             designs. On the chest are the letters ~CE~ in purple.",
         before [;
             "The snowsuit is blue, decorated with white and purple 
             designs. On the chest are the letters ~CE~ in purple.",
         before [;
+          Examine:
+            if (snowsuit hasnt visited) {
+                score = score + 1;
+                give snowsuit visited;
+            }
           Wear:
             if (snowshoes in player && snowshoes has worn) {
                 print_ret "The snowsuit can't fit over the snowshoes.";
           Wear:
             if (snowshoes in player && snowshoes has worn) {
                 print_ret "The snowsuit can't fit over the snowshoes.";
@@ -644,6 +655,13 @@ Object  backpack "backpack" backpacklocation
             toward the bottom of the backpack. On the side are the 
             letters ~CE~ in purple. The backpack is covered in blood, 
             as if the owner met with an untimely demise.",
             toward the bottom of the backpack. On the side are the 
             letters ~CE~ in purple. The backpack is covered in blood, 
             as if the owner met with an untimely demise.",
+        before [;
+          Examine:
+            if (backpack hasnt visited) {
+                score = score + 1;
+                give backpack visited;
+            }
+        ],
   has   clothing container openable;
 
 Object  flashlight "flashlight" backpack
   has   clothing container openable;
 
 Object  flashlight "flashlight" backpack
@@ -653,6 +671,10 @@ Object  flashlight "flashlight" backpack
             inches long.",
         before [;
           SwitchOn:
             inches long.",
         before [;
           SwitchOn:
+            if (flashlight hasnt visited) {
+                score = score + 1;
+                give flashlight visited;
+            }
             give flashlight light;
           SwitchOff:
             give lantern ~light;
             give flashlight light;
           SwitchOff:
             give lantern ~light;
@@ -841,6 +863,7 @@ Object  forest "Forest"
     give lantern ~light;
     lantern_fuel_left = 0;
     StopDaemon(lantern);
     give lantern ~light;
     lantern_fuel_left = 0;
     StopDaemon(lantern);
+    score = score - 1;
 ];
 
 [ check_for_cabin_lighting;
 ];
 
 [ check_for_cabin_lighting;
@@ -917,7 +940,16 @@ Object  northofcabin "North Of Cabin"
         n_to westofcabin,
         s_to roof,
         w_to westofcabin,
         n_to westofcabin,
         s_to roof,
         w_to westofcabin,
-        cant_go "It's too steep to go in that direction safely.";
+        cant_go "It's too steep to go in that direction safely.",
+        before [;
+          Go:
+            if (noun == s_obj) {
+                if (roof hasnt visited) {
+                    score = score + 1;
+                    give roof visited;
+                }
+            }
+        ];
 
 Object  westofcabin "West Of Cabin"
   with  description 
 
 Object  westofcabin "West Of Cabin"
   with  description 
@@ -990,9 +1022,8 @@ Object  snowmobile "snowmobile" thedark
             {
                 deadflag = 2;
                 print_ret 
             {
                 deadflag = 2;
                 print_ret 
-                    "You hear a snowmobile approaching in the 
-                    distance. The person says they saw your light and 
-                    came to rescue you.";
+                    "A snowmobile approaches. The person says they 
+                    saw your light and came to rescue you.";
             }
             return true;
         ],
             }
             return true;
         ],
@@ -1070,10 +1101,30 @@ Object  grue "grue" thedark
     grue!";
 ];
 
     grue!";
 ];
 
+[ PrintRank;
+    print ", earning you the rank of ";
+    if (score == 0)
+        "Novice.";
+    if (score == 1)
+        "Trained.";
+    if (score == 2)
+        "Skilled.";
+    if (score == 3)
+        "Talented.";
+    if (score == 4)
+        "Capable.";
+    if (score == 5)
+        "Adept.";
+    if (score == 6)
+        "Proficient.";
+    if (score >= 7)
+        print "Versed.";
+];
+
 [ URL;
     print 
         "^If you need help try some of the commands from: 
 [ URL;
     print 
         "^If you need help try some of the commands from: 
-        ^http://pr-if.org/doc/play-if-card/^";
+        ^https://pr-if.org/doc/play-if-card/^";
 ];
 
 [ XyzzySub;
 ];
 
 [ XyzzySub;
@@ -1119,4 +1170,4 @@ Extend 'climb'
     * 'through' / 'out' / 'via' noun -> Go;
 
 Extend 'go'
     * 'through' / 'out' / 'via' noun -> Go;
 
 Extend 'go'
-    * 'through' / 'out' / 'via' noun -> Go;
\ No newline at end of file
+    * 'through' / 'out' / 'via' noun -> Go;