Browse Source

Bug fixezzz\!\!\!\!\?\?\!\?\!\?\!\?\!\!

iam 1 year ago
parent
commit
7cc247c1ef
5 changed files with 27 additions and 12 deletions
  1. 7 6
      src/checkCondition.cpp
  2. 11 4
      src/gameController.cpp
  3. 2 2
      src/main.cpp
  4. 1 0
      webserver/games/game.txt
  5. 6 0
      webserver/public/stylesheets/game.css

+ 7 - 6
src/checkCondition.cpp

@@ -116,6 +116,7 @@ std::string parseConditionBoolean(std::string condition)
116 116
                 condition.insert(place-1, "0");
117 117
         }
118 118
     }
119
+    
119 120
     return condition;
120 121
 }
121 122
 
@@ -148,17 +149,17 @@ bool GameController::checkVariable(std::string variableString)
148 149
             variableName += variableString[place];
149 150
     }
150 151
     
151
-    for(int place = 0; place < variables.size(); place++)
152
-    {
153
-        if(variables.at(place) == variableName && variablesValue.at(place) == variableValue)
154
-            return !isNegate;
155
-    }
152
+    if(getVariableValue(variableName) == variableValue)
153
+        return !isNegate;
154
+    
156 155
     return isNegate;
157 156
 }
158 157
 
159 158
 bool GameController::checkCondition(std::string condition)
160 159
 {
161 160
     condition = removeWhiteSpace(condition, '\n');
161
+    condition = doMacros(condition);
162
+    
162 163
     std::string checkFor[] = {"item", "life", "gameclock", "var"};
163 164
     
164 165
     bool reply;
@@ -198,7 +199,7 @@ bool GameController::checkCondition(std::string condition)
198 199
                     else
199 200
                         condition.insert(place, "0");
200 201
                 }
201
-                
202
+        
202 203
         return parseConditionBoolean(condition)[0]-48;
203 204
     }
204 205
 }

+ 11 - 4
src/gameController.cpp

@@ -194,16 +194,19 @@ std::string GameController::doHealth(std::string command)
194 194
     {
195 195
         health += stoi(amount);
196 196
         std::cout << "+" << stoi(amount) << " health. (" << health << " now) " << sessionKey << std::endl;
197
+        std::cout << " " << sessionKey << std::endl;
197 198
     }
198 199
     else if(type == '-')
199 200
     {
200 201
         health -= stoi(amount);
201 202
         std::cout << "-" << stoi(amount) << " health. (" << health << " now) " << sessionKey << std::endl;
203
+        std::cout << " " << sessionKey << std::endl;
202 204
     }
203 205
     else if(type == '=')
204 206
     {
205
-        std::cout << "Health set to " << health << " " << sessionKey << std::endl;
206 207
         health = stoi(amount);
208
+        std::cout << "Health set to " << health << " " << sessionKey << std::endl;
209
+        std::cout << " " << sessionKey << std::endl;
207 210
     }
208 211
     
209 212
     if(health <= 0)
@@ -387,13 +390,16 @@ bool GameController::addItem(std::string itemString)
387 390
             {
388 391
                 case '+':
389 392
                 {
390
-                    std::cout << itemName << " + " << amount << " " << sessionKey << std::endl;
393
+                    itemsAmount.at(place) += intAmount;
394
+                    std::cout << itemName << " + " << amount << " (" << itemsAmount.at(place) << " now) " << sessionKey << std::endl;
395
+                    std::cout << " " << sessionKey << std::endl;
391 396
                 }
392 397
                 break;
393 398
                 case '-':
394 399
                 {
395 400
                     itemsAmount.at(place) -= intAmount;
396
-                    std::cout << itemName << " - " << amount << " " << sessionKey << std::endl;
401
+                    std::cout << itemName << " - " << amount << " (" << itemsAmount.at(place) << " now) " << sessionKey << std::endl;
402
+                    std::cout << " " << sessionKey << std::endl;
397 403
                 }
398 404
                 break;
399 405
                 case '/':
@@ -414,7 +420,8 @@ bool GameController::addItem(std::string itemString)
414 420
     
415 421
     if(not foundPlace)
416 422
     {
417
-        std::cout << itemName << " + " << amount << " " << sessionKey << std::endl;
423
+        std::cout << itemName << " + " << amount << " (" << amount << " now) " << sessionKey << std::endl;
424
+        std::cout << " " << sessionKey << std::endl;
418 425
         
419 426
         items.push_back(itemName);
420 427
         itemsAmount.push_back(intAmount);

+ 2 - 2
src/main.cpp

@@ -152,8 +152,8 @@ int main()
152 152
     mainGameVector.push_back(new GameContainer);
153 153
     mainGameVector.at(mainGameVector.size()-1)->game = new GameController("moo"); //moo
154 154
     mainGameVector.at(mainGameVector.size()-1)->sessionKey = "moo"; //moo
155
-    mainGameVector.at(mainGameVector.size()-1)->game->parseFile("game.txt"); //game.txt
156
-    mainGameVector.at(mainGameVector.size()-1)->game->storyline = ";setup;"; //;setup;
155
+    mainGameVector.at(mainGameVector.size()-1)->game->parseFile("rpg.txt"); //game.txt
156
+    mainGameVector.at(mainGameVector.size()-1)->game->storyline = ";1;"; //;setup;
157 157
     printOptions(mainGameVector.size()-1, &mainGameVector);
158 158
     */
159 159
     

File diff suppressed because it is too large
+ 1 - 0
webserver/games/game.txt


+ 6 - 0
webserver/public/stylesheets/game.css

@@ -2,6 +2,12 @@
2 2
     max-height: none !important;
3 3
     height: 70vh;
4 4
     margin-top: 30px;
5
+    
6
+    white-space: pre-wrap;       /* Since CSS 2.1 */
7
+    white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
8
+    white-space: -pre-wrap;      /* Opera 4-6 */
9
+    white-space: -o-pre-wrap;    /* Opera 7 */
10
+    word-wrap: break-word;       /* Internet Explorer 5.5+ */
5 11
 }
6 12
 
7 13
 #game {