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
///game.cpp
#include <iostream>
#include "menu.h"
#include "game.h"
#include "map.h"
#include "character.h"
#include "combat.h"
#include "enemy.h"
#include "inputTest.h"
#include "typing.h"
#include "weapon.h"
#include "inventory.h"
#include "armor.h"
Character hero;
Enemy enemy2(5,5,5,5,5,5,5);
Area area1;
Main_menu menu;
Inventory inventory;
/* This constructor solely sets the game state to true and will be used to end the game */
Game::Game()
{
game_running = true;
}
/* This method will be the backbone of the game. It will be responsible for initialising the game and making the conditional choices. */
void Game::run()
{
<<<<<<< HEAD
Inventory inventory;
Armor armor(69);
Weapon weapon(420);
inventory.add_item(armor);
inventory.add_item(weapon);
std::cout<<inventory.Inventory_array[0]->get_ID()<<std::endl;
std::cout<<inventory.Inventory_array[0]->get_item_type()<<std::endl;
Map map1; /* This line will generate and object of Map and will be used as the current playing field for the player. */
int x = 1;/* Setting the players coordinates to the beggining of the map, or top left. */
=======
Map map1;
int x = 1;
>>>>>>> eea4137c94972ad5ffc5c09eab0ecae6ee4071ba
int y = 1;
///start of Mateusz's code
///calls the menu and then fills the inventory with items
menu.choice();
<<<<<<< HEAD
hero.new_character();
/* A very important while loop. This will iterate for as long as the game is running and has not been completed, either through glorious victory or shameful defeat. */
=======
Armor armor(0,"Chest Hair",5);
Weapon weapon(1,"Sword",69);
Weapon weapon2(1,"Axe",99);
inventory.add_item(weapon,0);
inventory.add_item(weapon2,0);
inventory.add_item(armor,0);
///end of Mateusz's code
>>>>>>> eea4137c94972ad5ffc5c09eab0ecae6ee4071ba
while( game_running )
{
/* The following conditional statements will detect which type of node the player has currently moved into, and act accordingly. */
if ( map1.map[x][y] == 1 ) /* Nothing of interest. */
{
std::cout << "You've reached an empty grassland.\n" << std::endl;
}
else if ( map1.map[x][y] == 2 ) /* Normal enemy encounter */
{
std::cout << "This grassland wasn't so empty.\n" << std::endl;
/* This will initialise the combat mechanics developed by my team member Jakub Filipiak. */
Combat combat1(15,5);
combat1.battle(hero);
std::cout << "You now have "<< hero.current_HP << "HP" << std::endl;
}
else if ( map1.map[x][y] == 3 ) /* Boss encounter. */
{
std::cout << "Before you stands an abnormally large enemy. You hear boss music in the distance.\n" << std::endl;
hero.current_HP -= 9;
std::cout << "You now have "<< hero.current_HP << "HP" << std::endl;
if ( hero.current_HP >= 1 )
{
std::cout << "You have defeated the enemy leader. All remaining forces scatter.\n" << std::endl;
std::cout << "Congratulations, you've won!.\n" << std::endl;
game_running = false;
inventory.~Inventory();
break;
}
}
else if ( map1.map[x][y] == 420 ) /* Possible special area. */
{
std::cout << "You find a weird looking bush. You wonder if we should implement this.\n" << std::endl;
}
else if ( map1.map[x][y] == 69 ) /* Easter egg. That's about it. */
{
std::cout << "There's an egg on the floor and the weather reminds you of easter.\n" << std::endl;
}
/* This conditional statement checks if the player died in the last encounter they faced. */
if ( hero.current_HP <= 0 )
{
std::cout << "It appears you have died.\n" << std::endl;
game_running = false;
inventory.~Inventory();
break;
}
/* Call to the method to move the player on the map. */
std::string move = take_step();
<<<<<<< HEAD
/* The following choices firstly move the player and check if it is a valid node. If they are not it resets the player's position. If they are, the player is moved. */
if ( move == "S" || move == "s" )
=======
///start of Mateusz's code
///opens inventory menu, and then updates hero stats in case the iteps were swapped
if (move == "I" || move == "i" ){
inventory.inventory_menu();
hero.defense = inventory.armor_slot.stat;
hero.strength = inventory.weapon_slot.stat;
}
///end of Mateusz's code
else if ( move == "S" || move == "s" )
>>>>>>> eea4137c94972ad5ffc5c09eab0ecae6ee4071ba
{
x += 1;
if ( map1.map[x][y] == -1 )
{
std::cout << "Impassable. Choose a different direction.\n" << std::endl;
x -= 1;
}
else
{
std::cout << "You took the South path.\n" << std::endl;
}
}
else if ( move == "N" || move == "n" )
{
x -= 1;
if ( map1.map[x][y] == -1 )
{
std::cout << "Impassable. Choose a different direction.\n" << std::endl;
x += 1;
}
else
{
std::cout << "You took the North path.\n" << std::endl;
}
}
else if ( move == "W" || move == "w" )
{
y -= 1;
if ( map1.map[x][y] == -1 )
{
std::cout << "Impassable. Choose a different direction.\n" << std::endl;
y += 1;
}
else
{
std::cout << "You took the West path.\n" << std::endl;
}
}
else if ( move == "E" || move == "e" )
{
y += 1;
if ( map1.map[x][y] == -1 )
{
std::cout << "Impassable. Choose a different direction.\n" << std::endl;
y -= 1;
}
else
{
std::cout << "You took the East path.\n" << std::endl;
}
}
else
{
std::cout <<"Invalid direction.\n" << std::endl;
}
}
}
/* Method to ask the user for movement input. */
std::string Game::take_step()
{
std::string direction;
std::cout << "Where to go? (S/N/W/E)" << std::endl;
std::cout<< "Open Inventory (I)"<< std::endl;
<<<<<<< HEAD
std::cin >> direction;
=======
std::cin>>direction;
>>>>>>> eea4137c94972ad5ffc5c09eab0ecae6ee4071ba
std::cout << "\n" << std::endl;
return direction;
}