Welcome back.
In this video we're going to build an adventure game.
And therefore we first of all need to let the user know about the adventure game.
So welcome to the adventure game okay.
So that will be our first line.
And then we ask the user to enter his or her username or character name.
Enter your character's name okay.
And we could then add an apostrophe here.
That would work.
So then I'm going to store the player name in here, or the character name or something like that using
console dot read line.
And I'm going to ask the user for the class of his character.
So is it going to be a warrior, a wizard or an archer?
So here I'm going to say choose your character type or class, whatever you want to call it.
Warrior, wizard, Archer.
All right.
So then we need to get the user input.
Now we could say press one for warrior, press two for Wizard, and so forth.
But we can also just store whatever the user has entered.
Maybe the user has some very different idea of the character.
So I'm going to call it character type.
And that one also will be a red line by the user.
So then how the story starts is we're going to say something like and let's use a dollar sign here u
comma.
And then we're using the player name the and then we're using the player type.
So the character type find yourself at the edge of a dark forest okay.
So you're at the edge of a dark forest.
Now the next step would be to ask the user whether he wants to go into the forest or wants to camp out.
So CW, do you enter the forest or camp outside?
And then we give the user enter or camp as the option.
So we're going to get the user input in here string.
And this will be the choice one which will be Console.readline statement.
So now we're using the user's choice and make the story based on that.
So here we can just go and say if choice one is.
And actually let's make sure that we don't care whether it's a upper character or a lower character.
We're going to say if it's enter, then we're going to say something like, you bravely enter the forest,
and then else we can say something like, you decide to camp out and wait for daylight.
And here I forgot the semicolon at the end.
So let's add that there.
So here we can go ahead and add scenarios okay.
So we can go in here and say okay scenario one or scenario two or whatever we want.
We can add that here.
And we can also however have a game loop here.
So the next thing that I'm going to do is I'm going to have a game continuous equals true boolean.
So this one will take care of continuing the game or not continuing the game.
So I'm going to use a while loop here.
While game continues I'm going to say you come to a fork in the road go left or right and then we can
use the user option.
I'm going to call this one Direction and this one will be a Console.WriteLine statement.
And I'm going to check here if direction dot to lower is going to be equal to left, then let's say
the user finds a treasure.
So we're going to say console right line.
You find a treasure chest okay.
And now we can go further and say okay now what do you do with the chest.
What do you do with whatsoever.
And in my case, I'm just going to say at this point the game is over.
So you found the chest.
You're done.
Good job.
And then in the else block.
So let's say we don't select left we go right for example.
Or we go straight or whatever.
Then we're going to say you encounter a wild beast.
Now we're going to ask the user fight or flee.
And then we give the options here as well.
So the user understands what they need to enter, fight, slash, flee.
And then we're going to say string fight choice is console.
And.
Let's see.
Like this okay.
Console read line.
And now we can check what the choice was.
So if the fight choice to lower again making sure that our app will work no matter if they enter flee
or upper letter or whatever.
So let's say the user says fight and then we can use, for example, our guess the number game or whatever
and see how many tries we needed.
So let's say we only needed five tries, then we survive.
Or if we needed more than five tries, then we lose and we die and the game is over.
So here let me create a random number again.
And I'm going to say int luck is going to be random next between 1 and 1010 excluded or let's say 1110
included.
And I'm going to say if luck is greater than five, then we get a treasure.
So CW, you beat the opponent or the wild beast, wild beast.
And then we're going to say if luck greater eight, then we even got a treasure.
So if we're very lucky, we're going to say CW, you, the wild beast dropped a treasure.
Very cool.
So if the luck is less than 5 or 5, then we're going to say you're dead.
So you, uh.
Well, maybe we make it a little more appealing.
We say something like the beast attacked you where you didn't expect it.
It it ran, rammed its tusks into your chest, and you bleed out.
And then at this point, we can say game continues false.
So at this point, the game is over.
Okay.
So now I think that would be it.
So we just keep going.
Now we could add a lot more to the game.
But if you look at it this is pretty much already a game to a degree where we now go ahead and we can
select to fight or we can let it be.
So I'd say, let's run this little project and see what options we have and how it goes.
Okay, we see the options because we coded them.
But let's go ahead and let's call this one Frank.
The tank is the character name.
And I'm going to be a warrior.
And maybe we should use the character type also in the fighting.
So depending on which type you have you change the attack that will be displayed.
So that would be at this point here.
So when we are selecting to fight and we can have something random where let's say if the random number
is below 3 or 3 and below, then it's going to be weak against magicians or against wizards.
If it's between 4 and 7, then it's going to be weak against warriors.
If it's between 8 and 10, then it's going to be weak against archers, for example.
And then depending on our character type, it's going to give us an advantage and we win the fight or
we lose the fight.
So this is something where we could make the story even more appealing and more in depth.
Okay, so but then let's go ahead here.
Do, uh, you, Frank the tank, the warrior, find yourself at the edge of the dark forest?
Do you enter the forest or camp outside?
Okay, let's enter the forest.
You bravely enter the forest.
You come to a fork in the road.
Go left or right.
Okay.
Let's go left.
You find a treasure.
Done.
And now let's do it again.
But this time we don't find the treasure.
So I'm going to keep it simple.
I'm Dennis, I'm a warrior again.
Then I enter and here I go.
Right this time I encounter a wild beast.
So let's fight.
The beast attacked you.
Uh, attacked.
Comma.
I should have added the comma.
You were, uh.
You were.
You didn't expect it.
It rammed its tusks into your chest, and you bleed it out or you bleed out.
It should maybe say something like, game over.
But, yeah, uh, that's something we can now add here at the bottom as well.
So console right line.
Thank you for playing the game.
And maybe something like here CW the good old game over.
Yeah.
And that's pretty much our first little game.
It's a text based adventure game that is far from being done.
But now you can go ahead and extend that to however many.
Layers of if and else ifs and loops you want to have.
And I gave you a few ideas and I would love to see what you have built.
Okay, so once you're done building your own little adventure, feel free to share it with everyone
else in the course and I'd love to see that.
So I wish you all the best.
I wish you a lot of fun building this little story and see you in the next video.