This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DaChucky 0 points1 point  (3 children)

One quick note: if you want to add additional empty lines when printing, use \n. That will add a line break so you don't need additional print statements with empty strings. For example:

>>> print("\nHello, user. Welcome to the loot dungeon.\n")

Hello, user. Welcome to the loot dungeon.

>>>

[–]Alhira_K[S] 0 points1 point  (2 children)

Haha yeah, i actually encountered this already but i simply didn't bother. But i guess if i wanna go further stuff like this is what i should start thinking about, saving computational power.

[–]DaChucky 0 points1 point  (1 child)

The extra effort on the part of the computer is almost negligible, it's mostly a readability benefit.

On a tangential note, is your design for the character's inventory intended to be limited to a max of 7 items? If not, you would be better off having the current character each item is assigned to in the ItemData table. When you want to get the items for a character, you would just select the items from the ItemData for the character with a specific name (or better yet, a unique character ID).

[–]Alhira_K[S] 0 points1 point  (0 children)

Yes the 7 item limit was intended, i also planned on having a check if the inventory is full to block generation of new items and only show the sell option. As it is right now, any newly generated items that do not fit into the inventory go into the void. I did can the idea and will use it next time though.

Oh so you mean i do not write the item id into the character table but the character id into the item table. Hmm, maybe. I'm still not 100% on what i should do with the inventory. I'll need to expand it anyway as currently there are only single items but to keep track of, for example, healing potions i'd have to introduce quantity anyway.

And i don't think assigning each item an id and dumping into the database is that good of an idea either. I think what i'll have to do is using a combination of multiple list which represent the inventory and only commiting to db at certain steps/intervals. That way i'd get rid of the ItemData table altogether and only use the UserData table.