56 lines
2.3 KiB
C++
56 lines
2.3 KiB
C++
#ifndef VCORE_ADVENTURE_ECONOMY_POLICY_H
|
|
#define VCORE_ADVENTURE_ECONOMY_POLICY_H
|
|
#include "AdventureSocialFlow.h"
|
|
#include <algorithm>
|
|
#include <string>
|
|
|
|
namespace AdventureEconomyPolicy
|
|
{
|
|
enum class Service { None, Vendor, Bank, Auction, Repair, Any };
|
|
inline Service RequiredService(std::string const& kind)
|
|
{
|
|
if (kind=="vendor_visit" || kind=="goods" || kind=="trade" || kind=="vendor_compare") return Service::Vendor;
|
|
if (kind=="repair") return Service::Repair;
|
|
if (kind=="bank_visit" || kind=="banking") return Service::Bank;
|
|
if (kind=="auction_visit" || kind=="auctions") return Service::Auction;
|
|
if (kind=="service_wait" || kind=="service_finish") return Service::Any;
|
|
return Service::None;
|
|
}
|
|
inline std::string LocationRequirement(std::string const& category)
|
|
{
|
|
if (category=="economy_vendor") return "vendor_visit";
|
|
if (category=="economy_bank") return "bank_visit";
|
|
if (category=="economy_auction") return "auction_visit";
|
|
return "";
|
|
}
|
|
inline bool Economic(std::string const& kind)
|
|
{
|
|
return RequiredService(kind)!=Service::None || kind=="supplies";
|
|
}
|
|
inline bool Matches(std::string const& kind, bool vendor, bool banker, bool auctioneer, bool repairer=false)
|
|
{
|
|
switch (RequiredService(kind))
|
|
{
|
|
case Service::Vendor: return vendor;
|
|
case Service::Bank: return banker;
|
|
case Service::Auction: return auctioneer;
|
|
case Service::Repair: return repairer;
|
|
case Service::Any: return vendor || banker || auctioneer || repairer;
|
|
default: return false;
|
|
}
|
|
}
|
|
inline std::vector<AdventureSocialFlow::Step> Steps(std::string const& kind, uint32_t duration)
|
|
{
|
|
using namespace AdventureSocialFlow;
|
|
if (kind=="supplies") return {{Cue::Look,3000},{Cue::Nod,2000},{Cue::Listen,std::max(5000u,duration-std::min(duration,5000u))}};
|
|
if (kind=="service_wait") return {{Cue::Look,2000},{Cue::Listen,duration}};
|
|
if (kind=="service_finish") return {{Cue::Farewell,2000}};
|
|
if (RequiredService(kind)==Service::None) return {};
|
|
uint32_t const hold=std::max(6000u,duration-std::min(duration,12000u));
|
|
if (kind=="trade" || kind=="banking")
|
|
return {{Cue::Greet,2000},{Cue::Talk,4000},{Cue::Listen,hold},{Cue::Nod,2000},{Cue::Farewell,2000}};
|
|
return {{Cue::Greet,2000},{Cue::Look,hold},{Cue::Listen,4000},{Cue::Nod,2000},{Cue::Farewell,2000}};
|
|
}
|
|
}
|
|
#endif
|