The idea of loot and reward is a good theory but I meant it only in the sense of gameplay, and I can prove it by "loot lockout": in World of Warcraft you can only get loot from a raid boss in a specific difficulty once a week. The next successes give you no reward (and you can't trade loot with someone who did get loot when you couldn't). However, I've still cleared the same bosses several times a week because they were also fun. It was guaranteed that I wouldn't get immediate -- or any -- rewards for my success but it was still fun and focusable.
Your experience is interesting because I played Diablo 3 when it first came out and shortly afterwards got bored because the loot wasn't interesting. Once I finished all of the difficulties in hardcore mode (before everything got nerfed beyond its initial release) I uninstalled. But, I somehow managed to put thousands of hours into Diablo 2 and Path of Exile, both of which have much more interesting items (at least to me). Maybe the reward aspect is more important to me in those types of games.
I get what you mean by the gaming tasks though. I used to play moba style games. Every second had something to think about, and really it's almost like you have to turn off your brain and just let your brain take over if that makes any sense. If you tried to explain the exact work flow of what you had to think about in 5 seconds it almost seems impossible, but somehow with enough practice it's effortless. Maybe when your brain is in that state, it's not possible to get distracted.
Most people can relate to that experience, of course. Its just a much bigger struggle for ADHD folks (hence, the self-image of laziness, lacking discipline, etc), and often takes medication to manage.
In a fast paced action game, everything tends to stimulating. In software development... its mixed bag for most of us!
Yes, this was indeed my point (alongside the micro-tasks point in my other reply): games are made to be flashy, stimulating and exciting. They're made to pull your attention, which makes them easier to focus on for someone with ADHD.
You have writing docs, writing tests, working on the user auth work flow / any app features, researching features / inspiration, designing a page, writing a bit of CSS, tinkering with the ops side of things (deployment / infra code), thinking about how you're going to generate traffic to it, writing blog posts or making videos surrounding your project idea and the list goes on.
You could bounce around all of that and could think "ok, what's next?" after completing any one of those things but for some reason it's not the same.
Although I guess another difference is games tend to have a lot of immediate rewards, or even more strongly, "potential" rewards. Like in your PvE MMO example. There's always a chance something might drop that will make your character better. Especially useful in games like path of exile (action RPG where your items / loot play a big factor) and even if the items you want don't drop, you're still gaining experience to level up your character which gives you ancillary rewards, and since it's a multiplayer game you could trade them with other people for things you want in return.
Where as with the coding project, there's really no rewards until it's done and even then there's no guarantee. You have to be content with just patting yourself on the back with a "hey good job, you finished writing tests for the user sign up work flow, now move onto X".
The same thing applies to writing to a lesser extent. There's research, coming up with a good example, writing sections / paragraphs, creating associated images, etc.. None of that really has immediate effects until it's fully done and you publish it, and even then, the publishing aspect might not even be the thing that motivates you to write it. Like, I've written 230ish blog posts but I write them with 0 expectations. I write them because they help me materialize what I'm learning or have learned, but sometimes it's difficult to write even if I think to myself that I want to.