-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented critical hits and weapon specific crit chance system #120
Merged
+67
−20
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7fc4c38
Added the critical hit popup and the damage multiplier
R1ndT c0e98bf
Added damageDealt to the enemy death message
R1ndT 571e6ee
Moved critical hit popup to it's own method
R1ndT bb819cc
Added logic to critical hit chance and damage
R1ndT 4e1bb31
Implemented a wapon specific crit chance system
R1ndT 2695bc7
Created a getter for "damageDealt" variable
R1ndT cc7b49a
Cleaned up the critical hit logic
R1ndT e1165d2
Implemented the weapon specific crit damage multiplier
R1ndT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a private var, and if you need to access it from another class create a
getter
for it :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I did not even know something like this existed until now :D I have to say that it is much more clever. Still, I posted a question in the commit resolving this issue. I would greatly appreciate if you answered it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also why can't I just make it a public variable and reference it anywhere? (This is probably common sense for you, but I do not really understand why not)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! This has to do with how Object-Oriented Programming works. Classes need to be initialized/created before you can use them. Think of them as templates. As I'm sure you're aware, you can have multiple instances of
Weapon
, each with its own values. The exception isstatic
variables/methods, which is tied to the class itself, instead of the instance of the class. SincegetDamageDealt()
is not static, that means its tied to the instance and you can not access it directly (even though it changes with each round, it technically is still a property ofWeapon
).Weapon.get()
is a static method for getting the currently "held" weapon. When calling this, you are actually getting the instance ofWeapon
, and notWeapon
itselfLet me know if this is still confusing, I can write a better example if needed!
here's a more technical answer
check this out as well
Note that most of these things usually aren't a problem in smaller projects like this, but become much more important in large projects with dozens of people sharing the same codebase; however, it's always smart to plan ahead and follow good coding styles!
Again, let me know if that still doesn't make sense and I can get better examples for you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I did not expect so constructive and comprehensible questions.
I think that I understand for now. I will feel your explanations in practice when programming today and check back here if I need something re-explained.
Thank you so much for the answers, they have really helped me a lot. I am the type of person who does not like doing something he does not understand, so you have essentially made my life a bit easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to reach out whenever, even with questions about your own projects (either code questions, or high-level concepts), or if you just want some code reviews on something! My email is available on my Github profile :)