Skip to content

Instantly share code, notes, and snippets.

@Thanatossan
Created April 26, 2018 23:15
Show Gist options
  • Save Thanatossan/84e72c6a0e8b194255a70c52f2ff03c2 to your computer and use it in GitHub Desktop.
Save Thanatossan/84e72c6a0e8b194255a70c52f2ff03c2 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<vector>
#include<cstdlib>
#include<iomanip>
#include<ctime>
#include<algorithm>
#include"Structure.h"
using namespace std;
void Approveordecline_bot();
//setting n players role format.
void Avalon::roleSet(int n){
allCharacter.push_back("Mordred");
allCharacter.push_back("Assassin");
allCharacter.push_back("Merlin");
allCharacter.push_back("Soldier No.1");
switch(n){
case 8:
allCharacter.push_back("Percival");
case 7:
allCharacter.push_back("Soldier No.3");
case 6:
allCharacter.push_back("Oberon");
case 5:
allCharacter.push_back("Soldier No.2");
break;
}
}
//shuffle all roles before showing.
//show your character and ability.
void Avalon::showRole(){
cout << "\n You are playing as " << allCharacter[0] << "\n";
character = allCharacter[0];
if(character == "Mordred"){
side=-1;
cout << "\n\n*******************************************************************\n\n";
cout << " An evil who are unknown to Merlin.";
cout << "\n\n*******************************************************************\n\n";
}else if(character == "Assassin"){
side=-1;
cout << "\n\n*******************************************************************\n\n";
cout << " Find the Merlin. Take an advantage to win the game at the end.";
cout << "\n\n*******************************************************************\n\n";
}else if(character == "Oberon"){
side=-1;
cout << "\n\n*******************************************************************\n\n";
cout << " You are an evil. Your team knows who you are, but you don't.";
cout << "\n\n*******************************************************************\n\n";
}else if(character == "Merlin"){
side=1;
cout << "\n\n*******************************************************************\n\n";
cout << " Knows the evil. But keep it secret.";
cout << "\n\n*******************************************************************\n\n";
}else if(character == "Percival"){
side=1;
cout << "\n\n*******************************************************************\n\n";
cout << " Help Merlin to remain unnoticed.";
cout << "\n\n*******************************************************************\n\n";
}else{
side=1;
cout << "\n\n*******************************************************************\n\n";
cout << " You don't have any special abilities, successfully\n";
cout << " keep evils out of the mission at least 3 missions to win.";
cout << "\n\n*******************************************************************\n\n";
}
}
int main(){
//game open
int map;
string score[6];
srand(time(0));
data system(1,0);
cout << "###################################################################\n\n";
cout << " **** ** ** **** ** ****** ** ** \n";
cout << " ** ** ** ** ** ** ** ** ** *** ** \n";
cout << " ** ** ** ** ** ** ** ** ** **** ** \n";
cout << " ******** ** ** ******** ** ** ** ** ** ** \n";
cout << " ** ** **** ** ** ** ** ** ** **** \n";
cout << " ** ** ** ** ** ****** ****** ** *** \n\n";
cout << "###################################################################\n\n";
cout << " [1] GAME START [2] EXIT \n\n\n";
//choose start or exit
string action;
do{
cout << " Please choose the action \"1\" or \"2\" : ";
getline(cin,action);
if(action == "1" || action == "2") break;
}while(true);
//result of action
if(action == "1"){
//start
cout << "\n GAME STARTED !!\n";
cout << "\n\n\n Press \"Enter\" to continue...\n ";
cin.get();
//number of player produce picking map
int players = 0;
cout << "\n\n###################################################################\n\n";
do{
cout << " Please input number of players 5-8 : ";
cin >> players;
cin.ignore();////////////////////bug/////////////////////////////////////////////////////////////////////////////////////
}while(players<5 || players>8);
cout << "\n Starting map #" << players-4 << endl;
//random character
cout << "\n\n Pick one of the character cards...\n\n";
switch (players){
case 5 :
cout << " %%%%% %%%%% %%%%% %%%%% %%%%% \n";
cout << " % % % % % % % % % % \n";
cout << " % 1 % % 2 % % 3 % % 4 % % 5 % \n";
cout << " % % % % % % % % % % \n";
cout << " %%%%% %%%%% %%%%% %%%%% %%%%% \n\n";
break;
case 6 :
cout << " %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% \n";
cout << " % % % % % % % % % % % % \n";
cout << " % 1 % % 2 % % 3 % % 4 % % 5 % % 6 % \n";
cout << " % % % % % % % % % % % % \n";
cout << " %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% \n\n";
break;
case 7 :
cout << " %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% \n";
cout << " % % % % % % % % % % % % % % \n";
cout << " % 1 % % 2 % % 3 % % 4 % % 5 % % 6 % % 7 % \n";
cout << " % % % % % % % % % % % % % % \n";
cout << " %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% \n\n";
break;
case 8 :
cout << " %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% \n";
cout << " % % % % % % % % % % % % % % % % \n";
cout << " % 1 % % 2 % % 3 % % 4 % % 5 % % 6 % % 7 % % 8 % \n";
cout << " % % % % % % % % % % % % % % % % \n";
cout << " %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% \n\n";
break;
}
int card;
do{
cout << " Please input card number 1-" << players << " : ";
cin >> card;
cin.ignore();
}while(card < 1 || card > players);
Avalon player("korn","character",0,0,1,0);
player.roleSet(players);
random_shuffle( player.allCharacter.begin(), player.allCharacter.end());
player.showRole();
bot bot1(1,"bot1","character",0,0,0,0);
bot bot2(2,"bot2","character",0,0,0,0);
bot bot3(3,"bot3","character",0,0,0,0);
bot bot4(4,"bot4","character",0,0,0,0);
bot bot5(5,"bot1","character",0,0,0,0);
bot bot6(6,"bot2","character",0,0,0,0);
bot bot7(7,"bot3","character",0,0,0,0);
switch(players){
case 5:
bot1.character = player.allCharacter[1];
bot2.character = player.allCharacter[2];
bot3.character = player.allCharacter[3];
bot4.character = player.allCharacter[4];
break;
case 6:
bot1.character = player.allCharacter[1];
bot2.character = player.allCharacter[2];
bot3.character = player.allCharacter[3];
bot4.character = player.allCharacter[4];
bot5.character = player.allCharacter[5];
break;
case 7:
bot1.character = player.allCharacter[1];
bot2.character = player.allCharacter[2];
bot3.character = player.allCharacter[3];
bot4.character = player.allCharacter[4];
bot5.character = player.allCharacter[5];
bot6.character = player.allCharacter[6];
break;
case 8:
bot1.character = player.allCharacter[1];
bot2.character = player.allCharacter[2];
bot3.character = player.allCharacter[3];
bot4.character = player.allCharacter[4];
bot5.character = player.allCharacter[5];
bot6.character = player.allCharacter[6];
bot7.character = player.allCharacter[7];
break;
}
if(bot1.character == "Mordred" || bot1.character =="Assassin" || bot1.character =="Oberon"){ bot1.side=-1;}else{bot1.side =1; }
if(bot2.character == "Mordred" || bot2.character =="Assassin" || bot2.character =="Oberon"){ bot2.side=-1;}else{bot2.side =1; }
if(bot3.character == "Mordred" || bot3.character =="Assassin" || bot3.character =="Oberon"){ bot3.side=-1;}else{bot3.side =1; }
if(bot4.character == "Mordred" || bot4.character =="Assassin" || bot4.character =="Oberon"){ bot4.side=-1;}else{bot4.side =1; }
if(bot5.character == "Mordred" || bot5.character =="Assassin" || bot5.character =="Oberon"){ bot5.side=-1;}else{bot5.side =1; }
if(bot6.character == "Mordred" || bot6.character =="Assassin" || bot6.character =="Oberon"){ bot6.side=-1;}else{bot6.side =1; }
if(bot7.character == "Mordred" || bot7.character =="Assassin" || bot7.character =="Oberon"){ bot7.side=-1;}else{bot7.side =1; }
cout << "\n\n Press \"Enter\" to continue...\n ";
cin.get();
//game play
switch (players){
case 5 :
cout << "\n\n###################################################################\n\n";
break;
case 6 :
cout << "\n\n###############################################################################\n\n";
break;
case 7 :
cout << "\n\n###########################################################################################\n\n";
break;
case 8 :
cout << "\n\n#######################################################################################################\n\n";
break;
}
cout << " In this map, there're 5 quests...\n\n\n";
for(system.checkturn=1;system.checkturn<=5;system.checkturn++){
if(system.badwin==3){
break;
}
else if(system.goodwin==3){
break;
}
if(player.character=="Merlin"){
cout << " These player are Bad side \n";
if(bot1.side=-1 && bot1.character !="Mordred") cout << " bot1 \n";
if(bot2.side=-1 && bot2.character !="Mordred") cout << " bot2 \n";
if(bot3.side=-1 && bot3.character !="Mordred") cout << " bot3\n";
if(bot4.side=-1 && bot4.character !="Mordred") cout << " bot4\n";
}
else if(player.side=-1){
cout << "These player is on your side \n";
if(bot1.side==player.side && bot1.side!=1) cout << " bot1 \n";
if(bot2.side==player.side &&bot1.side!=1) cout << " bot2 \n";
if(bot3.side==player.side &&bot1.side!=1) cout << " bot3\n";
if(bot4.side==player.side &&bot1.side!=1) cout << " bot4\n";
}
cout << "\n";
string a=" 1 ", b=" 2 ", c=" 3 ", d=" 4 ", e=" 5 "; //defult
a = "Success"; //success
b = " Fail! "; //fail
switch (players){
case 5 :
cout << " @@@@@ @@@@@ @@@@@ @@@@@ @@@@@ \n";
cout << " @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ \n";
cout << " @"<<a<<"@ @"<<b<<"@ @"<<c<<"@ @"<<d<<"@ @"<<e<<"@ \n";
cout << " @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ \n";
cout << " @@@@@ @@@@@ @@@@@ @@@@@ @@@@@ \n\n\n";
break;
case 6 :
cout << " @@@@@ @@@@@ @@@@@ @@@@@ @@@@@ \n";
cout << " @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ \n";
cout << " @"<<a<<"@ @"<<b<<"@ @"<<c<<"@ @"<<d<<"@ @"<<e<<"@ \n";
cout << " @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ \n";
cout << " @@@@@ @@@@@ @@@@@ @@@@@ @@@@@ \n\n\n";
break;
case 7 :
cout << " @@@@@ @@@@@ @@@@@ @@@@@ @@@@@ \n";
cout << " @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ \n";
cout << " @"<<a<<"@ @"<<b<<"@ @"<<c<<"@ @"<<d<<"@ @"<<e<<"@ \n";
cout << " @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ \n";
cout << " @@@@@ @@@@@ @@@@@ @@@@@ @@@@@ \n\n\n";
break;
case 8 :
cout << " @@@@@ @@@@@ @@@@@ @@@@@ @@@@@ \n";
cout << " @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ \n";
cout << " @"<<a<<"@ @"<<b<<"@ @"<<c<<"@ @"<<d<<"@ @"<<e<<"@ \n";
cout << " @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ \n";
cout << " @@@@@ @@@@@ @@@@@ @@@@@ @@@@@ \n\n\n";
break;
}
//chooseplayer
/*switch (players){
case 5 :
cout << " [1] Agree [2] Disagree \n\n\n";
break;
case 6 :
cout << " [1] Agree [2] Disagree \n\n\n";
break;
case 7 :
cout << " [1] Agree [2] Disagree \n\n\n";
break;
case 8 :
cout << " [1] Agree [2] Disagree \n\n\n";
break;
}*/
/*switch (players){
case 5 :
cout << " [1] Success [2] Fail \n\n\n";
break;
case 6 :
cout << " [1] Success [2] Fail \n\n\n";
break;
case 7 :
cout << " [1] Success [2] Fail \n\n\n";
break;
case 8 :
cout << " [1] Success [2] Fail \n\n\n";
break;
}*/
/*switch (players){
case 5 :
cout << " Result:\n";
break;
case 6 :
cout << " Result:\n";
break;
case 7 :
cout << " Result:\n";
break;
case 8 :
cout << " Result:\n";
break;
}*/
switch (players){
case 5 :
cout << " 2 Succes 0 Fail\n\n\n";
break;
case 6 :
cout << " 2 Succes 0 Fail\n\n\n";
break;
case 7 :
cout << " 2 Succes 0 Fail\n\n\n";
break;
case 8 :
cout << " 2 Succes 0 Fail\n\n\n";
break;
}
if(player.king==1){
cout << " A A A \n";
cout << " %%%%% \n";
}
else if(bot1.king==1){
cout << " A A A \n";
cout << " %%%%% \n";
}
else if(bot2.king==1){
cout << " A A A \n";
cout << " %%%%% \n";
}
else if(bot3.king==1){
cout << " A A A \n";
cout << " %%%%% \n";
}
else if(bot4.king==1){
cout << " A A A \n";
cout << " %%%%% \n";
}
else if(bot5.king==1){
cout << " A A A \n";
cout << " %%%%% \n";
}
else if(bot6.king==1){
cout << " A A A \n";
cout << " %%%%% \n";
}
else if(bot7.king==1){
cout << " A A A \n";
cout << " %%%%% \n";
}
switch (players){
case 5 :
cout << " ::::::: >:::::::< >:::::::< ::::::: ::::::: \n";
cout << " : YOU : >: B-1 :< >: B-2 :< : B-3 : : B-4 : \n";
cout << " ::::::: >:::::::< >:::::::< ::::::: ::::::: \n\n\n";
break;
case 6 :
cout << " ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: \n";
cout << " : YOU : : B-1 : : B-2 : : B-3 : : B-4 : : B-5 : \n";
cout << " ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: \n\n\n";
break;
case 7 :
cout << " ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: \n";
cout << " : YOU : : B-1 : : B-2 : : B-3 : : B-4 : : B-5 : : B-6 : \n";
cout << " ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: \n\n\n";
break;
case 8 :
cout << " ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: \n";
cout << " : YOU : : B-1 : : B-2 : : B-3 : : B-4 : : B-5 : : B-6 : : B-7 : \n";
cout << " ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: ::::::: \n\n\n";
break;
}
do{
if(player.king ==1){
int chooseplayer1,chooseplayer2,chooseplayer3;
cout << "choose other player to the misson ";
cin >> chooseplayer1;
cout << "and ";
cin >> chooseplayer2;
if(chooseplayer1 == 1|| chooseplayer2 == 1) {
player.quest =1;
}
if(chooseplayer1 == 2|| chooseplayer2 == 2) {
bot1.quest =1;
}
if(chooseplayer1 == 3|| chooseplayer2 == 3) {
bot2.quest =1;
}
if(chooseplayer1 == 4|| chooseplayer2 == 4) {
bot3.quest =1;
}
if(chooseplayer1 == 5|| chooseplayer2 == 5) {
bot4.quest =1;
}
cout << "These are player to misson \n";
if(bot1.quest==1){
cout << "bot1 \n";
}
if(bot2.quest==1){
cout << "bot2 \n";
}
if(bot3.quest==1){
cout << "bot3 \n";
}
if(bot4.quest==1){
cout << "bot4 \n";
}
if(bot5.quest==1){
cout << "bot5 \n" ;
}
if(bot6.quest==1){
cout << "bot6 \n";
}
if(bot7.quest==1){
cout << "bot7 \n";
}
cout << "Approve or Decline?? \n";
cout << "The vote is ";
if(bot1.quest==1){
bot1.approve=1;
if(bot1.side-=-1){
if(bot2.side==-1){
bot2.approve=1;
}
else {
int x1=rand()%2;
if(x1=0){
bot2.approve=1;
}else {
bot2.approve=-1;
}
}
if(bot3.side==-1){
bot3.approve=1;
}
else {
int x2=rand()%2;
if(x2=0){
bot3.approve=1;
}else {
bot3.approve=-1;
}
}
if(bot4.side==-1){
bot4.approve=1;
}
else {
int x3=rand()%2;
if(x3=0){
bot4.approve=1;
}else {
bot4.approve=-1;
}
}
if(bot5.side==-1){
bot5.approve=1;
}
else {
int x4=rand()%2;
if(x4=0){
bot5.approve=1;
}else {
bot5.approve=-1;
}
}
if(bot6.side==-1){
bot6.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot6.approve=1;
}else {
bot6.approve=-1;
}
}
if(bot7.side==-1){
bot7.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot7.approve=1;
}else {
bot7.approve=-1;
}
}
}
else{
int x[8];
for(int i=0;i<8;i++){
x[i]=rand()%3;
if(x[i]>0){
x[i]=1;
}
else{
x[i]=-1;
}
}
bot2.approve=x[0];
bot3.approve=x[1];
bot4.approve=x[2];
bot5.approve=x[3];
bot6.approve=x[4];
bot7.approve=x[5];
} //endl
if(bot2.quest==1){
bot2.approve=1;
if(bot2.side-=-1){
if(bot1.side==-1){
bot1.approve=1;
}
else {
int x1=rand()%2;
if(x1=0){
bot1.approve=1;
}else {
bot1.approve=-1;
}
}
if(bot3.side==-1){
bot3.approve=1;
}
else {
int x2=rand()%2;
if(x2=0){
bot3.approve=1;
}else {
bot3.approve=-1;
}
}
if(bot4.side==-1){
bot4.approve=1;
}
else {
int x3=rand()%2;
if(x3=0){
bot4.approve=1;
}else {
bot4.approve=-1;
}
}
if(bot5.side==-1){
bot5.approve=1;
}
else {
int x4=rand()%2;
if(x4=0){
bot5.approve=1;
}else {
bot5.approve=-1;
}
}
if(bot6.side==-1){
bot6.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot6.approve=1;
}else {
bot6.approve=-1;
}
}
if(bot7.side==-1){
bot7.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot7.approve=1;
}else {
bot7.approve=-1;
}
}
}
else{
int x[8];
for(int i=0;i<8;i++){
x[i]=rand()%3;
if(x[i]>0){
x[i]=1;
}
else{
x[i]=-1;
}
}
bot1.approve=x[0];
bot3.approve=x[1];
bot4.approve=x[2];
bot5.approve=x[3];
bot6.approve=x[4];
bot7.approve=x[5];
} //endl
}
if(bot3.quest==1){
bot3.approve=1;
if(bot3.side-=-1){
if(bot2.side==-1){
bot2.approve=1;
}
else {
int x1=rand()%2;
if(x1=0){
bot2.approve=1;
}else {
bot2.approve=-1;
}
}
if(bot1.side==-1){
bot1.approve=1;
}
else {
int x2=rand()%2;
if(x2=0){
bot1.approve=1;
}else {
bot1.approve=-1;
}
}
if(bot4.side==-1){
bot4.approve=1;
}
else {
int x3=rand()%2;
if(x3=0){
bot4.approve=1;
}else {
bot4.approve=-1;
}
}
if(bot5.side==-1){
bot5.approve=1;
}
else {
int x4=rand()%2;
if(x4=0){
bot5.approve=1;
}else {
bot5.approve=-1;
}
}
if(bot6.side==-1){
bot6.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot6.approve=1;
}else {
bot6.approve=-1;
}
}
if(bot7.side==-1){
bot7.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot7.approve=1;
}else {
bot7.approve=-1;
}
}
}
else{
int x[8];
for(int i=0;i<8;i++){
x[i]=rand()%3;
if(x[i]>0){
x[i]=1;
}
else{
x[i]=-1;
}
}
bot2.approve=x[0];
bot1.approve=x[1];
bot4.approve=x[2];
bot5.approve=x[3];
bot6.approve=x[4];
bot7.approve=x[5];
} //endl
}
if(bot4.quest==1){
bot4.approve=1;
if(bot4.side-=-1){
if(bot2.side==-1){
bot2.approve=1;
}
else {
int x1=rand()%2;
if(x1=0){
bot2.approve=1;
}else {
bot2.approve=-1;
}
}
if(bot3.side==-1){
bot3.approve=1;
}
else {
int x2=rand()%2;
if(x2=0){
bot3.approve=1;
}else {
bot3.approve=-1;
}
}
if(bot1.side==-1){
bot1.approve=1;
}
else {
int x3=rand()%2;
if(x3=0){
bot1.approve=1;
}else {
bot1.approve=-1;
}
}
if(bot5.side==-1){
bot5.approve=1;
}
else {
int x4=rand()%2;
if(x4=0){
bot5.approve=1;
}else {
bot5.approve=-1;
}
}
if(bot6.side==-1){
bot6.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot6.approve=1;
}else {
bot6.approve=-1;
}
}
if(bot7.side==-1){
bot7.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot7.approve=1;
}else {
bot7.approve=-1;
}
}
}
else{
int x[8];
for(int i=0;i<8;i++){
x[i]=rand()%3;
if(x[i]>0){
x[i]=1;
}
else{
x[i]=-1;
}
}
bot2.approve=x[0];
bot3.approve=x[1];
bot1.approve=x[2];
bot5.approve=x[3];
bot6.approve=x[4];
bot7.approve=x[5];
} //endl
}
if(bot5.quest==1){
bot5.approve=1;
if(bot5.side-=-1){
if(bot2.side==-1){
bot2.approve=1;
}
else {
int x1=rand()%2;
if(x1=0){
bot2.approve=1;
}else {
bot2.approve=-1;
}
}
if(bot3.side==-1){
bot3.approve=1;
}
else {
int x2=rand()%2;
if(x2=0){
bot3.approve=1;
}else {
bot3.approve=-1;
}
}
if(bot4.side==-1){
bot4.approve=1;
}
else {
int x3=rand()%2;
if(x3=0){
bot4.approve=1;
}else {
bot4.approve=-1;
}
}
if(bot1.side==-1){
bot1.approve=1;
}
else {
int x4=rand()%2;
if(x4=0){
bot1.approve=1;
}else {
bot1.approve=-1;
}
}
if(bot6.side==-1){
bot6.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot6.approve=1;
}else {
bot6.approve=-1;
}
}
if(bot7.side==-1){
bot7.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot7.approve=1;
}else {
bot7.approve=-1;
}
}
}
else{
int x[8];
for(int i=0;i<8;i++){
x[i]=rand()%3;
if(x[i]>0){
x[i]=1;
}
bot2.approve=x[0];
bot3.approve=x[1];
bot4.approve=x[2];
bot1.approve=x[3];
bot6.approve=x[4];
bot7.approve=x[5];
} //endl
}
}
if(bot6.quest==1){
bot6.approve=1;
if(bot6.side-=-1){
if(bot2.side==-1){
bot2.approve=1;
}
else {
int x1=rand()%2;
if(x1=0){
bot2.approve=1;
}else {
bot2.approve=-1;
}
}
if(bot3.side==-1){
bot3.approve=1;
}
else {
int x2=rand()%2;
if(x2=0){
bot3.approve=1;
}else {
bot3.approve=-1;
}
}
if(bot4.side==-1){
bot4.approve=1;
}
else {
int x3=rand()%2;
if(x3=0){
bot4.approve=1;
}else {
bot4.approve=-1;
}
}
if(bot5.side==-1){
bot5.approve=1;
}
else {
int x4=rand()%2;
if(x4=0){
bot5.approve=1;
}else {
bot5.approve=-1;
}
}
if(bot1.side==-1){
bot1.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot1.approve=1;
}else {
bot1.approve=-1;
}
}
if(bot1.side==-1){
bot7.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot7.approve=1;
}else {
bot7.approve=-1;
}
}
}
else{
int x[8];
for(int i=0;i<8;i++){
x[i]=rand()%3;
if(x[i]>0){
x[i]=1;
}
else{
x[i]=-1;
}
}
bot2.approve=x[0];
bot3.approve=x[1];
bot4.approve=x[2];
bot5.approve=x[3];
bot1.approve=x[4];
bot7.approve=x[5];
} //endl
}
if(bot7.quest==1){
bot7.approve=1;
if(bot7.side-=-1){
if(bot2.side==-1){
bot2.approve=1;
}
else {
int x1=rand()%2;
if(x1=0){
bot2.approve=1;
}else {
bot2.approve=-1;
}
}
if(bot3.side==-1){
bot3.approve=1;
}
else {
int x2=rand()%2;
if(x2=0){
bot3.approve=1;
}else {
bot3.approve=-1;
}
}
if(bot4.side==-1){
bot4.approve=1;
}
else {
int x3=rand()%2;
if(x3=0){
bot4.approve=1;
}else {
bot4.approve=-1;
}
}
if(bot5.side==-1){
bot5.approve=1;
}
else {
int x4=rand()%2;
if(x4=0){
bot5.approve=1;
}else {
bot5.approve=-1;
}
}
if(bot6.side==-1){
bot6.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot6.approve=1;
}else {
bot6.approve=-1;
}
}if(bot1.side==-1){
bot1.approve=1;
}
else {
int x5=rand()%2;
if(x5=0){
bot1.approve=1;
}else {
bot1.approve=-1;
}
}
}
else{
int x[8];
for(int i=0;i<8;i++){
x[i]=rand()%3;
if(x[i]>0){
x[i]=1;
}
else{
x[i]=-1;
}
}
bot2.approve=x[0];
bot3.approve=x[1];
bot4.approve=x[2];
bot5.approve=x[3];
bot6.approve=x[4];
bot1.approve=x[5];
} //endl
}
}
}//player is king
else if(bot1.king ==1){
vector<int> random;
int temp=99;
if(system.checkturn==1){
for(int i=0 ;i<2 ;i++) {
int random=rand()%players +1;
while(temp==random){
random=rand()%players +1;
}
if(random ==1) player.quest=1;
else if(random ==2) bot2.quest=1;
else if(random ==3) bot3.quest=1;
else if(random ==4) bot4.quest=1;
temp=random;
}
}
else{
if(bot1.side==-1){
for(int i=0;i<2;i++){
int temp=3 ;
int random=rand()%2;
while(random==temp){
random=rand()%2;
}
if(random==1){
if(bot2.side==-1) bot2.quest==1 ;
else if(bot3.side==-1) bot3.quest==1;
if(bot4.side==-1) bot4.quest==1;
else if (player.side==-1) player.quest==1;
}
else {
if(bot2.side==-1) bot2.quest==-1;
else if(bot3.side==-1) bot3.quest==-1;
if(bot4.side==-1) bot4.quest==-1;
else if (player.side==-1) player.quest==-1;
}
temp=random;
}
}
else{ //bot is good side
int random=0;
if(system.checkturn==1 || system.checkturn ==2){
for(int i=0;i<2;i++){
while(random==temp){
random =rand()%players;
}
if(random==1){
bot2.quest=1;
}
else if(random==2){
bot3.quest=1;
}
else if(random==3){
bot4.quest=1;
}
else if(random==4){
player.quest=1;
}
int temp =random;
}
}
else{
int temp=0;
for(int l=0 ; l<1 ; l++){
int i=rand()%bot2.doubt;
int j=rand()%bot3.doubt;
int k=rand()%bot4.doubt;
int m=rand()%player.doubt;
vector<int> doubltofall;
doubltofall.push_back(i);
doubltofall.push_back(j);
doubltofall.push_back(k);
doubltofall.push_back(m);
int min=999;
for(int i=0;i<doubltofall.size();i++){
if(doubltofall[i]<min){
min=doubltofall[i];
}
if(min=i){bot2.quest =1; temp++; }
else if(min=j) {bot3.quest =1 ; temp++;}
else if(min=k) {bot4.quest =1 ;temp++; }
else if(min=m){player.quest =1; temp++; }
if(temp==2){
if(player.quest==0) {player.quest=1;
}
else {bot2.quest=1;
}
temp--;
}
}
}
}
}
}
}
else if(bot2.king ==1){
vector<int> random;
int temp=99;
if(system.checkturn==1){
for(int i=0 ;i<2 ;i++) {
int random=rand()%players +1;
while(temp==random){
random=rand()%players +1;
}
if(random ==1) player.quest=1;
else if(random ==2) bot1 .quest=1;
else if(random ==3) bot3.quest=1;
else if(random ==4) bot4.quest=1;
temp=random;
}
}
else{
if(bot2.side==-1){
for(int i=0;i<2;i++){
int temp=3 ;
int random=rand()%2;
while(random==temp){
random=rand()%2;
}
if(random==1){
if(bot1.side==-1) bot1.quest==1 ;
else if(bot3.side==-1) bot3.quest==1;
if(bot4.side==-1) bot4.quest==1;
else if (player.side==-1) player.quest==1;
}
else {
if(bot1.side==-1) bot1.quest==-1;
else if(bot3.side==-1) bot3.quest==-1;
if(bot4.side==-1) bot4.quest==-1;
else if (player.side==-1) player.quest==-1;
}
temp=random;
}
}
else{ //bot is good side
int random=0;
if(system.checkturn==1 || system.checkturn ==2){
for(int i=0;i<2;i++){
while(random==temp){
random =rand()%players;
}
if(random==1){
bot1.quest=1;
}
else if(random==2){
bot3.quest=1;
}
else if(random==3){
bot4.quest=1;
}
else if(random==4){
player.quest=1;
}
int temp =random;
}
}
else{
int temp=0;
for(int l=0 ; l<1 ; l++){
int i=rand()%bot1.doubt;
int j=rand()%bot3.doubt;
int k=rand()%bot4.doubt;
int m=rand()%player.doubt;
vector<int> doubltofall;
doubltofall.push_back(i);
doubltofall.push_back(j);
doubltofall.push_back(k);
doubltofall.push_back(m);
int min=999;
for(int i=0;i<doubltofall.size();i++){
if(doubltofall[i]<min){
min=doubltofall[i];
}
if(min=i){bot1.quest =1; temp++; }
else if(min=j) {bot3.quest =1 ; temp++;}
else if(min=k) {bot4.quest =1 ;temp++; }
else if(min=m){player.quest =1; temp++; }
if(temp==2){
if(player.quest==0) {player.quest=1;
}
else {bot1.quest=1;
}
temp--;
}
}
}
}
}
}
}
else if(bot3.king ==1){
vector<int> random;
int temp=99;
if(system.checkturn==1){
for(int i=0 ;i<2 ;i++) {
int random=rand()%players +1;
while(temp==random){
random=rand()%players +1;
}
if(random ==1) player.quest=1;
else if(random ==2) bot1 .quest=1;
else if(random ==3) bot2.quest=1;
else if(random ==4) bot4.quest=1;
temp=random;
}
}
else{
if(bot3.side==-1){
for(int i=0;i<2;i++){
int temp=3 ;
int random=rand()%2;
while(random==temp){
random=rand()%2;
}
if(random==1){
if(bot1.side==-1) bot1.quest==1 ;
else if(bot2.side==-1) bot2.quest==1;
if(bot4.side==-1) bot4.quest==1;
else if (player.side==-1) player.quest==1;
}
else {
if(bot1.side==-1) bot1.quest==-1;
else if(bot2.side==-1) bot2.quest==-1;
if(bot4.side==-1) bot4.quest==-1;
else if (player.side==-1) player.quest==-1;
}
temp=random;
}
}
else{ //bot is good side
int random=0;
if(system.checkturn==1 || system.checkturn ==2){
for(int i=0;i<2;i++){
while(random==temp){
random =rand()%players;
}
if(random==1){
bot1.quest=1;
}
else if(random==2){
bot2.quest=1;
}
else if(random==3){
bot4.quest=1;
}
else if(random==4){
player.quest=1;
}
int temp =random;
}
}
else{
int temp=0;
for(int l=0 ; l<1 ; l++){
int i=rand()%bot1.doubt;
int j=rand()%bot2.doubt;
int k=rand()%bot4.doubt;
int m=rand()%player.doubt;
vector<int> doubltofall;
doubltofall.push_back(i);
doubltofall.push_back(j);
doubltofall.push_back(k);
doubltofall.push_back(m);
int min=999;
for(int i=0;i<doubltofall.size();i++){
if(doubltofall[i]<min){
min=doubltofall[i];
}
if(min=i){bot1.quest =1; temp++; }
else if(min=j) {bot2.quest =1 ; temp++;}
else if(min=k) {bot4.quest =1 ;temp++; }
else if(min=m){player.quest =1; temp++; }
if(temp==2){
if(player.quest==0) {player.quest=1;
}
else {bot4.quest=1;
}
temp--;
}
}
}
}
}
}
}
else if(bot4.king ==1){
vector<int> random;
int temp=99;
if(system.checkturn==1){
for(int i=0 ;i<2 ;i++) {
int random=rand()%players +1;
while(temp==random){
random=rand()%players +1;
}
if(random ==1) player.quest=1;
else if(random ==2) bot2.quest=1;
else if(random ==3) bot3.quest=1;
else if(random ==4) bot1.quest=1;
temp=random;
}
}
else{
if(bot4.side==-1){
for(int i=0;i<2;i++){
int temp=3 ;
int random=rand()%2;
while(random==temp){
random=rand()%2;
}
if(random==1){
if(bot2.side==-1) bot2.quest==1 ;
else if(bot3.side==-1) bot3.quest==1;
if(bot1.side==-1) bot1.quest==1;
else if (player.side==-1) player.quest==1;
}
else {
if(bot2.side==-1) bot2.quest==-1;
else if(bot3.side==-1) bot3.quest==-1;
if(bot1.side==-1) bot1.quest==-1;
else if (player.side==-1) player.quest==-1;
}
temp=random;
}
}
else{ //bot is good side
int random=0;
if(system.checkturn==1 || system.checkturn ==2){
for(int i=0;i<2;i++){
while(random==temp){
random =rand()%players;
}
if(random==1){
bot2.quest=1;
}
else if(random==2){
bot3.quest=1;
}
else if(random==3){
bot1.quest=1;
}
else if(random==4){
player.quest=1;
}
int temp =random;
}
}
else{
int temp=0;
for(int l=0 ; l<1 ; l++){
int i=rand()%bot2.doubt;
int j=rand()%bot3.doubt;
int k=rand()%bot1.doubt;
int m=rand()%player.doubt;
vector<int> doubltofall;
doubltofall.push_back(i);
doubltofall.push_back(j);
doubltofall.push_back(k);
doubltofall.push_back(m);
int min=999;
for(int i=0;i<doubltofall.size();i++){
if(doubltofall[i]<min){
min=doubltofall[i];
}
if(min=i){bot2.quest =1; temp++; }
else if(min=j) {bot3.quest =1 ; temp++;}
else if(min=k) {bot1.quest =1 ;temp++; }
else if(min=m){player.quest =1; temp++; }
if(temp==2){
if(player.quest==0) {player.quest=1;
}
else {bot3.quest=1;
}
temp--;
}
}
}
}
}
}
}
//left bot2,3,4,5,6,7,8 is king case
int sum=0;
if(player.king=1){
if(players==5) sum=bot1.approve+bot2.approve+bot3.approve+bot4.approve;
if(players==6) sum=bot1.approve+bot2.approve+bot3.approve+bot4.approve+bot5.approve;
if(players==7) sum=bot1.approve+bot2.approve+bot3.approve+bot4.approve+bot5.approve+bot6.approve;
if(players==8) sum=bot1.approve+bot2.approve+bot3.approve+bot4.approve+bot5.approve+bot6.approve+bot7.approve;
}
if(sum>=0){
cout << "Approve !!! \n";
system.approve=1;
srand(time(0));
sum=0;
break;
}
else{
cout<< "Decline !!! \n";
system.decline ++;
player.quest=0;
bot1.quest=0;
bot2.quest=0;
bot3.quest=0;
bot4.quest=0;
bot5.quest=0;
bot6.quest=0;
bot7.quest=0;
sum=0;
srand(time(0));
}
if(system.decline ==5){
score[system.checkturn]="Fail";
player.quest=0;
bot1.quest=0;
bot2.quest=0;
bot3.quest=0;
bot4.quest=0;
bot5.quest=0;
bot6.quest=0;
bot7.quest=0;
sum=0;
srand(time(0));
break;
}
sum=0;
}while(true);
int vote=1;
if(player.quest==1){
if(player.side == 1){
vote*=1;
cout << "You've been chosen to the mission of glory.\n";
cout << "You vote success\n";
}
else if(player.side == -1){
int x;
cout << "You've been chosen to the mission of glory.\n";
cout << "Select [1] Success [2] Fail : ";
cin >> x;
if(x == 1){
vote*=1;
}else if(x == 2){
vote*-1;
}
}
cin.ignore();
}
else if(bot1.quest==1){
if(bot1.side==-1){
if(system.checkturn==1){
vote*=-1;
}
else{
int random=rand()%5;
if(random>1){
vote*=-1;
bot1.doubt =5;
}else {
vote*=1;
}
}
}
else if(bot1.side==1){
vote*=1;
}
}
else if(bot2.quest==1){
if(bot2.side==-1){
if(system.checkturn==1){
vote*=-1;
}
else{
int random=rand()%5;
if(random>1){
vote*=-1;
bot2.doubt =5;
}else {
vote*=1;
}
}
}
else if(bot2.side==1){
vote*=1;
}
}
else if(bot3.quest==1){
if(bot3.side==-1){
if(system.checkturn==1){
vote*=-1;
}
else{
int random=rand()%5;
if(random>1){
vote*=-1;
bot3.doubt =5;
}else {
vote*=1;
}
}
}
else if(bot3.side==1){
vote*=1;
}
}
else if(bot4.quest==1){
if(bot4.side==-1){
if(system.checkturn==1){
vote*=-1;
}
else{
int random=rand()%5;
if(random>1){
vote*=-1;
bot4.doubt =5;
}else {
vote*=1;
}
}
}
else if(bot4.side==1){
vote*=1;
}
}
else if(bot5.quest==1){
if(bot5.side==-1){
if(system.checkturn==1){
vote*=-1;
}
else{
int random=rand()%5;
if(random>1){
vote*=-1;
bot5.doubt =5;
}else {
vote*=1;
}
}
}
else if(bot5.side==1){
vote*=1;
}
}
else if(bot6.quest==1){
if(bot6.side==-1){
if(system.checkturn==1){
vote*=1;
}
else{
int random=rand()%5;
if(random>1){
vote*=-1;
bot6.doubt =5;
}else {
vote*=1;
}
}
}
else if(bot6.side==1){
vote*=1;
}
}
else if(bot7.quest==1){
if(bot7.side==-1){
if(system.checkturn==1){
vote*=1;
}
else{
int random=rand()%5;
if(random>1){
vote*=-1;
bot7.doubt =5;
}else {
vote*=1;
}
}
}
else if(bot7.side==1){
vote*=1;
}
}
if(vote==1 && system.decline!=5){
cout << "mission SUCCESS !! \n";
}
else{
cout << "mission FAIL !! \n";
}
srand(time(0));
vote=0;
system.checkturn++;
player.quest=0;
bot1.quest=0;
bot2.quest=0;
bot3.quest=0;
bot4.quest=0;
bot5.quest=0;
}
do{
switch (players){
case 5 :
cout << " Please choose the action \"1\" or \"2\" : ";
break;
case 6 :
cout << " Please choose the action \"1\" or \"2\" : ";
break;
case 7 :
cout << " Please choose the action \"1\" or \"2\" : ";
break;
case 8 :
cout << " Please choose the action \"1\" or \"2\" : ";
break;
}
getline(cin,action);
if(action == "1" || action == "2") break;
}while(true);
//send king to the next person
//put the oop turn
//checkscore for map
switch (players){
case 5 :
cout << "\n\n\n################################################################### \n";
cout << "##••-- --••## \n";
cout << "##••-- YOU WIN --••## \n";
cout << "##••-- --••## \n";
cout << "###################################################################\n\n";
break;
case 6 :
cout << "\n\n\n############################################################################### \n";
cout << "##••-- --••## \n";
cout << "##••-- YOU WIN --••## \n";
cout << "##••-- --••## \n";
cout << "###############################################################################\n\n";
break;
case 7 :
cout << "\n\n\n########################################################################################### \n";
cout << "##••-- --••## \n";
cout << "##••-- YOU WIN --••## \n";
cout << "##••-- --••## \n";
cout << "###########################################################################################\n\n";
break;
case 8 :
cout << "\n\n\n####################################################################################################### \n";
cout << "##••-- --••## \n";
cout << "##••-- YOU WIN --••## \n";
cout << "##••-- --••## \n";
cout << "#######################################################################################################\n\n";
break;
}
/*switch (players){
case 5 :
cout << "\n\n\n################################################################### \n";
cout << "##••-- --••## \n";
cout << "##••-- YOU LOSE! --••## \n";
cout << "##••-- --••## \n";
cout << "###################################################################\n\n";
break;
case 6 :
cout << "\n\n\n############################################################################### \n";
cout << "##••-- --••## \n";
cout << "##••-- YOU LOSE! --••## \n";
cout << "##••-- --••## \n";
cout << "###############################################################################\n\n";
break;
case 7 :
cout << "\n\n\n########################################################################################### \n";
cout << "##••-- --••## \n";
cout << "##••-- YOU LOSE! --••## \n";
cout << "##••-- --••## \n";
cout << "###########################################################################################\n\n";
break;
case 8 :
cout << "\n\n\n####################################################################################################### \n";
cout << "##••-- --••## \n";
cout << "##••-- YOU LOSE! --••## \n";
cout << "##••-- --••## \n";
cout << "#######################################################################################################\n\n";
break;
}*/
}
//exit
else if(action == "2") cout << "\n • Bye Bye • \n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment