Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <iostream>
#include "Board.hh"
//#include "Shop.cpp"
#include "character.hh"
#include "enemy.hh"
int main()
{
int temp; //holds the previous value of the terrain so that the terrain can be redisplayed upon the player leaving it
int entemp;// holds previous value of terrain for enemy
Board board;
board.board_creation();
//Character character;
Character player;
enemy Enemy;
enemy Monster;
Monster.xCo = 1;
Monster.yCo = 7;
//charMain(player);
//shop(); //runs the shop function allowing the player to buy whatever they want
while (player.hp > 0 and (Enemy.hp > 0 or Monster.hp > 0))
{
while (player.stm > 0) //or Enemy.stm > 0)
{
temp = board.board[player.yCo][player.xCo]; //gets the value of the terrain
board.board[player.yCo][player.xCo] = '#'; //using 9 as placeholder for player symbol currently
if (Enemy.hp > 0)
{
board.board[Enemy.xCo][Enemy.yCo] = '-';
Enemy.movement(); // causes the enemy to move
board.board[Enemy.xCo][Enemy.yCo] = '@'; //using @ symbol for enemy representation
}
if (Enemy.hp <= 0 and board.board[player.xCo][player.yCo] != board.board[Enemy.xCo][Enemy.yCo] ) // makes sure that the player is not in the space its replacing with an empty symbol
{
board.board[Enemy.xCo][Enemy.yCo] = '-';
}
if(Monster.hp > 0)
{
board.board[Monster.yCo][Monster.xCo] = '-';
Monster.movement();
board.board[Monster.yCo][Monster.xCo] = '@';
}
if (Monster.hp <= 0 and board.board[player.xCo][player.yCo] != board.board[Monster.xCo][Monster.yCo]) // makes sure that the player is not in the space its replacing with an empty symbol
{
board.board[Monster.yCo][Monster.xCo] = '-';
}
if (Enemy.hp <= 0 and Monster.hp <= 0)
{
player.gold + 5; // adds gold for victory
break;
}
board.board_output(); //displays board to player with player icon spawned
board.board[player.yCo][player.xCo] = temp; // sets the board back to its terrain
player.direction(player.stm); // moves player where they chose to go
if (player.xCo == Enemy.xCo and player.yCo == Enemy.yCo and Enemy.hp > 0)
{
std::cout<<""<<std::endl;
player.hp = player.hp - Enemy.dmg + player.def; //adjusts the player hp based on the enemy dmg
std::cout<<"You took "<<Enemy.dmg - player.def<<" dmg"<<std::endl; // outputs to the player how the combat went
std::cout<<"You now have "<<player.hp<<" health"<<std::endl; // outputs the hp left
Enemy.hp = Enemy.hp - player.dmg + Enemy.def; // adjusts the enemy hp based on the players attack
std::cout<<"You dealt "<<player.dmg<<" dmg"<<std::endl; // shows how much damadge the player dealt
std::cout<<"They have "<<Enemy.hp<<" health"<<std::endl; // shows the enemy hp
std::cout<<""<<std::endl;
player.xCo = player.xCo-1;
}
if (player.xCo == Monster.xCo and player.yCo == Monster.yCo and Monster.hp > 0)
{
std::cout<<""<<std::endl;
player.hp = player.hp - Monster.dmg + player.def; //adjusts the player hp based on the enemy dmg
std::cout<<"You took "<<Monster.dmg<<" dmg"<<std::endl; //
std::cout<<"You now have "<<Monster.hp<<" health"<<std::endl;
Monster.hp = Monster.hp - player.dmg + Monster.def;
std::cout<<"You dealt "<<player.dmg<<" dmg"<<std::endl;
std::cout<<"They have "<<Monster.hp<<" health"<<std::endl;
std::cout<<""<<std::endl;
player.xCo = player.xCo-1;
}
//board.board[player.yCo][player.xCo] = '#'; //sets new position to player icon
}
player.nextTurn();
Enemy.nextTurn();
}
std::cout<<"You win"<<std::endl;
system("pause");
}