Opened 8 years ago

Closed 8 years ago

#366 closed defect (fixed)

Rewrite equipment handling and limits

Reported by: ibboard Owned by: IBBoard <dev@…>
Priority: critical Milestone: WarFoundry API 0.2
Component: WarFoundry-API Version: Unknown or N/A
Keywords: equipment limit ratio Cc:
Blocked By: Blocking:

Description

Bug #356 highlighted a bug in the equipment handling for units in conjunction with limits. While the bug can be fixed (it is just indirect recursion) there is a bigger underlying problem that was discovered during testing.

Because of the way that the equipment checks how big it could be (based on equipment and slot limits, where slots may contain multiple item types) and truncates itself appropriately then it is perfectly possible (e.g. line 51 in IBBoard.WarFoundry.API.Tests/API/Objects/UnitEquipmentLimitTests.cs @ revision 181:49b359624ea5 returns 0 when it should be 2 if we don't truncate or 1 if we work out how to resolve the conflict)

Change History (6)

comment:1 Changed 8 years ago by ibboard

Obvious solution struck me after I left the computer - don't truncate but instead throw validation errors. That should reduce the complexity and likelihood of looping while still also giving users control (and it is only the tiny fraction of cases, like the original "0.7% of a unit of three rounds up to one trooper", where this would be a problem that the UI won't stop).

comment:2 Changed 8 years ago by ibboard

Status: newconfirmed

comment:3 Changed 8 years ago by IBBoard <dev@…>

In [c8002429ab452d197e42d119d1bd1d3f78116798/IBBoard.WarFoundry.API]:

Re #366: Rewrite equipment handling and limits

  • Remove code added for #356 and work without limiting
  • Move "Calculate number taken" method to util class

comment:4 Changed 8 years ago by IBBoard <dev@…>

In [bd38c32fb1a9b83d75f543433161adf906eaed67/IBBoard.WarFoundry.API.Tests]:

Re #366: Rewrite equipment handling and limits

  • Remove comment added during #356 - now resolved
  • Add test for behaviour of percentages
  • Add test for new "calculate number taken" util method

comment:5 Changed 8 years ago by IBBoard <dev@…>

In [00ea622313bebba81762b6bc2ebf0ba5462b4c62/IBBoard.WarFoundry.API.Tests]:

Re #366: Rewrite equipment handling and limits

  • Add test for numeric amounts to make sure that they're not affected either

comment:6 Changed 8 years ago by IBBoard <dev@…>

Owner: set to IBBoard <dev@…>
Resolution: fixed
Status: confirmedclosed

In [ba9af0ce916a98622da89fdf3e703aee047b66ad/IBBoard.WarFoundry.API.Tests]:

Fixes #366: Rewrite equipment handling and limits

  • Add on more test to make sure that things behave as expected
Note: See TracTickets for help on using tickets.