Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group 8 - Manual World - Development #109

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions assets/grids/team8_grid_large.grid
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
^^^ ^^^~~ ^^^^^^^^^^^^^^ ^^^^^^
^ ^^~~ ^^^^^^^^^^^^^^^^^^^ ^^^^^
^^^ ^^^~~ ^^^^^^^^^^^^^^} ^^^^^^
^ } ^^~~ ^^^^^^^^^^^^^^^^^^^ ^^^^^
^^^ ~~~ ^^^^^^^^^^^^^
^^^^^ ~~^ ^^^^^ ^^
^^^^ ~~~^^^ ^ ^^ ^^^
Expand All @@ -8,13 +8,13 @@
^ ~~~^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^
^ ^^~~ ^^^^^^^^^^^^ ^^^^^^^
^ ^^^~~ ^^^ ^^^^^^^ ^^^ ^^^^
^ ^^^~~~^^^^^^^^^ ^^^^^^^^^^^^~~~~~
^ { ^^^~~~^^^^^^^^^ ^^^^^^^^^^^^~~~~~
^^ ^^^^~~~~^^^^^^^^^^ ^^^^^^^^^^^^^~~~~~~~~
^^^ ^ ~~~~~^^^^^^^^^ ^^^^^^^^^~~~~~~~~~^^^^^
^^^ ^^~~~~~~^^^^^ ^^^^^~~~~~~~^^^^^^^ ^^^
^ ^ ~~~~~~~~##~~~~~~~^^^^^^^^^^ ^^^
^^ ^^^^^ ~~~##~~~~^^^^^^^^^ ^^^^
^^ ^^^^^^^^^^ ^^ ^^
^ ^^^^^^^^^^^^^ ^^^ ^
^ ^^^^^^^^^^^^^ ^^^ ^ {
^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
300 changes: 150 additions & 150 deletions assets/grids/team8_grid_v2.grid

Large diffs are not rendered by default.

35 changes: 33 additions & 2 deletions source/Interfaces/MainInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ namespace i_2D {
if (item_ptr->HasProperty("symbol")) {
c = item_ptr->GetProperty<char>("symbol");
}
symbol_grid[pos.CellY()][pos.CellX()] = c;
if (!item_ptr->IsOwned()){
symbol_grid[pos.CellY()][pos.CellX()] = c;
}
}

// Add in the agents
Expand All @@ -74,7 +76,9 @@ namespace i_2D {
if (agent_ptr->HasProperty("symbol")) {
c = agent_ptr->GetProperty<char>("symbol");
}
symbol_grid[pos.CellY()][pos.CellX()] = c;
if (!agent_ptr->HasProperty("deleted")){
symbol_grid[pos.CellY()][pos.CellX()] = c;
}
}
return symbol_grid;
}
Expand Down Expand Up @@ -376,6 +380,33 @@ namespace i_2D {
case sf::Keyboard::Right:
action_id = GetActionID("right");
break;
case sf::Keyboard::H:
action_id = GetActionID("heal");
break;
case sf::Keyboard::T:
action_id = GetActionID("stats");
break;
case sf::Keyboard::C:
action_id = GetActionID("use_axe");
break;
case sf::Keyboard::V:
action_id = GetActionID("use_boat");
break;
case sf::Keyboard::F:
action_id = GetActionID("attack");
break;
case sf::Keyboard::G:
action_id = GetActionID("special");
break;
case sf::Keyboard::B:
action_id = GetActionID("buff");
break;
case sf::Keyboard::R:
action_id = GetActionID("run");
break;
case sf::Keyboard::Y:
action_id = GetActionID("help");
break;
default:
break; // The user pressed an unknown key.
}
Expand Down
2 changes: 1 addition & 1 deletion source/Interfaces/TrashInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace cse491 {
if(agent_ptr->HasProperty("symbol")){
c = agent_ptr->GetProperty<char>("symbol");
}
if (!agent_ptr->HasProperty("Deleted")){
if (!agent_ptr->HasProperty("deleted")){
symbol_grid[pos.CellY()][pos.CellX()] = c;
}
}
Expand Down
26 changes: 8 additions & 18 deletions source/Worlds/ManualWorld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ namespace cse491_team8 {
portal_id_b = AddCellType("portal_b", "Portal that teleports player to another b-portal spot.", '{');
portal_id_c = AddCellType("portal_c", "Portal that teleports player to another c-portal spot.", '(');
portal_id_d = AddCellType("portal_d", "Portal that teleports player to another d-portal spot.", ')');
main_grid.Read("../assets/grids/team8_grid_large.grid", type_options);
main_grid.Read("../assets/grids/team8_grid_v2.grid", type_options);
}

~ManualWorld() = default;

/// @brief Generates move sets for all the agents
Expand Down Expand Up @@ -270,6 +269,7 @@ namespace cse491_team8 {
other_agent.SetProperty<int>("Strength", (int)(agent_health - item_strength));
}
item->SetUnowned();
agent.RemoveItem(item->GetID());
item->SetPosition(other_agent.GetPosition());
agent.Notify(other_agent.GetName() + " dropped their " + item->GetName() + "!");
}
Expand Down Expand Up @@ -314,17 +314,6 @@ namespace cse491_team8 {
return other_damage;
}

/// @brief Generates the battling boolean
/// Sets the battling boolean as a property for each agent
/// @return None
void SetBattling()
{
for (auto & [id, agent_ptr] : agent_map)
{
agent_ptr->SetProperty<bool>("Battling", false);
}
}

/// @brief Checks the strength between two agents
/// @param other_agent The autonomous agent to compare
/// @param agent The interface (player) agent to compare
Expand Down Expand Up @@ -421,7 +410,7 @@ namespace cse491_team8 {
agent.SetProperty<bool>("Battling", false);
other_agent.SetProperty<bool>("Battling", false);
DropItems(agent, other_agent);
other_agent.SetProperty<bool>("Deleted", true);
other_agent.SetProperty<bool>("deleted", true);
}
}

Expand All @@ -443,7 +432,7 @@ namespace cse491_team8 {

void RunAgents() override {
for (auto & [id, agent_ptr] : agent_map) {
if (agent_ptr->HasProperty("Deleted")) {
if (agent_ptr->HasProperty("deleted")) {
continue;
}
size_t action_id = agent_ptr->SelectAction(main_grid, type_options, item_map, agent_map);
Expand Down Expand Up @@ -484,6 +473,7 @@ namespace cse491_team8 {

// remove it from the board
item_ptr->SetOwner(agent);
agent.AddItem(item_ptr->GetID());
break;
}
}
Expand Down Expand Up @@ -628,7 +618,7 @@ namespace cse491_team8 {
auto agents = FindAgentsNear(agent.GetPosition(), 1);
for (auto agent_id : agents)
{
if (!agent_map[agent_id]->IsInterface() && !agent_map[agent_id]->HasProperty("Deleted"))
if (!agent_map[agent_id]->IsInterface() && !agent_map[agent_id]->HasProperty("deleted"))
{
agent.Notify("You are running away");
agent_map[agent_id]->SetProperty<bool>("Battling", false);
Expand Down Expand Up @@ -666,7 +656,7 @@ namespace cse491_team8 {
for (auto agent_id : agents)
{
// Battle other agent near the player
if (!agent_map[agent_id]->IsInterface() && !agent_map[agent_id]->HasProperty("Deleted"))
if (!agent_map[agent_id]->IsInterface() && !agent_map[agent_id]->HasProperty("deleted"))
{
agent.SetProperty<bool>("Battling", true);
agent_map[agent_id]->SetProperty<bool>("Battling", true);
Expand Down Expand Up @@ -836,4 +826,4 @@ namespace cse491_team8 {

};

} // End of namespace cse491
} // End of namespace cse491_team8
26 changes: 10 additions & 16 deletions source/group_3_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int main() {
daedricArmor->SetProperties("Health", 99, "Extra Inv. Space", 5);
daedricArmor->SetPosition(5, 0);
world_1.AddItem(std::move(daedricArmor));
world_1.Run();
// world_1.Run();

static const unsigned int SEED = 973;
BiomeGenerator biomeGenerator(BiomeType::Maze, 110, 25, SEED);
Expand All @@ -58,23 +58,17 @@ int main() {
world_2.AddAgent<cse491::PacingAgent>("Pacer 2").SetPosition(6, 1);
world_2.AddAgent<i_2D::MainInterface>("Interface2").SetProperty("symbol", '@');

world_2.Run();
// world_2.Run();

cse491_team8::ManualWorld world_3;
world_3.AddItem("Axe", "Chop", 5, "symbol", 'P').SetPosition(37, 3);
world_3.AddItem("Boat", "Swim", 7, "symbol", 'U').SetPosition(18, 4);
world_3.AddAgent<i_2D::MainInterface>("Interface3", "Strength", 15, "Health", 15, "Max_Health", 40, "Direction",
0).SetProperty("symbol", '@').SetPosition(40, 3);
world_3.AddAgent<cse491::PacingAgent>("Pacer 1", "Strength", 30, "Health", 5, "Max_Health", 30, "Direction",
0).SetPosition(45, 3);
world_3.AddAgent<cse491::PacingAgent>("Pacer 1", "Strength", 15, "Health", 10, "Max_Health", 30, "Direction",
0).SetPosition(3, 14);
world_3.AddAgent<cse491::PacingAgent>("Pacer 2", "Strength", 20, "Health", 20, "Max_Health", 30, "Direction",
0).SetPosition(7, 3);
world_3.AddAgent<cse491::PacingAgent>("Pacer 3", "Strength", 25, "Health", 30, "Max_Health", 30, "Direction",
0).SetPosition(18, 3);
world_3.AddAgent<cse491::PacingAgent>("Pacer 4", "Strength", 30, "Health", 40, "Max_Health", 30, "Direction",
0).SetPosition(45, 17);
world_3.AddItem("Axe", "Uses", 5, "symbol", 'P').SetPosition(37, 3);
world_3.AddItem("Boat", "Uses", 7, "symbol", 'U').SetPosition(18, 4);
world_3.AddAgent<i_2D::MainInterface>("Interface3").SetProperty("symbol", '@').SetPosition(40, 3);
world_3.AddAgent<cse491::PacingAgent>("Pacer 1").SetPosition(45, 3);
world_3.AddAgent<cse491::PacingAgent>("Pacer 1").SetPosition(3, 14);
world_3.AddAgent<cse491::PacingAgent>("Pacer 2").SetPosition(7, 3);
world_3.AddAgent<cse491::PacingAgent>("Pacer 3").SetPosition(18, 3);
world_3.AddAgent<cse491::PacingAgent>("Pacer 4").SetPosition(45, 17);

world_3.GenerateMoveSets();

Expand Down
17 changes: 17 additions & 0 deletions source/group_8_main.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Filename should match the application's, just swapping .cpp with .cmake
# Example: The CMake file for my_main.cpp would be my_main.cmake in the same directory

# Here, add one .cpp per line. Only the strings should
add_source_to_target(${EXE_NAME} "source/Interfaces/MainInterface.cpp")
add_source_to_target(${EXE_NAME} "source/Interfaces/TextureHolder.cpp")
add_source_to_target(${EXE_NAME} "source/Interfaces/Component.cpp")
add_source_to_target(${EXE_NAME} "source/Interfaces/Component.hpp")
add_source_to_target(${EXE_NAME} "source/Interfaces/Container.cpp")
add_source_to_target(${EXE_NAME} "source/Interfaces/Container.hpp")
add_source_to_target(${EXE_NAME} "source/Interfaces/Button.cpp")
add_source_to_target(${EXE_NAME} "source/Interfaces/Menu.cpp")
add_source_to_target(${EXE_NAME} "source/Worlds/BiomeGenerator.cpp")
add_source_to_target(${EXE_NAME} "source/Interfaces/TextBox.cpp")
add_source_to_target(${EXE_NAME} "source/Interfaces/MessageBoard.cpp")
add_source_to_target(${EXE_NAME} "source/Interfaces/Inventory.cpp")
add_source_to_target(${EXE_NAME} "source/Interfaces/Inventory.hpp")
32 changes: 21 additions & 11 deletions source/group_8_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,40 @@

// Include the modules that we will be using.
#include "Agents/PacingAgent.hpp"
#include "Interfaces/MainInterface.hpp"
#include "Interfaces/TrashInterface.hpp"
#include "Worlds/ManualWorld.hpp"
#include "Agents/AStarAgent.hpp"

int main()
{
cse491_team8::ManualWorld world;

world.AddItem("Axe", "Uses", 5, "symbol", 'P').SetPosition(37, 3);
world.AddItem("Axe", "Uses", 10, "symbol", 'P').SetPosition(40, 5);
world.AddItem("Boat", "Uses", 7, "symbol", 'U').SetPosition(18, 4);

world.AddItem("Sword", "Strength", 10, "symbol", 't').SetPosition(27, 11);
world.AddItem("Axe", "Uses", 5, "symbol", 'P').SetPosition(80, 120);
world.AddItem("Axe", "Uses", 10, "symbol", 'P').SetPosition(97, 40);

world.AddItem("Boat", "Uses", 7, "symbol", 'U').SetPosition(55, 11);

world.AddItem("Sword", "Strength", 8, "symbol", 't').SetPosition(18, 4);
world.AddItem("Sword", "Strength", 5, "symbol", 't').SetPosition(27, 11);
world.AddItem("Sword", "Strength", 4, "symbol", 't').SetPosition(65, 89);

world.AddItem("Health Potion", "Healing", 25, "symbol", 'j').SetPosition(38, 16);
world.AddItem("Health Potion", "Healing", 40, "symbol", 'j').SetPosition(40, 1);
world.AddItem("Health Potion", "Healing", 30, "symbol", 'j').SetPosition(1, 18);

world.AddAgent<cse491::TrashInterface>("Interface", "symbol", '@').SetPosition(40,3);
world.AddAgent<cse491::PacingAgent>("Pacer 1").SetPosition(45, 3);
// world.AddAgent<cse491::TrashInterface>("Interface", "symbol", '@').SetPosition(80, 63);
world.AddAgent<i_2D::MainInterface>("Interface", "symbol", '@').SetPosition(80,63);
world.AddAgent<cse491::PacingAgent>("Pacer 1").SetPosition(97, 45);
world.AddAgent<cse491::PacingAgent>("Pacer 5").SetPosition(3,14);
world.AddAgent<cse491::PacingAgent>("Pacer 2").SetPosition(7,3);
world.AddAgent<cse491::PacingAgent>("Pacer 2").SetPosition(7,30);
world.AddAgent<cse491::PacingAgent>("Pacer 6").SetPosition(27, 10);
world.AddAgent<cse491::PacingAgent>("Pacer 7").SetPosition(38, 10);
world.AddAgent<cse491::PacingAgent>("Pacer 3").SetPosition(18,3);
world.AddAgent<cse491::PacingAgent>("Pacer 4").SetPosition(45,17);
// need to set goal position
world.AddAgent<walle::AStarAgent>("AStar Agent 1").SetPosition(80, 111);

world.AddAgent<cse491::PacingAgent>("Shark", "OnlyWater", 1).SetPosition(11, 4);
world.AddAgent<cse491::PacingAgent>("Shark", "OnlyWater", 1).SetPosition(125, 140);

auto & pacer_1 = world.GetAgent(world.GetAgentID("Pacer 1"));
world.AddItem("Sword", "Strength", 15, "symbol", 't').SetPosition(pacer_1.GetPosition());
Expand All @@ -38,7 +49,6 @@ int main()
world.MoveSetAction(interface);

world.GenerateMoveSets();
// world.SetBattling();

world.Run();

Expand Down