Hey John, thank you very much for sharing your experience!
I don’t know what you mean by ‘merge’, but I understand the object orbiting part.
Let’s start with the code you used so far:
shouldOrbitOverviewEntry : EveOnline.ParseUserInterface.OverviewWindowEntry -> Bool
shouldOrbitOverviewEntry =
.objectName
>>Maybe.map(stringContainsIgnoringCase "broken")
>>Maybe.withDefault False
As a quick reminder for other readers, the objectName
field means we are looking at the text of the overview entry in the ‘Name’ column. To learn more about the parsed user interface of the EVE Online game client, see https://to.botlab.org/guide/parsed-user-interface-of-the-eve-online-game-client
In the current implementation of shouldOrbitOverviewEntry
, we can see the comparison of the object name to the string “broken” as you mentioned earlier.
To make it easier to follow the coding process, I am breaking this expansion down into two consecutive steps:
- Support multiple patterns to match the object name
- Support configuration via the bot settings
Support multiple patterns to match the object name
To start, we put the current preference of “broken” into a collection type, a type that supports any number of elements of the same type. We could use Set.Set String
here. I opted for List String
in this case. (One advantage of using a list instead of a set is that a list also enables us to encode priorities if more than one object matches the patterns.)
We can encode our list of patterns in a declaration like this:
overviewEntriesToOrbitNames : List String
overviewEntriesToOrbitNames =
[ "broken" ]
And here is how we can use that from shouldOrbitOverviewEntry
:
shouldOrbitOverviewEntry : EveOnline.ParseUserInterface.OverviewWindowEntry -> Bool
shouldOrbitOverviewEntry =
.objectName
>> Maybe.map
(\objectName ->
overviewEntriesToOrbitNames
|> List.any
(\objectNamePattern ->
stringContainsIgnoringCase objectNamePattern objectName
)
)
>> Maybe.withDefault False
We can rewrite that to the following more condensed syntax that yields the same results:
shouldOrbitOverviewEntry : EveOnline.ParseUserInterface.OverviewWindowEntry -> Bool
shouldOrbitOverviewEntry =
.objectName
>> Maybe.map
(\objectName ->
overviewEntriesToOrbitNames
|> List.any
(stringContainsIgnoringCase >> (|>) objectName)
)
>> Maybe.withDefault False
Support configuration via the bot settings
In that framework, the bot settings are available from eventContext.botSettings
in the BotDecisionContext
we have in our root function to decide the next action to take in the game client.
The existing code already has the BotDecisionContext
as parameter in decideActionInAnomaly
which invokes the new shouldOrbitOverviewEntry
So we only need to propagate it one function application further, adding a parameter for the settings in our new function:
shouldOrbitOverviewEntry : BotSettings -> EveOnline.ParseUserInterface.OverviewWindowEntry -> Bool
shouldOrbitOverviewEntry settings =
.objectName
>> Maybe.map
(\objectName ->
settings.overviewEntriesToOrbitNames
|> List.any
(stringContainsIgnoringCase >> (|>) objectName)
)
>> Maybe.withDefault False