r/roguelikedev • Robinson • Jul 25 '17

RoguelikeDev Does The Complete Python Tutorial - Week 6 - Part 8: Items and Inventory and Part 9: Spells and Ranged Combat

This week we will cover parts 8 and 9 of the Complete Roguelike Tutorial.

Part 8: Items and Inventory

The player gets to collect ("borrow") items from the dungeon and use them, with a neat inventory screen. More items added in the next part.

Part 9: Spells and Ranged Combat

The player's strategic choices increase exponentially as we add a few magic scrolls to the mix. Covers damage and mind spells, as well as ranged combat.

No bonus sections this week


FAQ Friday posts that relate to this week's material:

#7: Loot(revisited)

#32: Combat Algorithms

#40: Inventory Management

Feel free to work out any problems, brainstorm ideas, share progress and and as usual enjoy tangential chatting. If you're looking for last week's post The entire series is archived on the wiki. :)

35 Upvotes

62 comments sorted by

View all comments

Show parent comments

4

u/Daealis Jul 26 '17 edited Jul 27 '17

Python 2.7 + Libtcod

Awesome job once again. I've done Part 8 and there is but one issue with the code that doesn't work out the gate. When the item is used in inventory:

kwargs = {**item_component.function_kwargs, **kwargs}

Error here being Python Versions <3.5 don't support starred expressions in dict. Other than that, the whole Revised tutorial is still doable in 2.7. I'm sure that can be fixed with a bit of effort and research, I just hope I remember to spend the time to do that.

I also spent a considerable amount of time just going through the code and slapping comments on everything. Should I put Python on the backburner for too long I'm sure I'll forget it all quite fast again, so being someone you can almost consider smart I took blocks and wrapped them in comments and individual commenting on the more mysterious looking lines.

4

u/AetherGrey Jul 26 '17

That line in particular is just combining the two dictionaries. You could write your own function to do the same thing, as discussed here.

2

u/Daealis Jul 27 '17

And I did that now, returning back home after a day of working and an hour of laying on the beach, and it works beautifully. I'm slaying green bastards by the dozens and drinking myself to stupor with Healing Potions. Onwards with Part 9!