Need Help with Text Based Game

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  // game test number 1
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
using namespace std;

int main(){ 
int d10 ;
int ML1 ;
int ML2 ;
int ML3 ;
int RM1 ;
int RM2 ;
int BOS ;
int WP1 ;
int rr ;
int MNS ;
    cout << "You have been assigned by the Lord of Uberdark to patrol the Mines of Rodin. While patroling you run into a goblin!";
    char myArray[50];
    cout << " What do you want to do, run or fight the goblin? ";
    cin.getline( myArray, 50, '\n');
    if( !strcmp( myArray, "fight")){
        srand(time(0));
    d10 = rand() % 10+1;
    cout << d10;
    ML1 = rand() % 10+1;
    cout << ML1;
    if(d10 > ML1){
    cout << " You defeated the goblin!" << endl << endl;}
    if(d10 < ML1){
    cout << " You have been defeated by the goblin! You retreat back to Uberdark to rest." << endl << endl;}
    if(d10 == ML1){
    cout << " You and the goblin have both been defeated by entropy!\n\n" << endl << endl;
    }
    if(d10 == ML1){
           cout << " You get back up and rest for a while to then continue your task." << endl << endl;}
    if(d10 < ML1){
           cout << " You return from Uberdark well rested." << endl << endl;}
           }
    if( !strcmp( myArray, "run")){
        srand(time(0));
        rr = rand() % 14+1;
        if(rr > 7){
              cout << " You have successfully ran away, coward!" << endl << endl;}
        if(rr < 7){
              cout << " The goblin has caught up to you and beat you to the floor. You wake up later and continue to patrol." << endl << endl;}
        if(rr == 7){
              cout << " The goblin has caught up to you and beat you to the floor. You wake up later and continue to patrol." <<endl <<endl;}
    // Part 2
     {cout << " As you continue along in the mines you hear a noise. You investigate and discover the source, a room.";
     cout << " Will You go through the door or leave and cancel the investigation? ";
     cin.getline( myArray, 50, '\n');
     if( !strcmp( myArray, "go through")){
         srand(time(0));
         RM1 = rand() % 20+1;
         if(RM1 < 8){
                cout << " You find and ancient relic as you put the relic into your rucksack you feel a power come over you.";
                cout << " Your sword begins to glow blue and your armor is now...";
                cout << " Ancient armor of the Gods!" << endl << endl;}
         if(RM1 > 8){
                cout << " You find nothing but a pile of bones and a dead rat.";
                cout << " You leave the room and continue patroling." << endl <<endl;}
                }
     if( !strcmp( myArray, "leave")){
         cout << " You walk away from the door but the sound is still there and it continues to haunt you.";}
         srand(time(0));
         MNS = rand() % 20+1;
         if(MNS > 1){
                cout << " You run into a dwarf on the walk away from the door.";
                cout << " He is equipped with corrupt dwarven armor and has fierce red eyes.";
                cout << " As you reach for your sword the dwarf says something.";
                cout << " What are you doing petty human?";
                cout << " Do you not realize that I am the Dark Lord Farron?";
                cout << " You feel a dark shadow rise from the Farron.";
                cout << " The dwarf suddenly vannishes.";}
         if(MNS == 1){
                cout << " You run into a dwarf on the walk away from the door.";
                cout << " He is equipped with corrupt dwarven armor and has fierce red eyes.";
                cout << " As you reach for your sword the dwarf says something.";
                cout << " What are you doing petty human?";
                cout << " Do you not realize that I am the Dark Lord Farron?";
                cout << " You feel a dark shadow rise from the Farron.";
                cout << " The dwarf suddenly vannishes.";}
system("pause");}
}
}        

I don't know why but when I type "fight" in the beginning when fighting the goblin the window just closes can anyone help? It worked before but now it keeps closing when I type "fight". Plz help!
closed account (N36fSL3A)
Why aren't you using strings? Try using std::string.
So what else you expected it to do , if you fight you either win or lose , that's it,you get out of the program as there is no loop or anything more to do when you all do is fight.
Topic archived. No new replies allowed.