News for hackers. Stuff that matters.
Re:The faster you unlearn OOP, the better for you and your s... by arriu on Sunday November 25, 2018 @09:22AM (#18526971)
This does read nicely in most cases.

There are minor issues when you venture off and decide that it would be cool if a monsters could damage your weapon. Something like Monster.hits(Weapon).with(Weapon). You'll start wondering if Weapon should inherit from the player base class. If not, you'll spend time wondering how to share the code to keep things dry. Obviously there are many solutions even within OOP, but one might consider looking to ECS to remove code duplication and decouple things.

Lots of good examples in the game programming patterns book: http://gameprogrammingpatterns.com/component.html

Re:The faster you unlearn OOP, the better for you and your s... by jryan49 on Sunday November 25, 2018 @09:25AM (#18526982)
I think damage to the weapon could still be handled in the Hit class, because Hit has a reference to Player and Monster and Weapon. You could even create different types of Hit classes that could execute different kinds of Hit behavior like this.

In that case it may be better to rename it to HitStrategy?

Re:The faster you unlearn OOP, the better for you and your s... by alasdair_ on Sunday November 25, 2018 @09:42AM (#18527048)
>You'll start wondering if Weapon should inherit from the player base class.

Probably not. If you want to do that, they should both implement an interface (and perhaps share some code through composition) but code inheritance is likely not the right approach here.