int enoughToBuildCampus(Game g, int playerId, fromToArc arcPath[2]) { int result = FALSE; int pathResources = 2; if (arcPath[0].alreadyOwned) { pathResources--; } if (arcPath[1].alreadyOwned) { pathResources--; } int conRateBPS = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_BPS); int conRateBQN = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_BQN); int conRateMJ = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_MJ); int conRateMTV = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_MTV); int conRateMMONEY = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_MMONEY); int numBPS = getStudents(g, playerId, STUDENT_BPS); int numBQN = getStudents(g, playerId, STUDENT_BQN); int numMJ = getStudents(g, playerId, STUDENT_MJ); int numMTV = getStudents(g, playerId, STUDENT_MTV); int numMMONEY = getStudents(g, playerId, STUDENT_MMONEY); if (numMTV < 1) { if (numBPS - conRateBPS >= pathResources + 1) { convertStudents(g, STUDENT_BPS, STUDENT_MTV, 1); numBPS = numBPS - conRateBPS; numMTV++; } else if (numBQN - conRateBQN >= pathResources + 1) { convertStudents(g, STUDENT_BQN, STUDENT_MTV, 1); numBQN = numBQN - conRateBQN; numMTV++; } else if (numMJ - conRateMJ >= 1) { convertStudents(g, STUDENT_MJ, STUDENT_MTV, 1); numMJ = numMJ - conRateMJ; numMTV++; } } if (numMJ < 1) { if (numBPS - conRateBPS >= pathResources + 1) { convertStudents(g, STUDENT_BPS, STUDENT_MJ, 1); numBPS = numBPS - conRateBPS; numMJ++; } else if (numBQN - conRateBQN >= pathResources + 1) { convertStudents(g, STUDENT_BQN, STUDENT_MJ, 1); numBQN = numBQN - conRateBQN; numMJ++; } else if (numMTV - conRateMTV >= 1) { convertStudents(g, STUDENT_MTV, STUDENT_MJ, 1); numMTV = numMTV - conRateMTV; numMJ++; } } if (numBQN <= pathResources) { int neededBQN = pathResources + 1 - numBQN; if (numBPS - (conRateBPS * neededBQN) >= pathResources + 1) { convertStudents(g, STUDENT_BPS, STUDENT_BQN, neededBQN); numBPS = numBPS - (conRateBPS * (pathResources + 1)); numBQN += neededBQN; } else if (numMJ - (conRateBQN * neededBQN) >= 1) { convertStudents(g, STUDENT_MJ, STUDENT_BQN, neededBQN); numMJ = numMJ - (conRateBQN * (pathResources + 1)); numBQN += neededBQN; } else if (numMTV - (conRateBQN * neededBQN) >= 1) { convertStudents(g, STUDENT_MTV, STUDENT_BQN, neededBQN); numMTV = numMTV - (conRateBQN * (pathResources + 1)); numBQN += neededBQN; } } if (numBPS <= pathResources) { int neededBPS = pathResources + 1 - numBPS; if (numBQN - (conRateBQN * neededBPS) >= pathResources + 1) { convertStudents(g, STUDENT_BQN, STUDENT_BPS, neededBPS); numBQN = numBQN - (conRateBQN * (pathResources + 1)); numBPS += neededBPS; } else if (numMJ - (conRateMJ * neededBPS) >= 1) { convertStudents(g, STUDENT_MJ, STUDENT_BPS, neededBPS); numMJ = numMJ - (conRateMJ * (pathResources + 1)); numBPS += neededBPS; } else if (numMTV - (conRateMTV * neededBPS) >= 1) { convertStudents(g, STUDENT_MTV, STUDENT_BPS, neededBPS); numMTV = numMTV - (conRateMTV * (pathResources + 1)); numBPS += neededBPS; } } while (numMJ <= numBQN - 1 && numMJ <= numBPS - 1 && numMTV > 1) { convertStudents(g, STUDENT_MTV, STUDENT_MJ, 1); numMTV -= conRateMTV; numMJ++; } while (numBPS <= numBQN - 1 && numBPS <= numMJ - 1 && numMTV > 1) { convertStudents(g, STUDENT_MTV, STUDENT_BPS, 1); numMTV -= conRateMTV; numBPS++; } while(numBQN <= numBPS - 1 && numBQN <= numMJ - 1 && numMTV > 1) { convertStudents(g, STUDENT_MTV, STUDENT_BQN, 1); numMTV -= conRateMTV; numBQN++; } while (numMJ <= numBQN - 1 && numMJ <= numBPS - 1 && numMMONEY > 1) { convertStudents(g, STUDENT_MMONEY, STUDENT_MJ, 1); numMMONEY -= conRateMMONEY; numMJ++; } while (numBPS <= numBQN - 1 && numBPS <= numMJ - 1 && numMMONEY > 1) { convertStudents(g, STUDENT_MMONEY, STUDENT_BPS, 1); numMMONEY -= conRateMMONEY; numBPS++; } while(numBQN <= numBPS - 1 && numBQN <= numMJ - 1 && numMMONEY > 1) { convertStudents(g, STUDENT_MMONEY, STUDENT_BQN, 1); numMMONEY -= conRateMMONEY; numBQN++; } if (getStudents(g, playerId, STUDENT_BPS) >= pathResources + 1 && getStudents(g, playerId, STUDENT_BQN) >= pathResources + 1 && getStudents(g, playerId, STUDENT_MJ) >= 1 && getStudents(g, playerId, STUDENT_MTV) >= 1) { result = TRUE; } return result; }
int enoughToStartSpinoff(Game g, int playerId) { int result = FALSE; int changesMade = TRUE; int conRateBPS = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_BPS); int conRateBQN = getExchangeRate(g, playerId, STUDENT_BQN, STUDENT_BQN); int numMJ = 0; int numMTV = 0; int numMMONEY = 0; while (changesMade && (numMTV < 1 || numMMONEY < 1 || numMJ < 1)) { int effectiveBPS = getStudents(g, playerId, STUDENT_BPS) / conRateBPS; int effectiveBQN = getStudents(g, playerId, STUDENT_BQN) / conRateBQN; numMJ = getStudents(g, playerId, STUDENT_MJ); numMTV = getStudents(g, playerId, STUDENT_MTV); numMMONEY = getStudents(g, playerId, STUDENT_MMONEY); if (numMJ < 1 || numMTV < 1 || numMMONEY < 1) { int toSide; if (numMJ < 1) { toSide = STUDENT_MJ; } else if (numMTV < 1) { toSide = STUDENT_MTV; } else { toSide = STUDENT_MMONEY; } changesMade = FALSE; if (effectiveBPS > 0) { changesMade = TRUE; convertStudents(g, STUDENT_BPS, toSide, 1); } else if (effectiveBQN > 0) { changesMade = TRUE; convertStudents(g, STUDENT_BQN, toSide, 1); } } } int conRateMTV = getExchangeRate(g, playerId, STUDENT_MTV, STUDENT_MTV); int conRateMJ = getExchangeRate(g, playerId, STUDENT_MJ, STUDENT_MJ); int conRateMMONEY = getExchangeRate(g, playerId, STUDENT_MMONEY, STUDENT_MMONEY); numMTV = getStudents(g, playerId, STUDENT_MTV); numMJ = getStudents(g, playerId, STUDENT_MJ); numMMONEY = getStudents(g, playerId, STUDENT_MMONEY); while (numMTV > numMJ && numMTV > numMMONEY && numMTV >= conRateMTV) { numMTV -= conRateMTV; if (numMJ < numMMONEY) { convertStudents(g, STUDENT_MTV, STUDENT_MJ, 1); numMJ++; } else { convertStudents(g, STUDENT_MTV, STUDENT_MMONEY, 1); numMMONEY++; } } while (numMJ > numMTV && numMJ > numMMONEY && numMJ >= conRateMJ) { numMJ -= conRateMJ; if (numMTV < numMMONEY) { convertStudents(g, STUDENT_MJ, STUDENT_MTV, 1); numMTV++; } else { convertStudents(g, STUDENT_MJ, STUDENT_MMONEY, 1); numMMONEY++; } } while (numMMONEY > numMJ && numMMONEY > numMTV && numMMONEY > conRateMMONEY) { numMMONEY -= conRateMMONEY; if (numMJ < numMTV) { convertStudents(g, STUDENT_MMONEY, STUDENT_MJ, 1); numMJ++; } else { convertStudents(g, STUDENT_MMONEY, STUDENT_MTV, 1); numMTV++; } } if (numMTV > 0 && numMJ > 0 && numMMONEY > 0) { result = TRUE; } return result; }
bool CSVOldFormatConverter::convertNewStudents(QString csvDirPath) { return convertStudents(csvDirPath + "/Студент.csv", -1); }
int enoughToBuildGO8(Game g, int playerId) { int result = FALSE; int changesMade = TRUE; int conRateBPS = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_BPS); int conRateBQN = getExchangeRate(g, playerId, STUDENT_BQN, STUDENT_BQN); int conRateMTV = getExchangeRate(g, playerId, STUDENT_MTV, STUDENT_MTV); int numRequiredMJ = 1; int numRequiredMMONEY = 1; while (changesMade && (numRequiredMJ > 0 || numRequiredMMONEY > 0)) { int effectiveBPS = getStudents(g, playerId, STUDENT_BPS) / conRateBPS; int effectiveBQN = getStudents(g, playerId, STUDENT_BQN) / conRateBQN; int numMJ = getStudents(g, playerId, STUDENT_MJ); int effectiveMTV = getStudents(g, playerId, STUDENT_MTV) / conRateMTV; int numMMONEY = getStudents(g, playerId, STUDENT_MMONEY); numRequiredMJ = 2 - numMJ; numRequiredMMONEY = 3 - numMMONEY; if (numRequiredMJ > 0 || numRequiredMMONEY > 0) { int toSide; if (numRequiredMJ < numRequiredMMONEY) { toSide = STUDENT_MMONEY; } else { toSide = STUDENT_MJ; } changesMade = FALSE; if (effectiveBPS > 0) { changesMade = TRUE; convertStudents(g, STUDENT_BPS, toSide, 1); } else if (effectiveBQN > 0) { changesMade = TRUE; convertStudents(g, STUDENT_BQN, toSide, 1); } else if (effectiveMTV > 0) { changesMade = TRUE; convertStudents(g, STUDENT_MTV, toSide, 1); } } } int numMMONEY = getStudents(g, playerId, STUDENT_MMONEY); int numMJ = getStudents(g, playerId, STUDENT_MJ); int conRateMMONEY = getExchangeRate(g, playerId, STUDENT_MMONEY, STUDENT_MMONEY); int conRateMJ = getExchangeRate(g, playerId, STUDENT_MJ, STUDENT_MJ); while (numMMONEY > numMJ && numMMONEY >= 3 + conRateMMONEY) { numMMONEY -= conRateMTV; convertStudents(g, STUDENT_MMONEY, STUDENT_MJ, 1); numMJ++; } while (numMJ > numMMONEY && numMJ >= 2 + conRateMTV && numMMONEY < 3) { numMJ -= conRateMJ; convertStudents(g, STUDENT_MJ, STUDENT_MMONEY, 1); numMMONEY++; } if (numRequiredMMONEY < 1 && numRequiredMJ < 1) { // printf("Required MMONEY: %d\n", numRequiredMMONEY); // printf("Required MJ: %d\n", numRequiredMJ); // printf("MMONEY: %d\n", getStudents(g, playerId, STUDENT_MMONEY)); // printf("MJ: %d\n", getStudents(g, playerId, STUDENT_MJ)); result = TRUE; } if (getGO8s(g, UNI_A) + getGO8s(g, UNI_B) + getGO8s(g, UNI_C) >= 8) { result = FALSE; } return result; }
bool CSVOldFormatConverter::convertOldStudents(QString csvDirPath) { return convertStudents(csvDirPath + "/Студент_выпуск.csv"); }