stefan2200 / TWB

Python based bot for Tribal Wars

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quest rewards

hideth opened this issue · comments

Seems to be broken for now in two places.

I managed to make it "almost working"

        get_rewards = re.search(r'RewardSystem\.setRewards\((\[\{.+?\}\]),', res) 
        ->
        get_rewards = re.search(r'RewardSystem\.setRewards\([\n\r\s]+(\[\{.+?\}\]),', res)

2nd broken part is everything that refers to self.resman.actual - which is being used to check if storage can hold the rewards amount. With commenting out checking for storage ( for t_resource in reward["reward"]: ) and self.logger.info("Got quest reward: %s" % str(reward)) part, everything else seems to work.

Maybe you can fix it easily. (it says something like self.resman.actual is not defined).

Hi, tbh I have no idea why the resource manager fails. actual should be always set tot a dict so probably something unloads it.
The quest rewards issue should not be too hard to fix, can you perhaps supply me with the RewardSystem HTML code?

rozpoczęły","101":"Zadania plemienia jeszcze się nie rozpoczęły"};
RewardSystem.setRewards(
[{"id":123,"player_id":123,"building":"hide","building_level":2,"status":"unlocked","reward":{"wood":150,"stone":150,"iron":100}}],
{"hide":{"ids":[123],"wood":150,"stone":150,"iron":100,"count":1}},
{"645745":{"game_link":"/game.php?village=123&screen=hide","image":"<img src="https://dspl.innogamescdn.com/asset/45436e33/graphic/buildings/mid/hide1.png" title="Schowek" alt="" class="bmain_list_img" />","name":"Schowek"}},
1 );
RewardSystem.setUnlockableRewards([{"building_level":11,"building":"main","game_link":"/game.php?village=123&screen=main","image":"<img src="https://dspl.innogamescdn.com/asset/45436e33/graphic/buildings/mid/main2.png" title="Ratusz" alt="" class="bmain_list_img" />","name":"Ratusz"},{"building_level":6,"building":"barracks","game_link":"/game.php?village=123&screen=barracks","im

Its seems like there was no linebreak before RewardSystem.setRewards( and later part.
And about 2nd issue I mentioned, it seems to work now, but it basically said
for t_resource in reward["reward"]: self.resman.actual[t_resource] += reward["reward"][t_resource] - something here was missing
`

Ah I see, if the regex fails then probably tries to access some stuff that isn't there.
Regarding the regex, this one should universally fix the line break: RewardSystem\.setRewards\(\s*(\[\{.+?\}\]),

I confirm, your suggestion fixed the issue.

Awesome, I just created a hotfix for this issue, thanks for addressing it!