Я был вдохновлен "Black Mirror Bandersnatch", выбрав свой собственный приключенческий эпизод, и решил сам дать ему go. До сих пор я создал несколько функциональный скелет в качестве шаблона для остальной части проекта. Я хочу посмотреть, есть ли у каких-нибудь хороших программистов советы по упрощению операторов переключения, которые экспоненциально увеличиваются по мере продвижения в игру. Вот что у меня есть до сих пор ...
#include <iostream>
#include <Player.h>
using namespace std;
int main()
{
Player player;
cout << "Health: " << player.GetHealth() << endl;
int choice = 0;
cout << "You wake up on Jupiter. There is a tunnel with a mysterious blue light emitting from it in the distance. You look to the right and see a futuristic factory with strange crafts flying from it. You wonder how you got to Jupiter...\n" << endl;
cout << "Go to the tunnel(1) \t Go to the factory(2)\n>>> ";
cin >> choice;
switch(choice)
{
case 1:
cout << "You go towards the tunnel and get attacked by a flying saucer...\n";
player.DecreaseHealth();
cout << "Health: " << player.GetHealth() << "\n";
cout << "You see a secret nazi facility. Go and check it out(1). In the distance you see a TR3-B craft. Do you want to fly it? (2)\n";
//choice = 0;
cout << "Go to the secret nazi facility(1) \t Get inside TR3-B(2)\n>>> ";
cin >> choice;
switch(choice)
{
case 1:
cout << "You go to secret nazi facility...\n";
player.DecreaseHealth();
cout << "Health: " << player.GetHealth() << "\n";
break;
case 2:
cout << "You get inside TR3B... \n";
break;
}
break;
case 2:
cout << "You go towards the factory...\n";
cout << "Health: " << player.GetHealth() << "\n";
cout << "Do you want to steal element 117(1) or grab TR3-B top secret documents(2)\n";
cin >> choice;
switch(choice)
{
case 1:
cout << "You steal element 117...\n";
player.DecreaseHealth();
cout << "Health: " << player.GetHealth() << "\n";
break;
case 2:
cout << "You grab documents... \n";
break;
}
break;
}
return 0;
}
Как видите, у меня есть только 2 абсолютных пути с 2 собственными путями. В каждом случае будет добавлено еще 2 случая. Когда я доберусь до третьего уровня дерева, я получу огромное количество 16 дел. После третьего уровня его 32-64-128 и пр. Большое спасибо заранее.