Use "getter" pattern to derive current stats in Pokemon class
See original GitHub issueI want to propose computing the current “real” stats for a pokemon at access time instead of constructor time. I think this might clean up some weird logic, and also make it easier to display the effect of stat boosts, items, and abilities on a pokemon’s real stats.
This could look like changing .stats
to .getStats()
on the Pokemon class, or if we want to be clever, it could even be a property “getter” pattern.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get
This would obviously require some refactoring in the calculation logic though, so I wanted to ask before investing any time in it.
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (15 by maintainers)
Top Results From Across the Web
Do you use the get/set pattern (in Python)? - Stack Overflow
In python, you can just access the attribute directly because it is public: class MyClass: def __init__(self): self.my_attribute = 0 my_object = MyClass() ......
Read more >jUq - River Thames Conditions - Environment Agency - GOV.UK
Corven 34529g, Ncaa football stats play by play, Pyro pete the ultra invincible ... Logitech c920 mac settings, Cumberbund pattern free, Thatcher rock...
Read more >How to Create an RPG Game in Unity – Comprehensive Guide
In this tutorial, we are going to build an RPG game using Unity. Our game will have three scenes: a title scene, a...
Read more >CodeWars-6-kyu-Soluitions - GitHub
Are they the "same"? ... Create Calculate the area of a regular n sides polygon inside a circl… ... Create Calculate the function...
Read more >Pokemon Turn Based battle (Python)
You have chosen a great problem to begin with, however there are a few things you get wrong about OOP. OOP is not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also don’t like getters in general; I think they make code less readable compared to just adding
()
after the variable name so it’s clear that it’s a function call.No, that’s not a hack, the constructors intentionally support
new Pokemon(pokemon)
to clone.