Funds Kingdom::GetIncome(void) const { Funds resource; // captured object const u8 resources[] = { Resource::WOOD, Resource::ORE, Resource::MERCURY, Resource::SULFUR, Resource::CRYSTAL, Resource::GEMS, Resource::GOLD, Resource::UNKNOWN }; for(u8 index = 0; resources[index] != Resource::UNKNOWN; ++index) resource += ProfitConditions::FromMine(resources[index]) * world.CountCapturedMines(resources[index], GetColor()); // castles for(KingdomCastles::const_iterator it = castles.begin(); it != castles.end(); ++it) { const Castle & castle = **it; // castle or town profit resource += ProfitConditions::FromBuilding((castle.isCastle() ? BUILD_CASTLE : BUILD_TENT), 0); // statue if(castle.isBuild(BUILD_STATUE)) resource += ProfitConditions::FromBuilding(BUILD_STATUE, 0); // dungeon for warlock if(castle.isBuild(BUILD_SPEC) && Race::WRLK == castle.GetRace()) resource += ProfitConditions::FromBuilding(BUILD_SPEC, Race::WRLK); } // find artifacts const u8 artifacts[] = { Artifact::GOLDEN_GOOSE, Artifact::ENDLESS_SACK_GOLD, Artifact::ENDLESS_BAG_GOLD, Artifact::ENDLESS_PURSE_GOLD, Artifact::ENDLESS_POUCH_SULFUR, Artifact::ENDLESS_VIAL_MERCURY, Artifact::ENDLESS_POUCH_GEMS, Artifact::ENDLESS_CORD_WOOD, Artifact::ENDLESS_CART_ORE, Artifact::ENDLESS_POUCH_CRYSTAL, Artifact::UNKNOWN }; for(u8 index = 0; artifacts[index] != Artifact::UNKNOWN; ++index) for(KingdomHeroes::const_iterator ith = heroes.begin(); ith != heroes.end(); ++ith) resource += ProfitConditions::FromArtifact(artifacts[index]) * (**ith).GetBagArtifacts().Count(Artifact(artifacts[index])); // TAX_LIEN for(KingdomHeroes::const_iterator ith = heroes.begin(); ith != heroes.end(); ++ith) resource -= ProfitConditions::FromArtifact(Artifact::TAX_LIEN) * (**ith).GetBagArtifacts().Count(Artifact(Artifact::TAX_LIEN)); // estates skill bonus for(KingdomHeroes::const_iterator ith = heroes.begin(); ith != heroes.end(); ++ith) resource.gold += (**ith).GetSecondaryValues(Skill::Secondary::ESTATES); return resource; }
Artifact Dialog::SelectArtifact(u8 cur) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); LocalEvent & le = LocalEvent::Get(); std::vector<int> artifacts(static_cast<int>(Artifact::UNKNOWN), Artifact::UNKNOWN); cursor.Hide(); cursor.SetThemes(cursor.POINTER); for(size_t ii = 0; ii < artifacts.size(); ++ii) artifacts[ii] = ii; const u16 window_w = 370; const u16 window_h = 280; Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h); frameborder.Redraw(AGG::GetICN(ICN::TEXTBAK2, 0)); const Rect & area = frameborder.GetArea(); SelectEnumArtifact listbox(area); listbox.SetListContent(artifacts); if(cur != Artifact::UNKNOWN) listbox.SetCurrent(static_cast<int>(cur)); listbox.Redraw(); ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL); btnGroups.Draw(); cursor.Show(); display.Flip(); u16 result = Dialog::ZERO; while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents()) { result = btnGroups.QueueEventProcessing(); listbox.QueueEventProcessing(); if(!cursor.isVisible()) { listbox.Redraw(); cursor.Show(); display.Flip(); } } return result == Dialog::OK || listbox.ok ? Artifact(listbox.GetCurrent()) : Artifact(Artifact::UNKNOWN); }
void Battle::PickupArtifactsAction(HeroBase & hero1, HeroBase & hero2, bool local) { BagArtifacts & bag1 = hero1.GetBagArtifacts(); BagArtifacts & bag2 = hero2.GetBagArtifacts(); for(u8 ii = 0; ii < bag2.size(); ++ii) { Artifact & art = bag2[ii]; if(art.isUltimate()) { art = Artifact::UNKNOWN; } else if(art() != Artifact::UNKNOWN && art() != Artifact::MAGIC_BOOK) { BagArtifacts::iterator it = std::find(bag1.begin(), bag1.end(), Artifact((Artifact::UNKNOWN))); if(bag1.end() != it) { *it = art; if(local) { Game::PlayPickupSound(); Dialog::ArtifactInfo(_("You have captured an enemy artifact!"), "", art); } } art = Artifact::UNKNOWN; } } }
Battle::Catapult::Catapult(const HeroBase & hero, bool fortification) : cat_shots(1), cat_first(20), cat_miss(true) /*, cat_fort(fortification) */ { switch(hero.GetLevelSkill(Skill::Secondary::BALLISTICS)) { case Skill::Level::BASIC: cat_first = 40; cat_miss = false; break; case Skill::Level::ADVANCED: cat_first = 80; cat_shots += 1; cat_miss = false; break; case Skill::Level::EXPERT: cat_first = 100; cat_shots += 1; cat_miss = false; break; default: break; } u32 acount = hero.HasArtifact(Artifact::BALLISTA); if(acount) cat_shots += acount * Artifact(Artifact::BALLISTA).ExtraValue(); }
bool BagArtifacts::MakeBattleGarb(void) { iterator it1, it2, it3; it1 = std::find(begin(), end(), Artifact(Artifact::BREASTPLATE_ANDURAN)); it2 = std::find(begin(), end(), Artifact(Artifact::HELMET_ANDURAN)); it3 = std::find(begin(), end(), Artifact(Artifact::SWORD_ANDURAN)); if(it1 == end() || it2 == end() || it3 == end()) return false; *it1 = Artifact::UNKNOWN; *it2 = Artifact::UNKNOWN; *it3 = Artifact::UNKNOWN; PushArtifact(Artifact::BATTLE_GARB); return true; }
Artifact DominoConnector::CreateArtifact(HWND /*parentWindow*/,const std::wstring& AvailableFileFormats,std::wstring& NewFileName) { // HACKETY UNREFERENCED_PARAMETER(AvailableFileFormats); UNREFERENCED_PARAMETER(NewFileName); DominoDocOdmaUI::IOdmaUIPtr spNotesOdmaUI; //TODO: We really, really need a CreateInstance to deal with error handling. HRESULT hr = spNotesOdmaUI.CreateInstance(_T("DDocODMA.OdmaUI")); if(FAILED(hr)) { throw Workshare::Com::ComException(_T("Failed to create an instance of the Domino.Document Odma UI. This object is needed to display the UI to create an artifact. The Lotus Domino Document Manager may not be configured properly."), hr); } spNotesOdmaUI->DoModalSaveAs(); IDispatchPtr spResult = spNotesOdmaUI->GetSavedDocument(); if(spResult == 0) { Log(_T("The user selected to cancel the process to create a document")); return Artifact::GetNull(); } DominoDoc::IDocumentPtr spDocument = spResult; DominoDoc::ILibraryPtr spLibrary = spDocument->Library; Log(_T("A new place holder was created in the library, [%s], for document [%s]"), (const TCHAR*)spLibrary->url, (const TCHAR*)spDocument->Id); return Artifact(new DominoDocArtifact(spResult)); }
bool BagArtifacts::PushArtifact(const Artifact & art) { iterator it = std::find(begin(), end(), Artifact(Artifact::UNKNOWN)); if(it == end()) return false; *it = art; // book insert first if(art() == Artifact::MAGIC_BOOK) std::swap(*it, front()); return true; }
/* get rand all artifact */ int Artifact::Rand(level_t lvl) { std::vector<int> v; v.reserve(25); // if possibly: make unique on map for(u32 art = ULTIMATE_BOOK; art < UNKNOWN; ++art) if((lvl & Artifact(art).Level()) && !(artifacts[art].bits & ART_DISABLED) && !(artifacts[art].bits & ART_RNDUSED)) v.push_back(art); // if(v.empty()) { for(u32 art = ULTIMATE_BOOK; art < UNKNOWN; ++art) if((lvl & Artifact(art).Level()) && !(artifacts[art].bits & ART_DISABLED)) v.push_back(art); } int res = v.size() ? *Rand::Get(v) : Artifact::UNKNOWN; artifacts[res].bits |= ART_RNDUSED; return res; }
Artifact Artifact::FromMP2IndexSprite(u32 index) { if(0xA2 > index) return Artifact((index - 1) / 2); else if(Settings::Get().PriceLoyaltyVersion() && 0xAB < index && 0xCE > index) return Artifact((index - 1) / 2); else if(0xA3 == index) return Artifact(Rand(ART_LEVEL123)); else if(0xA4 == index) return Artifact(Rand(ART_ULTIMATE)); else if(0xA7 == index) return Artifact(Rand(ART_LEVEL1)); else if(0xA9 == index) return Artifact(Rand(ART_LEVEL2)); else if(0xAB == index) return Rand(ART_LEVEL3); DEBUG(DBG_GAME, DBG_WARN, "unknown index: " << static_cast<int>(index)); return Artifact(UNKNOWN); }
bool BagArtifacts::isFull(void) const { return end() == std::find(begin(), end(), Artifact(Artifact::UNKNOWN)); }