PokemonGo-Bot icon indicating copy to clipboard operation
PokemonGo-Bot copied to clipboard

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

Open WayneUong opened this issue 7 years ago • 15 comments

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'

WayneUong avatar May 16 '17 16:05 WayneUong

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

MerlionRock avatar May 17 '17 02:05 MerlionRock

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

WayneUong avatar May 17 '17 07:05 WayneUong

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.

crvfts avatar May 19 '17 03:05 crvfts

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 <self.level = self._level>

xp_per_level.json add line <41, 10000000, 300000000> config.json, or whatever you named your config file: <level_limit: 41>

frankblac avatar May 21 '17 09:05 frankblac

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.

frankblac avatar May 21 '17 14:05 frankblac

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)

MerlionRock avatar May 27 '17 02:05 MerlionRock

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)

pogarek avatar May 28 '17 10:05 pogarek

It runs, but still issues with the update_live_stats.

frankblac avatar May 28 '17 10:05 frankblac

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 avatar May 28 '17 11:05 frankblac

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

frankblac avatar May 28 '17 11:05 frankblac

@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 avatar May 28 '17 20:05 crvfts

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.

crvfts avatar May 28 '17 20:05 crvfts

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

MerlionRock avatar May 29 '17 03:05 MerlionRock

Let's get it tested first 😁

pogarek avatar May 29 '17 04:05 pogarek

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

Thanks

claudioferrari avatar Aug 01 '17 13:08 claudioferrari