Opened 9 years ago

Closed 8 years ago

#350 closed defect (fixed)

Add requirement to allow N of unit for specific other units

Reported by: ibboard Owned by:
Priority: major Milestone: WarFoundry API 0.2
Component: WarFoundry-API Version:
Keywords: Cc:
Blocked By: #349 Blocking: #27

Description (last modified by ibboard)

We need a requirement equivalent to Rollcall's "N,id" for a unit (i.e. "you can take N of a given unit for every 1 of unit with id"). This will also require a factory.

It needs to be able to handle future extension, multiple units and varying numbers. It would be best to allow N of a unit for every M of a unit with id. An additive option (e.g. 2,a|b when you have 2 unit a and 3 unit b giving 2 * (2 + 3) = 10) would also be useful.

Change History (31)

comment:1 Changed 9 years ago by ibboard

Status: newaccepted

comment:2 Changed 8 years ago by ibboard

Description: modified (diff)

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

In [0922851f6125558595522cd3be4552942a36c713/IBBoard.WarFoundry.API]:

Re #350: Add requirement to allow N of unit for specific other units

  • Extend unit count requirement data to handle fixed numbers of units allowed per unit required
  • Add initial stub of requirement using some copy-and-paste, but starting to avoid ticket:379

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

In [410f3d85c9c5bc415e031ad9b6bb31f8978b8c75/IBBoard.WarFoundry.API]:

Re #350: Add requirement to allow N of unit for specific other units

  • Add code to get failure message for "allowed to add"
  • Refactor out common for checking if numbers exceed limits

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

In [5252dfb9cdfb9d8180fa2ef3bfd9723d7a96d699/IBBoard.WarFoundry.API]:

Re #350: Add requirement to allow N of unit for specific other units

  • Add code for validating army (based on code for validating adding)

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

In [0762766bd3f2cfd6137e46ad8547d44c70d1cc95/IBBoard.WarFoundry.API.Tests]:

Re #350: Add requirement to allow N of unit for specific other units

  • Remove static access to mock race - it broke tests
  • Add first tests for new requirement

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

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

Re #350: Add requirement to allow N of unit for specific other units

  • Add extra test to check failure of limit with specific values
  • Add extra lines to existing tests to check returned error

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

In [702a0957f9e43c280a3e1622e357a2ed447c29b7/IBBoard.WarFoundry.API.Tests]:

Re #350: Add requirement to allow N of unit for specific other units

  • Add army validation tests

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

In [baa34d91031f67bea41cede7dc3b9ab1599ce2d8/IBBoard.WarFoundry.API]:

Re #350: Add requirement to allow N of unit for specific other units

  • Correct "adding" validation message - we haven't added when we check if adding is okay

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

In [d2331ee59d74b66d965c1cc776fb8533c7c5e8f6/IBBoard.WarFoundry.API]:

Re #350: Add requirement to allow N of unit for specific other units

  • Add factory for requirement
  • Add extra method that assumes "allow N unit for every 1 unit"
  • Update/fix documentation

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

In [2b19d6f18f3a69a056675f24a1a76ca90a392e57/IBBoard.WarFoundry.API.Tests]:

Re #350: Add requirement to allow N of unit for specific other units

  • Correct expected output in tests - we haven't added when we check if adding is okay

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

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

Re #350: Add requirement to allow N of unit for specific other units

  • Add unit tests for having requirements on more than one unit type

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

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

Re #350: Add requirement to allow N of unit for specific other units

  • Add first unit tests for factory, based on existing factory unit tests

comment:14 Changed 8 years ago by ibboard

Format for requirements in data files should be something like:

<requirement requirementName=""><data>3:unitID1|2:unitID2</data></requirement>

to allow 3 of a unit for every one unitID1 and for every unitID2 (so 2 unitID1 and 2 unitID2 would allow up to 4 units, because 2*2 is the lowest).

Version 0, edited 8 years ago by ibboard (next)

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

In [5ac76de8ce628c8152c6df678b4c9996f30b6a48/IBBoard.WarFoundry.API]:

Re #350: Add requirement to allow N of unit for specific other units

  • Add code for parsing min numbers as well as allowed numbers

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

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

Re #350: Add requirement to allow N of unit for specific other units

  • Add tests for defining minimum amount as well as allowed amount (e.g. "2 of these allow 3 of those")

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

In [8e95ccb8e9d5500b15bd8741ce17719fc8ca631c/IBBoard.WarFoundry.API.Tests]:

Re #350: Add requirement to allow N of unit for specific other units

  • Add tests for multiple failures

comment:18 Changed 8 years ago by ibboard

Format for requirements in data files should now also allow something like:

<requirement requirementName="RequiresNUnitsForMUnits"><data>unitID1</data></requirement>
<requirement requirementName="RequiresNUnitsForMUnits"><data>unitID2:3</data></requirement>
<requirement requirementName="RequiresNUnitsForMUnits"><data>unitID3:2;3</data></requirement>
<requirement requirementName="RequiresNUnitsForMUnits"><data>unitID4:2|unitID5</data></requirement>

and any other combination of the above. These examples allow:

  • up to 1 of the unit for every unitID1
  • up to 3 of the unit for every unitID2
  • up to 3 of the unit for every 2 unitID3
  • up to 2 of the unit for every unitID2 or up to 1 of the unit for every unitID5 (whichever is lower)

The additive option on unit types (e.g. 2 unit a and 3 unit b giving up to N*(2+3) units allowed) is to follow.

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

In [206a45fdfa9ea8d16e23180d1af6ebde124fee20/IBBoard.WarFoundry.API]:

Re #350: Add requirement to allow N of unit for specific other units

  • Extend N for M requirement to start handling multiple unit types in an additive method
  • Extend requirement data object to handle multiple unit types

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

In [2d1bdd679f821f8c8b9e81393b431e9f6ea92714/IBBoard.WarFoundry.API]:

Re #350: Add requirement to allow N of unit for specific other units

  • Make method public so it is part of the API (additive units with an allowed number other than 1)
  • Fix up documentation

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

In [ca1e8f7c8b7308e617a94185434d143fb1aff4db/IBBoard.WarFoundry.API]:

Re: #350: Add requirement to allow N of unit for specific other units

  • Update army validation to support required amounts other than 1

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

In [4fbb7f205f7e4877f50c2a954cd0793b7a1e93ac/IBBoard.WarFoundry.API]:

Re #350: Add requirement to allow N of unit for specific other units

  • Extend factory to support additive unit types
  • Add three parameter method to requirement to set min, allowed and additive unit types

Note: Naughty code (untested) added to requirement to make factory compile! Needs testing.

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

In [dbd779cdc0f9b75ee06d3521c1d6d43a6ac0e8ad/IBBoard.WarFoundry.API]:

Re #350: Add requirement to allow N of unit for specific other units

  • Fix limit checking when "limited count" is not 1 (e.g. "need 2 for every 3")

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

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

Re #350: Add requirement to allow N of unit for specific other units

  • Add initial unit tests for handling multiple additive unit types

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

In [6a54d1787fbe6f752ef05c346679fa7e552eb2e8/IBBoard.WarFoundry.API.Tests]:

Re #350: Add requirement to allow N of unit for specific other units

  • Add big stack of test methods to test additive requirements with allowed values other than one
  • Add helper method to reduce repetition (used in new code, but not yet in old code)

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

In [925c37fa4febe3a78de0e10b527b982b2fe67919/IBBoard.WarFoundry.API.Tests]:

Re #350: Add requirement to allow N of unit for specific other units

  • Add unit tests for validating army, based on adding unit tests

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

In [6a0a0e228e3cc4efd836fc94dd6cc269215aa1bb/IBBoard.WarFoundry.API.Tests]:

Re #350: Add requirement to allow N of unit for specific other units

  • Add unit tests for additive requirements

Still need tests to make sure mixing additive with non-additive is handled correctly

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

In [43b571aa41245c0c4e8ceb627c483d741f616529/IBBoard.WarFoundry.API.Tests]:

Re #350: Add requirement to allow N of unit for specific other units

  • Add tests on factory for different combinations of additive and non-additive requirements

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

In [49e50238c3809a9f982a2c1b0683af29ecea4e36/IBBoard.WarFoundry.API.Tests]:

Re #350: Add requirement to allow N of unit for specific other units

  • Add unit tests to make sure we handle required values other than 1 (e.g. "need 2 for every 3") properly

comment:30 Changed 8 years ago by ibboard

Fixed as part of #379

comment:31 Changed 8 years ago by ibboard

Resolution: fixed
Status: acceptedclosed

Actually mark as fixed.

Note: See TracTickets for help on using tickets.