Exemplo n.º 1
0
void parseField(){
	int j; void moveRBW();
	for(j = 0; j < 64; j++){
		
		if(colArr[j] == UNK){
			continue;
		}
		else if(colArr[j] == (RBW)){

			printf("Rainbow at %d!\n", j + 1);

			moveRBW(j);
			enactMove();
			return;
		}
		else if(checkHP(j)){
			colArr[j] = UNK;
			colArr[j + 1] = UNK;
			colArr[moves[0] - 1] = UNK;
			colArr[moves[1] - 1] = UNK;

			enactMove();
			continue;
		}
		else if(checkHD(j)){
			colArr[j] = UNK;
			colArr[j + 2] = UNK;
			colArr[moves[0] - 1] = UNK;
			colArr[moves[1] - 1] = UNK;

			enactMove();
			continue;
		}
		else if((j / 8 < 8) && checkVP(j)){
			colArr[j] = UNK;
			colArr[j + 8] = UNK;
			colArr[moves[0] - 1] = UNK;
			colArr[moves[1] - 1] = UNK;
			
			enactMove();
			continue;
		}	
		else if((j / 8 < 7) && checkVD(j)){
			colArr[j] = UNK;
			colArr[j + 16] = UNK;
			colArr[moves[0] - 1] = UNK;
			colArr[moves[1] - 1] = UNK;

			enactMove();
			continue;
		}
		else continue;
	}
	return;
}	
Exemplo n.º 2
0
void Game::startGame() {
	Utils::cClear();
	while (playing) {
		//fighting loop
		while (fighting){
			if (player->getCurrentRoom()->hasEnemies()){
				Utils::Print("\n" + player->getCurrentRoom()->getEnemyInfo(true));
				Utils::PrintLine(player->getStatus());
				Utils::PrintLine("\nWhat do you want to do?\nAttack | Run | Use Potion | Use Item");
				std::string choice = Utils::ReadString();
				handleInput(choice);
				Utils::cClear();
			}
			else {
				Utils::PrintLine("You defeated the enemy.");
				fighting = false;
			}
			

		}
		// print map
		Utils::Print(dungeon->getCurrentLayer()->getDungeonMap(cheat, player->getCurrentRoom()));
		if (cheat){
			cheat = false;
		}
		if (affected) {
			affected = false;
			Utils::PrintLine(effect);
		}
		if (showStats){
			showStats = false;
			Utils::PrintLine(player->getStatus() + "\n");
		}
		if (showInventory) {
			showInventory = false;
			std::string equipped = "";
			std::string inventory = "";
			

			if (player->getItems().size() == 0 && player->getSword() == nullptr && player->getShield() == nullptr){
				inventory += "You don't have any items right now.";
			}
			else {
				if (player->getSword() != nullptr || player->getShield() != nullptr) {
					equipped += "Equipped:\n";
				}
				inventory += "Inventory: \n";
				for (int i = 0; i < player->getItems().size(); i++){
					if (player->getItems()[i] != player->getSword() && player->getItems()[i] != player->getShield()) {
						inventory += "[" + std::to_string(i + 1) + "] " + std::string(player->getItems()[i]->getText()) + "\n";
					}
					else if (player->getItems()[i] == player->getSword()) {
						equipped += "[" + std::to_string(i + 1) + "]" + player->getSword()->getText() + ": " + std::to_string(player->getSword()->getEquipPower()) + "\n";
					}
					else if (player->getItems()[i] == player->getShield()) {
						equipped += "[" + std::to_string(i + 1) + "]" + player->getShield()->getText() + ": " + std::to_string(player->getShield()->getEquipPower()) + "\n";
					}
				}
				if (player->getSword() != nullptr || player->getShield() != nullptr) {
					equipped += "\n";
				}
			}
			Utils::PrintLine(equipped + inventory + "\n");
		}
		if (compass){
			compass = false;
			std::string compassString = "You take the compass out of your pocket. It lights up and shows you your path: \n\n";
			//TODO shortest path with least amount of enemies.
			compassString += "Output from shortest path stuffs";
			Utils::PrintLine(compassString);
		}
		if (talisman){
			talisman = false;
			std::string talismanString = "You take out the talisman. It whispers to you that the ladder down is ";
			talismanString += std::to_string(player->useTalisman(player->getCurrentRoom(), dungeon->getLastRoom())) + " rooms away"; //TODO bfs for path.
			Utils::PrintLine(talismanString);
		}
		// Print all actions
		if (player->getCurrentRoom() == dungeon->getFirstRoom()) {
			Utils::PrintLine("This is the first room of this layer.");
		} else if (player->getCurrentRoom() == dungeon->getLastRoom()) {
			Utils::PrintLine("You have found the last room in this layer! Do you wish to go down, further into the dungeon?");
		}
		Utils::Print(player->getCurrentRoom()->getRoomInfo());
		player->getCurrentRoom()->checkForTraps(player);
		

		
		actions = "|";
		for (std::string actionString : player->getCurrentRoom()->getPossibleActions()) {
			if (actionString != "") {
				actions += "  " + actionString + "  |";
			}
		}
		if (player->getCurrentRoom() == dungeon->getLastRoom()) {
			actions += "  Down |";
		}
		else if (player->getCurrentRoom() == dungeon->getFirstRoom() && dungeon->getLevel() != 1) {
			actions += "  Up |";
		}
		actions += "  Quit |";
		Utils::PrintLine(actions);
		Utils::PrintLine("Please enter your choice below.");
		std::string choice = Utils::ReadString();
		handleInput(choice);
		Utils::cClear();
		checkHP();
	}

}