Item spell coverage calculation

This commit is contained in:
Yunfan Li
2024-08-11 02:10:50 +08:00
parent 7db30c96b8
commit 52b9dec2cd
8 changed files with 147 additions and 125 deletions

View File

@@ -172,6 +172,7 @@ public:
creators["naxx chat shortcut"] = &ChatActionContext::naxx_chat_shortcut;
creators["bwl chat shortcut"] = &ChatActionContext::bwl_chat_shortcut;
creators["tell expected dps"] = &ChatActionContext::tell_expected_dps;
creators["calc"] = &ChatActionContext::calc;
}
private:
@@ -268,6 +269,7 @@ private:
static Action* naxx_chat_shortcut(PlayerbotAI* ai) { return new NaxxChatShortcutAction(ai); }
static Action* bwl_chat_shortcut(PlayerbotAI* ai) { return new BwlChatShortcutAction(ai); }
static Action* tell_expected_dps(PlayerbotAI* ai) { return new TellExpectedDpsAction(ai); }
static Action* calc(PlayerbotAI* ai) { return new TellCalculateItemAction(ai); }
};
#endif

View File

@@ -4,10 +4,16 @@
*/
#include "TellLosAction.h"
#include <istream>
#include <sstream>
#include "ChatHelper.h"
#include "DBCStores.h"
#include "Event.h"
#include "ItemTemplate.h"
#include "ObjectMgr.h"
#include "Playerbots.h"
#include "StatsWeightCalculator.h"
#include "World.h"
bool TellLosAction::Execute(Event event)
@@ -130,3 +136,21 @@ bool TellExpectedDpsAction::Execute(Event event)
botAI->TellMaster("Expected Group DPS: " + std::to_string(dps));
return true;
}
bool TellCalculateItemAction::Execute(Event event)
{
std::string const text = event.getParam();
ItemIds ids = chat->parseItems(text);
StatsWeightCalculator calculator(bot);
for (const uint32 &id : ids)
{
const ItemTemplate* proto = sObjectMgr->GetItemTemplate(id);
if (!proto)
continue;
float score = calculator.CalculateItem(id);
std::ostringstream out;
out << "Calculated score of " << chat->FormatItem(proto) << " : " << score;
botAI->TellMasterNoFacing(out.str());
}
return true;
}

View File

@@ -37,4 +37,13 @@ public:
virtual bool Execute(Event event);
};
class TellCalculateItemAction : public Action
{
public:
TellCalculateItemAction(PlayerbotAI* ai) : Action(ai, "calculate item") {}
virtual bool Execute(Event event);
};
#endif

View File

@@ -157,4 +157,5 @@ ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : Pas
supported.push_back("guild leave");
supported.push_back("rtsc");
supported.push_back("drink");
supported.push_back("calc");
}

View File

@@ -121,6 +121,7 @@ public:
creators["bwl"] = &ChatTriggerContext::bwl;
creators["dps"] = &ChatTriggerContext::dps;
creators["disperse"] = &ChatTriggerContext::disperse;
creators["calc"] = &ChatTriggerContext::calc;
}
private:
@@ -221,6 +222,7 @@ private:
static Trigger* bwl(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "bwl"); }
static Trigger* dps(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "dps"); }
static Trigger* disperse(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "disperse"); }
static Trigger* calc(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "calc"); }
};
#endif