question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use "getter" pattern to derive current stats in Pokemon class

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
Zarelcommented, Mar 16, 2020

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.

1reaction
Zarelcommented, Mar 16, 2020

I wrote this helper, but it seems to me it only sort of works by accident that most of the properties of a pokemon overlap with the shape the constructor expects.

No, that’s not a hack, the constructors intentionally support new Pokemon(pokemon) to clone.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found