//Variable Declarations
String spaces[72];
String O[4];
String X[4];
String W[4];
String M[4];
String Player1Name="";
int Player1Points=0;
String Player2Name="";
int Player2Points=0;
String Player3Name="";
int Player3Points=0;
String Player4Name="";
int Player4Points=0;
String choice="";
String Place="Place";
String Move="Move";
int O1;
int O2;
int O3;
int O4;
int X1;
int X2;
int X3;
int X4;
int W1;
int W2;
int W3;
int W4;
int M1;
int M2;
int M3;
int M4;
int pointlessNumber;
int diceRoll=0;
//Declaring what is in the arrays
void setup()
{
Serial.begin(9600);
for(int x=0;x<63;x++){
spaces[x]="_";
}
for(int x=63;x<72;x++){
spaces[x]=" ";
}
for(int x=0;x<4;x++){
O[x]="O";
}
for(int x=0;x<4;x++){
X[x]="X";
}
for(int x=0;x<4;x++){
W[x]="W";
}
for(int x=0;x<4;x++){
M[x]="M";
}
randomSeed(analogRead(0));
//Player 1 Name Declaration
Serial.println("Player 1! What is your name!(Your name is permanent so be careful in choosing!)");
while(Serial.available()>0){
Serial.readString();
}
while (Serial.available() == 0){}
Player1Name=Serial.readString();
//Player 2 Name Declaration
Serial.println("Player 2! What is your name!(Your name is permanent so be careful in choosing!)");
while(Serial.available()>0){
Serial.readString();
}
while (Serial.available() == 0){}
Player2Name=Serial.readString();
//Player 3 Name Declaration
Serial.println("Player 3! What is your name!(Your name is permanent so be careful in choosing!)");
while(Serial.available()>0){
Serial.readString();
}
while (Serial.available() == 0){}
Player3Name=Serial.readString();
//Player 4 Name Declaration
Serial.println("Player 4! What is your name!(Your name is permanent so be careful in choosing!)");
while(Serial.available()>0){
Serial.readString();
}
while (Serial.available() == 0){}
Player4Name=Serial.readString();
//Rules
Serial.println("Now it's time to explain the rules, and even if you know how to play ludo, you should still listen. We have normal ludo rules, to get a piece out of your home area and onto the board you must roll a 6, if you roll any number, you can move any piece on the board. To win you must get all 4 pieces around the whole board and through the middle on your end(These are your sides that will be defined in a bit). The only changes to the rules is that instead of your piece going back to base when another piece lands on it, your piece will go invisible until you next move it when a piece moves over it. Another special rule, when you move a piece you have a 1 in 100 chance to go back to the start. The very last change that has happened is that with a false input your wonderful turn... will be skipped, so remember where your pieces are. Good luck and have fun and remember to live, laugh, love! :D");
delay(12000);
//Setting players up
Serial.println("O (" + Player1Name + ") is on the Bottom, X (" + Player2Name + ") is on the Right, W (" + Player3Name + ") is on the Top, M (" + Player4Name + ") is on the Left");
}
void loop()
{
while(Player1Points!=4||Player2Points!=4||Player3Points!=4||Player4Points!=4){
//Player 1 Turn
map(); //Map
delay(1000);
Serial.println(Player1Name + " Go!");
Serial.println("How many times do you shake the dice?");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
pointlessNumber=Serial.parseInt();//Doesn't impact anything, just here so the player feels they do something to impact the dice roll
diceRoll=random(1,7);
Serial.println("You got a " + String(diceRoll) + "!");
if(diceRoll==6)//determines whether they can spawn a piece or not
{
Serial.println("Would you like to place a piece on the board or move a piece?(Type Place or Move)");
while(Serial.available()>0){
Serial.readString();
}
while (Serial.available() == 0){}
choice=Serial.readString();
if(choice==Place){
getOutOfSpawnO();
}
else if(choice==Move){
if(O[0]==" " || O[1]==" " || O[2]==" " || O[3]==" "){
movePieceO();
}
else{
Serial.println("You have nothing to move :( You can take a piece out instead");
getOutOfSpawnO();
}
}
else{
Serial.println("Due to you trying to be funny I will just skip your turn. No messing around here.");//if the player has no pieces their turn is skipped
}
}
else if(diceRoll!=6)
{
if(O[0]==" " || O[1]==" " || O[2]==" " || O[3]==" "){
movePieceO();
}
else{
Serial.println("Unfortunately you have nothing to do on your turn as you have no pieces on the board:(");
}
}
//Player 2 Turn
map();
delay(1000);
Serial.println(Player2Name + " Go!");
Serial.println("How many times do you shake the dice?");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
pointlessNumber=Serial.parseInt();
diceRoll=random(1,7);;
Serial.println("You got a " + String(diceRoll) + "!");
if(diceRoll==6)
{
Serial.println("Would you like to place a piece on the board or move a piece?(Type Place or Move)");
while(Serial.available()>0){
Serial.readString();
}
while (Serial.available() == 0){}
choice=Serial.readString();
if(choice==Place){
getOutOfSpawnX();
}
else if(choice==Move){
if(X[0]==" " || X[1]==" " || X[2]==" " || X[3]==" "){
movePieceX();
}
else{
Serial.println("You have nothing to move :( You can take a piece out instead");
getOutOfSpawnX();
}
}
else{
Serial.println("Due to you trying to be funny I will just skip your turn. No messing around here.");
}
}
else if(diceRoll!=6)
{
if(X[0]==" " || X[1]==" " || X[2]==" " || X[3]==" "){
movePieceX();
}
else{
Serial.println("Unfortunately you have nothing to do on your turn as you have no pieces on the board:(");
}
}
//Player 3 Turn
map();
delay(1000);
Serial.println(Player3Name + " Go!");
Serial.println("How many times do you shake the dice?");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
pointlessNumber=Serial.parseInt();
diceRoll=random(1,7);;
Serial.println("You got a " + String(diceRoll) + "!");
if(diceRoll==6)
{
Serial.println("Would you like to place a piece on the board or move a piece?(Type Place or Move)");
while(Serial.available()>0){
Serial.readString();
}
while (Serial.available() == 0){}
choice=Serial.readString();
if(choice==Place){
getOutOfSpawnW();
}
else if(choice==Move){
if(W[0]==" " || W[1]==" " || W[2]==" " || W[3]==" "){
movePieceW();
}
else{
Serial.println("You have nothing to move :( You can take a piece out instead");
getOutOfSpawnW();
}
}
else{
Serial.println("Due to you trying to be funny I will just skip your turn. No messing around here.");
}
}
else if(diceRoll!=6)
{
if(W[0]==" " || W[1]==" " || W[2]==" " || W[3]==" "){
movePieceW();
}
else{
Serial.println("Unfortunately you have nothing to do on your turn as you have no pieces on the board:(");
}
}
//Player 4 Turn
map();
delay(1000);
Serial.println(Player4Name + " Go!");
Serial.println("How many times do you shake the dice?");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
pointlessNumber=Serial.parseInt();
diceRoll=random(1,7);;
Serial.println("You got a " + String(diceRoll) + "!");
if(diceRoll==6)
{
Serial.println("Would you like to place a piece on the board or move a piece?(Type Place or Move)");
while(Serial.available()>0){
Serial.readString();
}
while (Serial.available() == 0){}
choice=Serial.readString();
if(choice==Place){
getOutOfSpawnM();
}
else if(choice==Move){
if(M[0]==" " || M[1]==" " || M[2]==" " || M[3]==" "){
movePieceM();
}
else{
Serial.println("You have nothing to move :( You can take a piece out instead");
getOutOfSpawnM();
}
}
else{
Serial.println("Due to you trying to be funny I will just skip your turn. No messing around here.");
}
}
else if(diceRoll!=6)
{
if(M[0]==" " || M[1]==" " || M[2]==" " || M[3]==" "){
movePieceM();
}
else{
Serial.println("Unfortunately you have nothing to do on your turn as you have no pieces on the board:(");
}
}
}
if(Player1Points==4){
Serial.println(Player1Name + " Won!");
}
}
void map()//map declaration
{
Serial.println(Player1Name + " has " + String(Player1Points) + " points, " + Player2Name + " has " + String(Player2Points) + " points, " + Player3Name + " has " + String(Player3Points) + " points, " + Player4Name + " has " + String(Player4Points) + " points.");
Serial.println(" _ _ _");
Serial.println(" _ _ _ _ |" + spaces[23] + "|" + spaces[24] + "|" + spaces[25] + "| _ _ _ _ ");
Serial.println(" | | |" + spaces[22] + "|" + spaces[67] + "|" + spaces[26] + "| | |");
Serial.println(" | " + M[0] + " " + M[1] + " | |" + spaces[21] + "|" + spaces[68] + "|" + spaces[27] + "| | " + W[0] + " " + W[1] + " |");
Serial.println(" | " + M[2] + " " + M[3] + " | |" + spaces[20] + "|" + spaces[69] + "|" + spaces[28] + "| | " + W[2] + " " + W[3] + " |");
Serial.println(" |_ _ _ _| |" + spaces[19] + "|" + spaces[70] + "|" + spaces[29] + "| |_ _ _ _|");
Serial.println(" _ _ _ _ _ _|" + spaces[18] + "|" + spaces[71] + "|" + spaces[30] + "|_ _ _ _ _ _");
Serial.println("|" + spaces[12] + "|" + spaces[13] + "|" + spaces[14] + "|" + spaces[15] + "|" + spaces[16] + "|" + spaces[17] + "| |" + spaces[31] + "|" + spaces[32] + "|" + spaces[33] + "|" + spaces[34] + "|" + spaces[35] + "|" + spaces[36] + "|");
Serial.println("|" + spaces[11] + "|" + spaces[52] + " " + spaces[53] + " " + spaces[54] + " " + spaces[55] + " " + spaces[56] + " " + spaces[61] + " " + spaces[60] + " " + spaces[59] + " " + spaces[58] + " " + spaces[57] + "|" + spaces[37] + "|");
Serial.println("|" + spaces[10] + "|" + spaces[9] + "|" + spaces[8] + "|" + spaces[7] + "|" + spaces[6] + "|" + spaces[5] + "|_ _|" + spaces[43] + "|" + spaces[42] + "|" + spaces[41] + "|" + spaces[40] + "|" + spaces[39] + "|" + spaces[38] + "|");
Serial.println(" _ _ _ _ |" + spaces[4] + "|" + spaces[66] + "|" + spaces[44] + "| _ _ _ _ ");
Serial.println(" | | |" + spaces[3] + "|" + spaces[65] + "|" + spaces[45] + "| | | ");
Serial.println(" | " + O[0] + " " + O[1] + " | |" + spaces[2] + "|" + spaces[64] + "|" + spaces[46] + "| | " + X[0] + " " + X[1] + " | ");
Serial.println(" | " + O[2] + " " + O[3] + " | |" + spaces[1] + "|" + spaces[63] + "|" + spaces[47] + "| | " + X[2] + " " + X[3] + " | ");
Serial.println(" |_ _ _ _| |" + spaces[0] + "|" + spaces[62] + "|" + spaces[48] + "| |_ _ _ _| ");
Serial.println(" |" + spaces[51] + "|" + spaces[50] + "|" + spaces[49] + "|");
}
void getOutOfSpawnO()
{
Serial.println("Which piece would you like to move out of spawn?");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
int number=Serial.parseInt();
number=number-1;
if(spaces[0]!="O"){//determines which piece to move out of spawn
if(number==0 && O[0]=="O"){
O1=0;
O[number]=" ";
spaces[0]="O";
}
else if(number==1 && O[1]=="O"){
O2=0;
O[number]=" ";
spaces[0]="O";
}
else if(number==2 && O[2]=="O"){
O3=0;
O[number]=" ";
spaces[0]="O";
}
else if(number==3 && O[3]=="O"){
O4=0;
O[number]=" ";
spaces[0]="O";
}
else
{
Serial.println("Due to you trying to be a funny guy you lost your turn! Hope you thought it was funny cause you skipped your placement!");
}
}
else{
Serial.println("You already have a piece at the starting line, please move that piece before taking another one out of spawn.");
}
}
void movePieceO()//determines which piece you wanna move and how many spaces to move while also determining if you have to move past a certain square that isn't as easy as just adding the roll to the space number(ex. If you need to move a piece from 51 to 0 (as it is apart of the circle and is where the numbers go around again.)) This is the same for all other loops that follow, just simply changing numbers and variables to correspond with the start areas and pieces.
{
Serial.println("Which of the pieces on the board would you like to move?(Caution! If you input a incorrect number your turn will be skipped)");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
int number=Serial.parseInt();
if(number==1 && O[0]==" "){
for(int x=0;x<diceRoll;x++)
{
if(O1==50){
spaces[O1]="_";
O1=62;
spaces[O1]="O";
}
else if(O1==66){
spaces[O1]="_";
O1=100;
Player1Points=Player1Points+1;
}
else if(O1==100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[O1]="_";
O1=O1+1;
spaces[O1]="O";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[O1]="_";
O[0]="O";
}
}
else if(number==2 && O[1]==" "){
for(int x=0;x<diceRoll;x++)
{
if(O2==50){
spaces[O2]="_";
O2=62;
spaces[O2]="O";
}
else if(O2==66){
spaces[O2]="_";
O2=100;
Player1Points=Player1Points+1;
}
else if(O2==100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[O2]="_";
O2=O2+1;
spaces[O2]="O";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[O2]="_";
O[1]="O";
}
}
else if(number==3 && O[2]==" "){
for(int x=0;x<diceRoll;x++)
{
if(O3==50){
spaces[O3]="_";
O3=62;
spaces[O3]="O";
}
else if(O3==66){
spaces[O3]="_";
O3=100;
Player1Points=Player1Points+1;
}
else if(O3==100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[O3]="_";
O3=O3+1;
spaces[O3]="O";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[O3]="_";
O[2]="O";
}
}
else if(number==4 && O[3]==" "){
for(int x=0;x<diceRoll;x++)
{
if(O4==50){
spaces[O4]="_";
O4=62;
spaces[O4]="O";
}
else if(O4==66){
spaces[O4]="_";
O4=100;
Player1Points=Player1Points+1;
}
else if(O4==100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[O4]="_";
O4=O4+1;
spaces[O4]="O";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[O4]="_";
O[3]="O";
}
}
else
{
Serial.println("What did I tell you!? You're losing your turn now.");
}
}
void getOutOfSpawnX()
{
Serial.println("Which piece would you like to move out of spawn?");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
int number=Serial.parseInt();
number=number-1;
if(spaces[39]!="X"){
if(number==0 && X[0]=="X"){
X1=39;
X[number]=" ";
spaces[39]="X";
}
else if(number==1 && X[1]=="X"){
X2=39;
X[number]=" ";
spaces[39]="X";
}
else if(number==2 && X[2]=="X"){
X3=39;
X[number]=" ";
spaces[39]="X";
}
else if(number==3 && X[3]=="X"){
X4=39;
X[number]=" ";
spaces[39]="X";
}
else
{
Serial.println("Due to you trying to be a funny guy you lost your turn! Hope you thought it was funny cause you skipped your placement!");
}
}
else{
Serial.println("You already have a piece at the starting line, please move that piece before taking another one out of spawn.");
}
}
void movePieceX()
{
Serial.println("Which of the pieces on the board would you like to move?(Caution! If you input a incorrect number your turn will be skipped)");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
int number=Serial.parseInt();
if(number==1 && X[0]==" "){
for(int x=0;x<diceRoll;x++)
{
if(X1==51){
spaces[X1]="_";
X1=0;
spaces[X1]="X";
}
else if(X1==37){
spaces[X1]="_";
X1=57;
spaces[X1]="X";
}
else if(X1==61){
spaces[X1]="_";
X1=100;
Player2Points=Player2Points+1;
}
else if(X1=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[X1]="_";
X1=X1+1;
spaces[X1]="X";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[X1]="_";
X[0]="X";
}
}
else if(number==2 && X[1]==" "){
for(int x=0;x<diceRoll;x++)
{
if(X2==51){
spaces[X2]="_";
X2=0;
spaces[X2]="X";
}
else if(X2==37){
spaces[X2]="_";
X2=57;
spaces[X2]="X";
}
else if(X2==61){
spaces[X2]="_";
X2=100;
Player2Points=Player2Points+1;
}
else if(X2=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[X2]="_";
X2=X2+1;
spaces[X2]="X";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[X2]="_";
X[1]="X";
}
}
else if(number==3 && X[2]==" "){
for(int x=0;x<diceRoll;x++)
{
if(X3==51){
spaces[X3]="_";
X3=0;
spaces[X3]="X";
}
else if(X3==37){
spaces[X3]="_";
X3=57;
spaces[X3]="X";
}
else if(X3==61){
spaces[X3]="_";
X3=100;
Player2Points=Player2Points+1;
}
else if(X3=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[X3]="_";
X3=X3+1;
spaces[X3]="X";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[X3]="_";
X[2]="X";
}
}
else if(number==4 && X[3]==" "){
for(int x=0;x<diceRoll;x++)
{
if(X4==51){
spaces[X4]="_";
X4=0;
spaces[X4]="X";
}
else if(X4==37){
spaces[X4]="_";
X4=57;
spaces[X4]="X";
}
else if(X4==61){
spaces[X4]="_";
X4=100;
Player2Points=Player2Points+1;
}
else if(X4=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[X4]="_";
X4=X4+1;
spaces[X4]="X";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[X4]="_";
X[3]="X";
}
}
else
{
Serial.println("What did I tell you!? You're losing your turn now.");
}
}
void getOutOfSpawnW()
{
Serial.println("Which piece would you like to move out of spawn?");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
int number=Serial.parseInt();
number=number-1;
if(spaces[26]!="W"){
if(number==0 && W[0]=="W"){
W1=26;
W[number]=" ";
spaces[26]="W";
}
else if(number==1 && W[1]=="W"){
W2=26;
W[number]=" ";
spaces[26]="W";
}
else if(number==2 && W[2]=="W"){
W3=26;
W[number]=" ";
spaces[26]="W";
}
else if(number==3 && W[3]=="W"){
W4=26;
W[number]=" ";
spaces[26]="W";
}
else
{
Serial.println("Due to you trying to be a funny guy you lost your turn! Hope you thought it was funny cause you skipped your placement!");
}
}
else{
Serial.println("You already have a piece at the starting line, please move that piece before taking another one out of spawn.");
}
}
void movePieceW()
{
Serial.println("Which of the pieces on the board would you like to move?(Caution! If you input a incorrect number your turn will be skipped)");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
int number=Serial.parseInt();
if(number==1 && W[0]==" "){
for(int x=0;x<diceRoll;x++)
{
if(W1==51){
spaces[W1]="_";
W1=0;
spaces[W1]="W";
}
else if(W1==24){
spaces[W1]="_";
W1=67;
spaces[W1]="W";
}
else if(W1==71){
spaces[W1]="_";
W1=100;
Player2Points=Player2Points+1;
}
else if(W1=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[W1]="_";
W1=W1+1;
spaces[W1]="W";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[W1]="_";
W[0]="W";
}
}
else if(number==2 && W[1]==" "){
for(int x=0;x<diceRoll;x++)
{
if(W2==51){
spaces[W2]="_";
W2=0;
spaces[W2]="W";
}
else if(W2==24){
spaces[W2]="_";
W2=67;
spaces[W2]="W";
}
else if(W2==71){
spaces[W2]="_";
W2=100;
Player2Points=Player2Points+1;
}
else if(W2=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[W2]="_";
W2=W2+1;
spaces[W2]="W";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[W2]="_";
W[1]="W";
}
}
else if(number==3 && W[2]==" "){
for(int x=0;x<diceRoll;x++)
{
if(W3==51){
spaces[W3]="_";
W3=0;
spaces[W3]="W";
}
else if(W3==24){
spaces[W3]="_";
W3=67;
spaces[W3]="W";
}
else if(W3==71){
spaces[W3]="_";
W3=100;
Player2Points=Player2Points+1;
}
else if(W3=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[W3]="_";
W3=W3+1;
spaces[W3]="W";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[W3]="_";
W[2]="W";
}
}
else if(number==4 && W[3]==" "){
for(int x=0;x<diceRoll;x++)
{
if(W4==51){
spaces[W4]="_";
W4=0;
spaces[W4]="W";
}
else if(W4==24){
spaces[W4]="_";
W4=67;
spaces[W4]="W";
}
else if(W4==71){
spaces[W4]="_";
W4=100;
Player2Points=Player2Points+1;
}
else if(W4=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[W4]="_";
W4=W4+1;
spaces[W4]="W";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[W4]="_";
W[3]="W";
}
}
else
{
Serial.println("What did I tell you!? You're losing your turn now.");
}
}
void getOutOfSpawnM()
{
Serial.println("Which piece would you like to move out of spawn?");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
int number=Serial.parseInt();
number=number-1;
if(spaces[13]!="M"){
if(number==0 && M[0]=="M"){
M1=13;
M[number]=" ";
spaces[13]="M";
}
else if(number==1 && M[1]=="M"){
M2=13;
M[number]=" ";
spaces[13]="M";
}
else if(number==2 && M[2]=="M"){
M3=13;
M[number]=" ";
spaces[13]="M";
}
else if(number==3 && M[3]=="M"){
M4=13;
M[number]=" ";
spaces[13]="M";
}
else
{
Serial.println("Due to you trying to be a funny guy you lost your turn! Hope you thought it was funny cause you skipped your placement!");
}
}
else{
Serial.println("You already have a piece at the starting line, please move that piece before taking another one out of spawn.");
}
}
void movePieceM()
{
Serial.println("Which of the pieces on the board would you like to move?(Caution! If you input a incorrect number your turn will be skipped)");
while(Serial.available()>0){
Serial.parseInt();
}
while (Serial.available() == 0){}
int number=Serial.parseInt();
if(number==1 && M[0]==" "){
for(int x=0;x<diceRoll;x++)
{
if(M1==51){
spaces[M1]="_";
M1=0;
spaces[M1]="M";
}
else if(M1==11){
spaces[M1]="_";
M1=52;
spaces[M1]="M";
}
else if(M1==56){
spaces[M1]="_";
M1=100;
Player2Points=Player2Points+1;
}
else if(M1=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[M1]="_";
M1=M1+1;
spaces[M1]="M";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[M1]="_";
M[0]="M";
}
}
else if(number==2 && M[1]==" "){
for(int x=0;x<diceRoll;x++)
{
if(M2==51){
spaces[M2]="_";
M2=0;
spaces[M2]="M";
}
else if(M2==11){
spaces[M2]="_";
M2=52;
spaces[M2]="M";
}
else if(M2==56){
spaces[M2]="_";
M2=100;
Player2Points=Player2Points+1;
}
else if(M2=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[M2]="_";
M2=M2+1;
spaces[M2]="M";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[M2]="_";
M[1]="M";
}
}
else if(number==3 && M[2]==" "){
for(int x=0;x<diceRoll;x++)
{
if(M3==51){
spaces[M3]="_";
M3=0;
spaces[M3]="M";
}
else if(M3==11){
spaces[M3]="_";
M3=52;
spaces[M3]="M";
}
else if(M3==56){
spaces[M3]="_";
M3=100;
Player2Points=Player2Points+1;
}
else if(M3=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[M3]="_";
M3=M3+1;
spaces[M3]="M";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[M3]="_";
M[2]="M";
}
}
else if(number==4 && W[3]==" "){
for(int x=0;x<diceRoll;x++)
{
if(M4==51){
spaces[M4]="_";
M4=0;
spaces[M4]="M";
}
else if(M4==11){
spaces[M4]="_";
M4=52;
spaces[M4]="M";
}
else if(M4==56){
spaces[M4]="_";
M4=100;
Player2Points=Player2Points+1;
}
else if(M4=100){
Serial.println("You already finished this piece, this smells like funny business, seems like you dont want a turn.");
}
else{
spaces[M4]="_";
M4=M4+1;
spaces[M4]="M";
}
}
int chanceToGoBackToSpawn=random(1,100);
if (chanceToGoBackToSpawn=100){
Serial.println("YIKES, your piece hit the 1 in 100 chance to get back home... Salutations :P");
spaces[M4]="_";
M[3]="M";
}
}
else
{
Serial.println("What did I tell you!? You're losing your turn now.");
}
}