private int CheckGameOver() { int rightP = 0; int leftP = 0; int rightD = 0; int leftD = 0; int flag = 0; rightP = rightCoastCtr.GetCharacterNum()[0]; rightD = rightCoastCtr.GetCharacterNum()[1]; leftP = leftCoasrCtr.GetCharacterNum()[0]; leftD = leftCoasrCtr.GetCharacterNum()[1]; if (leftD + leftP == 6) { flag = 1; //win } if (boatCtr.boat.location == Location.right) { rightP += boatCtr.GetCharacterNum()[0]; rightD += boatCtr.GetCharacterNum()[1]; } else { leftP += boatCtr.GetCharacterNum()[0]; leftD += boatCtr.GetCharacterNum()[1]; } if ((rightP < rightD && rightP > 0) || (leftP < leftD && leftP > 0)) { flag = -1; //lose } return(flag); }
private int CheckGameOver() { int rightPriest = 0; int rightDevil = 0; int leftPriest = 0; int leftDevil = 0; int status = 0; rightPriest += rightCoastCtrl.GetCharacterNum()[0]; rightDevil += rightCoastCtrl.GetCharacterNum()[1]; leftPriest += leftCoastCtrl.GetCharacterNum()[0]; leftDevil += leftCoastCtrl.GetCharacterNum()[1]; // Win if (leftPriest + leftDevil == 6) { status = 2; } if (boatCtrl.boat.Location == Location.right) { rightPriest += boatCtrl.GetCharacterNum()[0]; rightDevil += boatCtrl.GetCharacterNum()[1]; } else { leftPriest += boatCtrl.GetCharacterNum()[0]; leftDevil += boatCtrl.GetCharacterNum()[1]; } // Lose if ((rightPriest < rightDevil && rightPriest > 0) || (leftPriest < leftDevil && leftPriest > 0)) { status = 1; } return(status); }
int CheckGameOver() // 0->continue, 1->lose, 2->win { int start_priest = 0; int start_devil = 0; int end_priest = 0; int end_devil = 0; int[] startCount = startCoast.GetCharacterNum(); start_priest += startCount[0]; start_devil += startCount[1]; int[] endCount = endCoast.GetCharacterNum(); end_priest += endCount[0]; end_devil += endCount[1]; if (end_priest + end_devil == 6) // win { return(2); } int[] boatCount = boat.GetCharacterNum(); if (boat.Get_end_or_start() == -1) // boat at endCoast { end_priest += boatCount[0]; end_devil += boatCount[1]; } else // boat at startCoast { start_priest += boatCount[0]; start_devil += boatCount[1]; } if (start_priest < start_devil && start_priest > 0) // lose { return(1); } if (end_priest < end_devil && end_priest > 0) { return(1); } return(0); // continue }
int CheckGameOver() // playing 0, lose 1, win 2 { int fromPriest = 0; int fromDevil = 0; int toPriest = 0; int toDevil = 0; int[] fromCount = fromCoast.GetCharacterNum(); fromPriest += fromCount[0]; fromDevil += fromCount[1]; int[] toCount = toCoast.GetCharacterNum(); toPriest += toCount[0]; toDevil += toCount[1]; if (toPriest + toDevil == 6) { return(2); } int[] boatCount = boat.GetCharacterNum(); if (boat.Get_to_or_from() == -1) { toPriest += boatCount[0]; toDevil += boatCount[1]; } else { fromPriest += boatCount[0]; fromDevil += boatCount[1]; } if (fromPriest < fromDevil && fromPriest > 0) { return(1); } if (toPriest < toDevil && toPriest > 0) { return(1); } return(0); }