M
M
Mozzarella2018-04-05 20:31:21
C++ / C#
Mozzarella, 2018-04-05 20:31:21

How to modify c# decorator pattern so that it can be removed?

I am developing a game like HearthStone in c#. I'm trying to implement a buff system using the "decorator" pattern. There is a class Card

public abstract class Card
    {
        public string Name { get; set; }
        public string Description { get; set; }
        public int Health { get; set; }
        public int Damage { get; set; }
        public int Mana { get; set; }
    }

And there is a buff
public abstract class HealthBuff : Card
    {
        public string Name { get; set; }
        public string Description { get; set; }
        public int Health => base.Health + 2;
        public int Damage { get; set; }
        public int Mana { get; set; }
    }

And there can be many such buffs, so you need to remove them in this class hierarchy, if necessary. How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Griboks, 2018-04-05
@Griboks

Use component architecture instead of inheritance.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question