Single post in PokeWalker errors while dowsing
Forum Index > Core > Bugs > PokeWalker errors while dowsing >
So in times like these, where I'm confused what's happening with my current code, I like to go high level and write pseudocode, and sometimes the steps I expect the user to take, assuming no errors or issues. Here's how I understand the dowsing process should run and the psuedocode for if I was writing it:
Pokewalker dowsing steps:
1. Player clicks on dowsing minigame
2. Minigame starts
3. Player clicks on a patch of grass
4. Pokewalker reports whether item is found, near, or far. Decrements one turn if item was not found.
5. Player clicks on a patch of grass, if item wasnt found
6. Pokewalker reports whether item was found or not
7. Player clicks again to return to menu.
Sorry if that's hard to follow: indenting is hard in forum posts.
Anyways, the main difference here I'd like to point out is I suggest having a "start" request for the minigame, that's different from the turns from searching grass. That way, the server would only recieve turn requests from the client after starting and wouldn't mistake it for a new dowsing attempt. If the user attempts a new one by opening a new PokeWalker window or by refreshing, etc. the server would recieve the new attempt request and drop the old one.
Edit: Sorry, it actually wouldn't drop the old attempt, if they were both open. But it would track them separately. So in theory the user could open a new window and if they have enough Watts could do two seperate attempts simultaneously, if both attempts have a unique identifier like the mutex string sent. It's weird behaviour, but I don't really think an issue (unless the user only has one open inventory space, and both attempts find an item, which I think was the intent with the check for inventory space in the current error handler)
Pokewalker dowsing pseudocode
When start dowsing minigame button is clicked:
If player has less than 3 Watts:
return Display Need Watts message
If player has a full inventory:
return Display Full Inventory message
Send start dowsing minigame request to server
When start request returns:
If request returns an error:
return (or report the error here? Either way attempt does not start)
While the player has turns, returned by the start request:
When the player chooses a grass patch:
Send search grass attempt to server
When the search grass attempt returns:
If request returns an error:
return (If the server for some reason forgets the dowsing attempt is happening and recieves a search attempt for the same mutex string, the returned error would be handled here, I suppose in that case end the attempt and maybe refund the Watts?)
If an item was found:
Show item to player
Add item to player inventory
When player clicks the middle button:
return to main menu
Else:
Disable the last clicked grass patch
Report the item find clue (It's near, not close...) to the player
Set local turns to turns from search response
(handed by server to prevent cheating)
Show where the item was
When player clicks the middle button:
return to main menu
Creator of PokeFarm Pokemon IVs;
a userscript that reports your best owned Pokemon.PM if you're interested in or are an IV breeder and you'd like to join our group!