[EnhanceYourCode] : the Builder Pattern, Part2
Hello, In the previous article, we explored the theory of the builder pattern. Let’s see a more concrete example : Let’s assuming that we are building a Role Playing Game core model. Here are the basic rules: A player can be a Hero : a Warrior, a Wizard, or a Thief (we keep it simple) Every Hero has 4 main characteristics: Health, Strength, Spirit, and Speed, that are counted in points. Heroes have a Level, and starting characteristics are based on this level (Health starts at Level * 10, Strength and Spirit start at Level * 5, and Speed starts at Level * 3) Warrior has a (+2 Strength, -2 Spirit) Modificator, Wizard has (+2 Spirit, -2 Strength) Modificator Player can improve 2 Characteristics of 1 points each or 1 characteristic of 2 points, in order to cutomize his Hero. A naive implementation of the Hero class would be : ...