Closed bbarker closed 4 years ago
The reason I chose to use JSON encoding is because it would probably be the most reliable way of storing information of the bot, I assume it can be omitted, but I wanted to keep as much functionality in the PureScript side of things. What kind of issue are you running into?
@emiflake OK, was just curious, that sounds good to me.
Here's the error I get on this branch, haven't really looked into it yet:
Compiling Bot.Task
Error found:
in module Bot.Task
at src/Bot/Task.purs:23:18 - 23:56 (line 23, column 18 - line 23, column 56)
No type class instance was found for
Data.Argonaut.Encode.Generic.Rep.EncodeLiteral (Constructor "Hunting"
(Argument
(Maybe
{ x :: Number
, y :: Number
}
)
)
)
while applying a function encodeLiteralSumWithTransform
of type Generic t0 t1 => EncodeLiteral t1 => (String -> String) -> t0 -> Json
to argument identity
while inferring the type of encodeLiteralSumWithTransform identity
in value declaration encodeTask
where t1 is an unknown type
t0 is an unknown type
@emiflake OK, it should be fixed now - as soon as i looked at the JSON API, i found some relevant examples.
If you feel like it is fine, feel free to Squash & Merge.
One note: state now sort of keeps track of the hunting position in two places: last hunting position, and the hunting position of the current task (assuming the current task is hunting). I guess these could conceivable be different, though I haven't thought of a good use case yet, so we may want to revert to the previous definition of Hunting
and just keep the last hunting position in the state.
I was exploring this sort of way to allow a
Hunting
task to have a configurable parameter, which is also nice since by default you can just useNothing
while path finding is still in the works, and then it will just hunt nearby.However, this causes an error with the JSON encoding, so I wanted to ask your thoughts on this. Never used any JSONencoder in PS. Also, why do we need the JSON encoding (just curious)?