Skip to content
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

[Update] add check to make sure shield ac bonus is only added when one handed weapon is equipped #52

Open
KingFruit85 opened this issue Feb 1, 2020 · 8 comments

Comments

@KingFruit85
Copy link
Owner

No description provided.

@KingFruit85
Copy link
Owner Author

Oh, and wielder is proficient in shields...

@HedgehogHolly HedgehogHolly self-assigned this Feb 2, 2020
@HedgehogHolly
Copy link
Collaborator

Im attempting this one but I have a couple of questions...

  1. There is no property for one-handed weapon, so Im assuming if the property doesn't include two-handed weapons its a one-handed weapon?

  2. The function uses .some? which (from googling) say that it checks one of the elements passes but if we need multiple things to pass such as proficiency and one-handed weapon will we have to change .some to .every? (complete guess)

@KingFruit85
Copy link
Owner Author

  1. That's right, no one-handed property, but the versatile property means the weapon can be used either 1-h / 2-h.

So my thoughts are there are multiple approaches, either we decide for the user how they are going to be using their equipment or we present both sets of data, for example:

Character has a staff and a shield -> we force the character to use staff 2-h and disregard shield.
Or
Character has a staff and a shield -> we force the character to use staff 1-h and equip shield.
Or
Character has a staff and a shield -> we store the AC value of both shield & without shield and let the user decide.
Or
Some other way I haven't thought of.

I'll let you decide either way if you end up picking this up 👍

  1. From memory .some is a way of searching an array of objects for an object with a specific property. I think you should be able to use two conditionals by using the AND operator (&&), for example:
 if (weapons.some(item => item.name === "Shield") && (weaponProficiencies.some(item => item.name === "some Proficiency")) {
 //DO SOME STUFF
  }

You may have to play around and get creative if that doesn't work, always happy to help!

@KingFruit85
Copy link
Owner Author

Added proficiency check in logic

@KingFruit85
Copy link
Owner Author

@HedgehogHolly

This is how I added the prof check:

//Checks for the exsistance of a shield in the characters inventory and that they have proficiency to use one and applies ac bonus if these conditions return true.
if (
weapons.some(item => item.name === "Shield") &&
armorProf.includes("shields")
) {
AC += 2;
} else if (
weapons.some(item => item.name === "Wooden Shield") &&
armorProf.includes("shields")
) {
AC += 2;
}
return AC;
}

@HedgehogHolly
Copy link
Collaborator

The proficiency makes sense 🙂 I have no idea how you would solve for the one handed/two handed issue

@KingFruit85
Copy link
Owner Author

KingFruit85 commented Feb 4, 2020

@HedgehogHolly I need to sit down and have a proper think about it, but it could be as simple as wrapping the whole statement in another if loop that checks for the 1-h property on the weapon(so the code only executes if a 1-h weapon is present). But that would require adding the 1-h property to all the applicable weapons.

The more I think about it as I write I think displaying both sets of infomation is better for the user.

  • AC with shield
  • AC without shield

And maybe a refactor is in order to make it clear what the primary weapon is, so split the weapons collection into [primaryWeapon] & [otherWeapons]

Lots to think about!

@KingFruit85
Copy link
Owner Author

@HedgehogHolly

So after looking at this link Roll20-Weapons

If I have read it correctly, any weapon without the two-handed property can be used one-handed.

So I think finishing this off this issue will be as simple as adding a check for the two-handed property of the primaryWeapon variable when the AC bonus is being calculated, if it's found don't apply the AC bonus.

My recent change to the way inventories are arranged/stored should make this pretty straightforward, what do you think?

@HedgehogHolly HedgehogHolly removed their assignment Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants