PokemonGoF / PokemonGo-Bot

The Pokemon Go Bot, baking with community.
MIT License
3.87k stars 1.54k forks source link

[LVL 40] TypeError: unsupported operand type(s) for +: 'NoneType' and 'int' #6044

Open WayneUong opened 7 years ago

WayneUong commented 7 years ago

Traceback (most recent call last): File "pokecli.py", line 865, in main() File "pokecli.py", line 195, in main bot = start_bot(bot, config) File "pokecli.py", line 147, in start_bot bot.start() File "/Users/wayneuong/PokemonGo-Bot/pokemongo_bot/init.py", line 157, in start init_inventory(self) File "/Users/wayneuong/PokemonGo-Bot/pokemongo_bot/inventory.py", line 1461, in init_inventory _inventory = Inventory(bot) File "/Users/wayneuong/PokemonGo-Bot/pokemongo_bot/inventory.py", line 1305, in init self.refresh() File "/Users/wayneuong/PokemonGo-Bot/pokemongo_bot/inventory.py", line 1315, in refresh i.refresh(inventory) File "/Users/wayneuong/PokemonGo-Bot/pokemongo_bot/inventory.py", line 123, in refresh self.player_stats = self.retrieve_data(inventory) File "/Users/wayneuong/PokemonGo-Bot/pokemongo_bot/inventory.py", line 142, in retrieve_data self.parse(item) File "/Users/wayneuong/PokemonGo-Bot/pokemongo_bot/inventory.py", line 130, in parse self.exp = item.get('experience', 0) File "/Users/wayneuong/PokemonGo-Bot/pokemongo_bot/inventory.py", line 115, in exp self.level = self._level + 1 TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

MerlionRock commented 7 years ago

haha... sorry I've not reach level 40 yet...

Can you change your inventory.py at line 115 to the following and let me know if it solve the problem?

        if self._level < 40:
            if value >= self.next_level_xp:
                self.level = self._level + 1
                # increase next_level_xp to a big amount
                # will be fix on the next heartbeat
                self.next_level_xp += 10000000

        self._exp = value

I'll push for the fix once you get back to me

WayneUong commented 7 years ago

@MerlionRock It doesn't work. When I do print(self._level), it shows None.

crvfts commented 7 years ago

I replied to a USER in Slack about a month ago, suggesting a possible fix. They did what I suggested plus one additional edit and stated they were able to spin/catch again at level 40. Here is the convo snippet, hope it helps.

crvfts [12:16 PM] perhaps u can increase the MAX_LEVEL in inventory.py to 41 and then add something like " 41, 5000000, 25000000 " in xp_per_level.json so u can keep catching and spinning. may work. also may need to "level_limit": 41 in config

USER [2:32 PM] Thx @crvfts I changed the exp.setter in inventory.py from =self_level + 1 to = self_level in addition to your other suggestion and spinning and catching works.

frankblac commented 7 years ago

I can confirm that the following modifications work for me at level 40. However, running an account at lower levels with these modificiations will fail, so i cannot recommend it as a general code modification.

inventory.py: <self.level = self._level +1> changed to

xp_per_level.json add line <41, 10000000, 300000000> config.json, or whatever you named your config file:
frankblac commented 7 years ago

Seems like changing level_limit in config.json was not necessary. However, I forgot I had also disabled UpdateLiveStats in config.json. It won't run with the UpdateLiveStats task set to true.

MerlionRock commented 7 years ago

I don't have a level 40 account to troubleshoot this error. If anyone willing lend me an account to troubleshoot this error, please PM me in discord.

Preferably that account doesn't matter to you at all. (Because there might be a lot of invalid calls to server which might get account flagged or worst, banned)

pogarek commented 7 years ago

try this to fix: inventory.py : swap line 131 with 130, after changes it should be like this:

        self.level = item.get('level', 0)
        self.exp = item.get('experience', 0)

the second change would for UpdateLiveStats task, which uses xp_per_level.json file. just add new entry with some fake data, like :

    [
        41,
        50000000,
        200000000
    ]

Third change is to update_live_stats.py around line 259. Make it like this:

        level_completion_percentage = 100
        if whole_level_xp > 0 :            
            level_completion_percentage = int((current_level_xp * 100) / whole_level

Please let us know how it works for you (EDITED to fix to update_live_stats.py)

frankblac commented 7 years ago

It runs, but still issues with the update_live_stats.

frankblac commented 7 years ago

ok, some characters missing above perhaps: Runs fine now, including update_live_stats task

level_completion_percentage = 100 if whole_level_xp > 0 : level_completion_percentage = int((current_level_xp * 100) / whole_level_xp)

frankblac commented 7 years ago

note - I set level_limit = 42.. in config.json. At 41 it stopped - "You have reached your target level".

crvfts commented 7 years ago

@pogarek perhaps also need to make edit in update_live_stats.py at L147

  [39, 3000000, 15000000],
  [40, 5000000, 20000000],
  [41, 5000000, 20000000],
  [42, 5000000, 20000000]

along with what you just suggested.

crvfts commented 7 years ago

seems you could also set lvl 42 to a huge number so you don't need to accommodate for an infinite number of theoretical level increments. just have one final level of 41 or 42 that would take forever to complete.

MerlionRock commented 7 years ago

@pogarek, you want to create a PR for this?

pogarek commented 7 years ago

Let's get it tested first 😁

claudioferrari commented 7 years ago

@pogarek: your solution works fine, what about a PR for it?

Thanks