X-Git-Url: https://jfr.im/git/irc/gameservirc.git/blobdiff_plain/16655a315555e39af914860733ce17d7ef664d0d..9920617b5f77fa9d420300fdc9bfe5357938eecf:/gameserv-2.0/testdriver/main.cpp diff --git a/gameserv-2.0/testdriver/main.cpp b/gameserv-2.0/testdriver/main.cpp index 7cd45a1..4a8dcc7 100644 --- a/gameserv-2.0/testdriver/main.cpp +++ b/gameserv-2.0/testdriver/main.cpp @@ -4,45 +4,172 @@ using namespace std; using GameServ::GameLayer::GameObjects::PlayerGO; #include using GameServ::GameLayer::PlayerGL; +#include +using GameServ::GameLayer::ForestGL; +#include +using GameServ::GameLayer::FightGL; + +#include +using GameServ::GameLayer::GameObjects::ItemGO; +#include +using GameServ::GameLayer::GameObjects::WeaponGO; +#include +using GameServ::GameLayer::GameObjects::ArmorGO; +#include +using GameServ::GameLayer::GameObjects::PotionGO; +#include +using GameServ::GameLayer::GameObjects::MonsterGO; + #include using GameServ::Exceptions::GameServException; #include using GameServ::Types::Range; +using GameServ::Types::ItemTypes; +using GameServ::Types::Modifiers; + +#include +using namespace GameServ::GameLayer::Helpers; + +#include +#include +using boost::str; +using boost::format; + +#include +using boost::shared_ptr; + +string ItemInfo(shared_ptr spItem); +string MonsterInfo(shared_ptr spMonster); +string PlayerInfo(shared_ptr spPlayer); +void DisplayMonster(shared_ptr spMonster); +void DisplayPlayer(shared_ptr spPlayer); int main() { try { - //PlayerGL pgl; - //shared_ptr spPlayer = pgl.GetById("Kain"); - //cout << spPlayer->Name() << endl; - //spPlayer->Name("Kainazzzo"); - //pgl.Insert(spPlayer); - + PlayerGL pgl; + shared_ptr spPlayer = pgl.GetById("Kain"); + - map frequencies; - int x; - for (x = 0; x < 10000; x++) + + cout << "Name: " << spPlayer->Name() << endl + << "Level: " << spPlayer->LevelNumber() << endl + << "Exp: " << spPlayer->Experience() << endl + << "Strength: " << spPlayer->Strength() << endl + << "Defense: " << spPlayer->Defense() << endl + << "Gold: " << spPlayer->Gold() << endl + << "Bank: " << spPlayer->Bank() << endl + << "Items: " << endl; + + + + shared_ptr spInventory = InventoryManager::Instance(); + ItemList inventory = spInventory->GetInventory(spPlayer); + ItemList::const_iterator iter; + for (iter = inventory.begin(); iter != inventory.end(); iter++) { - Range testrange(-100, 100); - int randnum = testrange.Random(); - frequencies[randnum]++; + shared_ptr spItem = (*iter); + cout << ItemInfo(spItem) << endl; } - map::const_iterator iter; - for (iter = frequencies.begin(); iter != frequencies.end(); iter++) + + ForestGL forestGL; + FightGL fightGL; + string cmd = ""; + while (cmd != "quit") { - cout << iter->first << ": "; - cout << (iter->second / (double)(x + 1)) * 100 << '%' << endl; + spPlayer->Health(spPlayer->MaxHealth()); + spPlayer->Alive(true); + DisplayPlayer(spPlayer); + getline(cin, cmd); + if (cmd == "search") + { + cout << "Searching the forest..." << endl; + shared_ptr spMonster = forestGL.GetRandomMonsterForPlayer(spPlayer); + + while (spPlayer->Alive() && spMonster->Alive()) + { + DisplayMonster(spMonster); + cout << "Hit Enter to attack: " << endl; + getline(cin, cmd); + cout << "You hit " << spMonster->Name() << " for " << + fightGL.PlayerAttackMonster(spPlayer, spMonster) << endl; + if (!spMonster->Alive()) + { + cout << "You have killed " << spMonster->Name() << endl; + cout << "He shouts: " << spMonster->DeathCry() << endl; + } + else + { + cout << spMonster->Name() << " hits you with their " + << spMonster->WeaponName() << " for " << fightGL.MonsterAttackPlayer(spMonster, spPlayer) + << endl; + if (!spPlayer->Alive()) + { + cout << spMonster->Name() << " has killed you!" << endl; + } + } + } + } } + + + //map frequencies; + //int x; + //for (x = 0; x < 10000; x++) + //{ + // Range testrange(-100, 100); + // int randnum = testrange.Random(); + // frequencies[randnum]++; + //} + //map::const_iterator iter; + //for (iter = frequencies.begin(); iter != frequencies.end(); iter++) + //{ + // cout << iter->first << ": "; + // cout << (iter->second / (double)(x + 1)) * 100 << '%' << endl; + //} } catch (GameServException &e) { cout << e.VerboseError() << endl; } + cout << "Done. Hit enter to quit." << endl; string temp; - cin >> temp; + getline(cin, temp); return 0; } + +string ItemInfo(shared_ptr spItem) +{ + return str(format("Name: %1% Type: %2%") % spItem->Name() % ItemTypes::GetName(spItem->Type())); +} + +string MonsterInfo(shared_ptr spMonster) +{ + string info = str(format("Name: %1% Weapon: %2%\nStrength: %3% Defense %4% ") % + spMonster->Name() % spMonster->WeaponName() % spMonster->Strength() % + spMonster->Defense()); + info += str(format("Health: %1%/%2%") % spMonster->Health() % spMonster->MaxHealth()); + return info; +} + +string PlayerInfo(shared_ptr spPlayer) +{ + string info = str(format("Name: %1% Level: %2%\nHealth: %3%/%4%") % + spPlayer->Name() % spPlayer->LevelNumber() % spPlayer->Health() % + spPlayer->MaxHealth()); + return info; +} + +void DisplayMonster(shared_ptr spMonster) +{ + cout << "Monster:\n" << MonsterInfo(spMonster) << endl; +} + +void DisplayPlayer(shared_ptr spPlayer) +{ + cout << "Player:\n" << PlayerInfo(spPlayer) << endl; +} \ No newline at end of file