Skip to content

Commit

Permalink
give weapon and then armor after a number of kills
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Thomas (malinka) committed Jan 16, 2018
1 parent 808a4d8 commit 83492e0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
33 changes: 26 additions & 7 deletions src/Application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Application::Application() :
Entropy::Mnemosyne::Application(),
_player(),
_map(),
_weapon(),
_armor(),
_menu(end()),
_world(end()),
_fight(end()),
Expand Down Expand Up @@ -89,11 +91,18 @@ void Application::Options()

void Application::Restart()
{
_enemy = load("Monster.png", Texture(GL::Texture::Texture2D));
_enemy = load("Monster.png"s, Texture(GL::Texture::Texture2D));

auto player = load("Character.png", Texture(GL::Texture::Texture2D));
auto floor = load("Grass.png", Texture(GL::Texture::Texture2D));
auto wall = load("Mountain.png", Texture(GL::Texture::Texture2D));
auto player = load("Character.png"s, Texture(GL::Texture::Texture2D));
auto floor = load("Grass.png"s, Texture(GL::Texture::Texture2D));
auto wall = load("Mountain.png"s, Texture(GL::Texture::Texture2D));
auto sword = load("Sword.png"s, Texture(GL::Texture::Texture2D));
auto armor = load("Armor.png"s, Texture(GL::Texture::Texture2D));

Template None("Empty Template", {});

_weapon = make_shared<Weapon>("Basic Sword"s, sword.shared(), Weapon::Type::Sword, None);
_armor = make_shared<Armor>("Basic Light Armor"s, armor.shared(), Armor::Type::Light, None);

// 2018-01-11 AMR NOTE: calculated with the super scientific method of trial and error
auto height = 16;
Expand All @@ -119,7 +128,7 @@ void Application::Restart()
_player = make_shared<Character>(player.shared(), 10, 10, 10, 10, 10, 10);

_player->Translate(Vertex(width / 2, height / 2, 0));
(*_map)[width / 2 - width / 4][height / 2].setActor(make_shared<Character>(_enemy.shared(), 1, 1, 1, 1, 1, 1));
(*_map)[width / 2 - width / 4][height / 2].setActor(make_shared<Character>(_enemy.shared(), 0, 0, 1, 0, 0, 0));

_menu = addMode(make_shared<Modes::Menu>(*this));
_world = addMode(make_shared<Modes::World>(*this, _player, _map));
Expand All @@ -146,12 +155,22 @@ void Application::Win(const shared_ptr<Character> &w)
if(w != _player) {
setMode(_death);
} else {
auto p = (*_map)[_player->Position().x][_player->Position().y].Actor()->Cost();

_player->giveXp((p > 0) ? p : 1);

if(_player->Xp() >= 10 && !_player->hasWeapon()) {
_player->Equip(*_weapon);
} else if(_player->Xp() >= 20 && !_player->hasArmor()) {
_player->Equip(*_armor);
}

(*_map)[_player->Position().x][_player->Position().y].setActor(shared_ptr<Character>());

if(_player->Position().x == width / 2 - width / 4 && _player->Position().y == height / 2) {
(*_map)[width / 2 + width / 4][height / 2].setActor(make_shared<Character>(_enemy.shared(), 1, 1, 1, 1, 1, 1));
(*_map)[width / 2 + width / 4][height / 2].setActor(make_shared<Character>(_enemy.shared(), 0, 0, 1, 0, 0, 0));
} else {
(*_map)[width / 2 - width / 4][height / 2].setActor(make_shared<Character>(_enemy.shared(), 1, 1, 1, 1, 1, 1));
(*_map)[width / 2 - width / 4][height / 2].setActor(make_shared<Character>(_enemy.shared(), 0, 0, 1, 0, 0, 0));
}

setMode(_world);
Expand Down
2 changes: 2 additions & 0 deletions src/Application.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
private:
std::shared_ptr<Character> _player;
std::shared_ptr<Map> _map;
std::shared_ptr<Weapon> _weapon;
std::shared_ptr<Armor> _armor;
PolymorphicList<Mnemosyne::ModeBase>::iterator _menu;
PolymorphicList<Mnemosyne::ModeBase>::iterator _world;
PolymorphicList<Mnemosyne::ModeBase>::iterator _fight;
Expand Down

0 comments on commit 83492e0

Please sign in to comment.