From 83492e042ae2af8995723102504e4b9c4148ee70 Mon Sep 17 00:00:00 2001 From: "Michael Thomas (malinka)" Date: Tue, 16 Jan 2018 14:42:37 -0500 Subject: [PATCH] give weapon and then armor after a number of kills --- src/Application.cc | 33 ++++++++++++++++++++++++++------- src/Application.hh | 2 ++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/Application.cc b/src/Application.cc index 0070c84..061bca5 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -27,6 +27,8 @@ Application::Application() : Entropy::Mnemosyne::Application(), _player(), _map(), + _weapon(), + _armor(), _menu(end()), _world(end()), _fight(end()), @@ -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("Basic Sword"s, sword.shared(), Weapon::Type::Sword, None); + _armor = make_shared("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; @@ -119,7 +128,7 @@ void Application::Restart() _player = make_shared(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(_enemy.shared(), 1, 1, 1, 1, 1, 1)); + (*_map)[width / 2 - width / 4][height / 2].setActor(make_shared(_enemy.shared(), 0, 0, 1, 0, 0, 0)); _menu = addMode(make_shared(*this)); _world = addMode(make_shared(*this, _player, _map)); @@ -146,12 +155,22 @@ void Application::Win(const shared_ptr &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()); if(_player->Position().x == width / 2 - width / 4 && _player->Position().y == height / 2) { - (*_map)[width / 2 + width / 4][height / 2].setActor(make_shared(_enemy.shared(), 1, 1, 1, 1, 1, 1)); + (*_map)[width / 2 + width / 4][height / 2].setActor(make_shared(_enemy.shared(), 0, 0, 1, 0, 0, 0)); } else { - (*_map)[width / 2 - width / 4][height / 2].setActor(make_shared(_enemy.shared(), 1, 1, 1, 1, 1, 1)); + (*_map)[width / 2 - width / 4][height / 2].setActor(make_shared(_enemy.shared(), 0, 0, 1, 0, 0, 0)); } setMode(_world); diff --git a/src/Application.hh b/src/Application.hh index 3ec7e31..c2dc064 100644 --- a/src/Application.hh +++ b/src/Application.hh @@ -36,6 +36,8 @@ private: std::shared_ptr _player; std::shared_ptr _map; + std::shared_ptr _weapon; + std::shared_ptr _armor; PolymorphicList::iterator _menu; PolymorphicList::iterator _world; PolymorphicList::iterator _fight;