Page MenuHomeWildfire Games

Cleanup damage type related code in cmpDamageReceiver and cmpDamage.
ClosedPublic

Authored by leper on Sep 3 2017, 2:41 AM.

Details

Reviewers
bb
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP20178: Cleanup damage type related code in cmpDamageReceiver and cmpDamage.
Summary

Should make it easy to change the schema to something along the lines of <oneOrMore> with somewhat arbitrary names. Would need a slight change to GetArmourStrengths to make that actually parse anything.

TODO: Is it the right choice to not deal any damage if that damage type isn't present in the armour?
I suspect it might make sense to warn in case that happens, and assume that modders will always specify everything.

Test Plan

Check that this doesn't break anything

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

leper created this revision.Sep 3 2017, 2:41 AM
Vulcan added a subscriber: Vulcan.Sep 3 2017, 3:33 AM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jenkins-master:8080/job/phabricator/1955/ for more details.

Vulcan added a comment.Sep 3 2017, 3:35 AM
Executing section Default...
Executing section Source...
Executing section JS...
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jenkins-master:8080/job/phabricator_lint/472/ for more details.

bb requested changes to this revision.Sep 4 2017, 1:55 PM
bb added a subscriber: bb.

changes seem sane also with the changes i planned on #252 in the back of my mind.

wrt TODO, we could also see it as a feature to not deal any damage, like we hack for siege engines, perhaps only this would be better done with an infinity tag or so. If we consider doing that (in another rev) mods should specify everything and a warning would be in place.

some style issues though:

binaries/data/mods/public/simulation/components/Armour.js
48 ↗(On Diff #3468)

(between 0 and 1)

AFAIK false since this is used for attack bonuses that can be anything positive (f.e. spearman vs cav have 3)

also caps and periods

49 ↗(On Diff #3468)

period

binaries/data/mods/public/simulation/components/tests/test_Damage.js
79 ↗(On Diff #3468)

no use for multiplier?

180 ↗(On Diff #3468)

spaces around *

181 ↗(On Diff #3468)

same

188–189 ↗(On Diff #3468)

same same

196–197 ↗(On Diff #3468)

^^

212–213 ↗(On Diff #3468)

Guess what xd

267–268 ↗(On Diff #3468)

hmmmpf change all below too

This revision now requires changes to proceed.Sep 4 2017, 1:55 PM
elexis added a subscriber: elexis.Sep 4 2017, 2:21 PM
elexis added inline comments.
binaries/data/mods/public/simulation/components/tests/test_Damage.js
79 ↗(On Diff #3468)

(While at whitespace warfare, I'd also welcome every statement being on a separate line in the entire JS code)

In D865#33874, @bb wrote:

changes seem sane also with the changes i planned on #252 in the back of my mind.

The main issue with that ticket (and others that are as old would be that they are very limiting. Going from 1 attack to 2 attacks is strange if we could just go from 1 to multiple.

wrt TODO, we could also see it as a feature to not deal any damage, like we hack for siege engines, perhaps only this would be better done with an infinity tag or so. If we consider doing that (in another rev) mods should specify everything and a warning would be in place.

Having thought about this a little more, it makes more sense to deal full damage in case there is no armor for a certain type of damage. Opinions?

binaries/data/mods/public/simulation/components/Armour.js
48 ↗(On Diff #3468)

Then the comment in Damage.js is a lie.

63 ↗(On Diff #3468)

Given some more thought it makes more sense to just deal the damage (with an armor strength of 0) when there is no armor for that type of damage.

binaries/data/mods/public/simulation/components/tests/test_Damage.js
79 ↗(On Diff #3468)

Mostly it isn't used by the code, but well I seem to have missed that one.

bb added a comment.EditedSep 5 2017, 12:33 AM
In D865#33989, @leper wrote:
In D865#33874, @bb wrote:

changes seem sane also with the changes i planned on #252 in the back of my mind.

The main issue with that ticket (and others that are as old would be that they are very limiting. Going from 1 attack to 2 attacks is strange if we could just go from 1 to multiple.

See my github for n attack types :P
https://github.com/bb-bb/0ad/tree/t252_secondAttack

wrt TODO, we could also see it as a feature to not deal any damage, like we hack for siege engines, perhaps only this would be better done with an infinity tag or so. If we consider doing that (in another rev) mods should specify everything and a warning would be in place.

Having thought about this a little more, it makes more sense to deal full damage in case there is no armor for a certain type of damage. Opinions?

maybe just warn?

See my github for n attack types :P
https://github.com/bb-bb/0ad/tree/t252_secondAttack

Assuming you mean the lower case branch instead of that one, that seems somewhat nicer than previous iterations I have seen.

wrt TODO, we could also see it as a feature to not deal any damage, like we hack for siege engines, perhaps only this would be better done with an infinity tag or so. If we consider doing that (in another rev) mods should specify everything and a warning would be in place.

Having thought about this a little more, it makes more sense to deal full damage in case there is no armor for a certain type of damage. Opinions?

maybe just warn?

Would be a possibility, but that would prevent mods from adding a few units with a new damage type (eg radiation) and corresponding armour (lead) that are good against units already present, but that do not have those types currently.

(Note that I think we should make the damage types optional (requiring at least one?) in most places so extending those is easier without breaking everything. Might make validation harder though.)

leper updated this revision to Diff 3495.Sep 5 2017, 3:37 AM

Deal full damage in case there is no armour for a given damage type.

Remove invalid part of a comment "(between 0 and 1)".
Fix spacing around *.

Vulcan added a comment.Sep 5 2017, 6:04 AM
Executing section Default...
Executing section Source...
Executing section JS...
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jenkins-master:8080/job/phabricator_lint/485/ for more details.

Vulcan added a comment.Sep 5 2017, 6:50 AM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jenkins-master:8080/job/phabricator/1970/ for more details.

bb added a comment.Sep 5 2017, 11:15 AM
In D865#33997, @leper wrote:

See my github for n attack types :P
https://github.com/bb-bb/0ad/tree/t252_secondAttack

Assuming you mean the lower case branch instead of that one, that seems somewhat nicer than previous iterations I have seen.

Nope my bad, didn't push the changes... first need that sound fix XD

bb accepted this revision as: bb.Sep 5 2017, 11:50 AM

Meh that cap,
Fine with the fact that no armour means 0 armour, someone who wants to yell about that should do it himself.

binaries/data/mods/public/simulation/components/Armour.js
48 ↗(On Diff #3495)

usually has a capital letter t

Care to accept as O2 too?

binaries/data/mods/public/simulation/components/Armour.js
48 ↗(On Diff #3495)

See the same thing in Damage.js. Also that isn't a proper sentence, so well.

49 ↗(On Diff #3468)

Might add that one when committing.

bb accepted this revision.Sep 6 2017, 10:45 AM

meh

This revision is now accepted and ready to land.Sep 6 2017, 10:45 AM
This revision was automatically updated to reflect the committed changes.