Opened 11 years ago

Last modified 8 years ago

#27 confirmed enhancement

Define unit requirements

Reported by: ibboard Owned by:
Priority: major Milestone: WarFoundry API 0.2
Component: WarFoundry-API Version: Unknown or N/A
Keywords: Cc:
Blocked By: #52, #345, #350, #351, #365, #394, #396, #397, #398 Blocking: #29, #104, #278

Description

Rollcall had a concept of "use restrictions", which are the basis for WarFoundry "use restrictions". An initial basic implementation already exists but isn't extensively used or tested. A full set of use restrictions should be handled and available for different factories to create as necessary.

Change History (88)

comment:1 Changed 11 years ago by ibboard

Component: General/UnknownWarFoundry API

Rollcall restrictions:

  • N, UnitIDList - In this case the army may have N of this unit for each unit in the UnitIDList. Assume there are three X units and two Y units. Then 2,X|Y means you may have no more than 10 [2 * (3 + 2)] of this unit while 2,X,2,Y means you may have no more than 6 [2 * 3] or no more than 4 [2 * 2] of this unit.
  • -1, UnitIDList - The army must have at least one unit listed in the UnitIDList to be eligible to have this unit. Note that -1,X,-1,Y means the army must have at least unit X AND one unit Y while -1,X|Y means the army must have a unit X OR Y
  • -2. UnitIDList - The army may not have any unit listed in the UnitIDList to be eligible to have this unit. Note that -2,X,-2,Y is equivalent to -2,X|Y with the exception that two entries produce two warning messages.
  • -3, X -This unit cannot be chosen. This unit is only used as a champion. If X is 1 then the unit can have its own equipment, otherwise the equipment will match that of the parent unit.
  • -4,0 - This unit may be the army general but is not required to be so
  • -5,0 - This unit must be the army general.

-4 and -5 equivalents should be handled under #23. -3 is to be handled by #28.

comment:2 Changed 11 years ago by ibboard

Blocking: 29 added

comment:3 Changed 11 years ago by ibboard

Blocked By: 52 added

comment:4 Changed 11 years ago by ibboard

Summary: Define "unit requirements"Define unit requirements

comment:5 Changed 11 years ago by ibboard

Owner: ibboard deleted

Remove owner so that the team can more easily see bugs. Using default owners seems good at first but is bad practice when a team can be working on any part of the project.

comment:6 Changed 10 years ago by ibboard

Blocking: 104 added

comment:7 Changed 10 years ago by ibboard

Blocking: 57 added

comment:8 Changed 10 years ago by ibboard

Status: newconfirmed

Move tickets to new "confirmed" status to show that they've been checked

comment:9 Changed 10 years ago by ibboard

Blocking: 271 added

comment:10 Changed 10 years ago by ibboard

Blocking: 278 added

comment:7 Changed 9 years ago by ibboard

Milestone: WarFoundry 0.2WarFoundry API 0.2

Separate API milestone from UI milestone

comment:8 Changed 9 years ago by ibboard

Blocking: 57 removed

(In #57) Ticket doesn't make sense any more - we're defining the spec as we go and relying on backward/forward compatibility so there is no "complete" to load.

comment:9 Changed 9 years ago by ibboard

Version: Unknown or N/A

A list of requirements has been collected in this thread. In addition to unit requirements (what must/must not be taken before a unit can/can't be taken) we also need to consider equipment requirements.

The current list of requirements is:

  • Must have one (or more) of unit Y to take any number of unit X (e.g. "must have at least one bowman unit to take Borris the Bowman special character")
  • Can have up to A units of X for every B of unit Y (e.g. "can have up to three slave units for each normal unit")
  • Cannot have any of Y to take X (e.g. "cannot have any flame demons if you take dryads")
  • Unit X makes unit Y count as cat A instead of cat B (mainly occurs with special characters moving special choices to core choices)
  • Unit X requires Z number of models of unit Y (e.g. "Doomsayer can only be taken if there are 15 or more flagelants")
  • Unit X can only be taken in armies of Y points and above (e.g. "Grand High Emperor can only be taken in armies of 3000pts or more)
  • Unit must take item X to have equipment item Y (e.g. "must have Mark of Warrior God to take Axe of Warrior God")
  • Equipment item X can only be taken Y times per army (e.g. "rare scroll can only be taken three times per army")
  • Points limits on unit equipment (e.g. "up to 40pts spent on any combination of items Q, R, S...Y or Z")
  • Equipment X can only be taken in armies of Y points and above (e.g. "Historic National Battle Standard can only be takin in armies of 3000pts or more")

comment:10 Changed 9 years ago by ibboard

In [831]:

Re #27: Define unit requirements

  • First skeleton of first new style requirement

comment:11 Changed 9 years ago by ibboard

In [832]:

Re #27: Define unit requirements

  • First test for first new style requirement
  • Update some of the Mock objects to add a few more required elements (mainly Category)

comment:12 Changed 9 years ago by ibboard

In [833]:

Re #27: Define unit requirements

  • Refactor out common code
  • Simplify tests to try with one unit type required at first
  • Add test where requirement is satisfied

comment:13 Changed 9 years ago by ibboard

In [834]:

Re #27: Define unit requirements

  • Add checking for passing requirements

comment:14 Changed 9 years ago by ibboard

In [835]:

Re #27: Define unit requirements

  • Add tests to cover UnitType, since we'll often be checking if we can create a unit rather than creating and adding it

comment:15 Changed 9 years ago by ibboard

In [836]:

Re #27: Define unit requirements

  • Change method definition to be able to handle both Unit and UnitType

comment:16 Changed 9 years ago by ibboard

In [837]:

Re #27: Define unit requirements

  • Update method name for a more "natural language" approach of "if (req.AllowsAdding(...))"

comment:17 Changed 9 years ago by ibboard

In [838]:

Re #27: Define unit requirements

  • Update method name for a more "natural language" approach of "if (req.AllowsAdding(...))"

comment:18 Changed 9 years ago by ibboard

In [839]:

Re #27: Define unit requirements

  • Add unit tests for multiple unit types being required

comment:19 Changed 9 years ago by ibboard

In [840]:

Re #27: Define unit requirements

  • Rename class to match behaviour (no longer just units)

comment:20 Changed 9 years ago by ibboard

In [841]:

Re #27: Define unit requirements

  • Rename class to match behaviour (no longer just units)
  • Move to correct package

comment:21 Changed 9 years ago by ibboard

In [842]:

Re #27: Define unit requirements

  • Add tests where a min count > 1 is set

comment:22 Changed 9 years ago by ibboard

In [843]:

Re #27: Define unit requirements

  • Implement code for min limits > 1

comment:23 Changed 9 years ago by ibboard

In [844]:

Re #27: Define unit requirements

  • Add unit tests for validating an existing army without adding anything to it

comment:24 Changed 9 years ago by ibboard

In [845]:

Re #27: Define unit requirements

  • Add new method for validating an existing army
  • Refactor existing code into new method

comment:25 Changed 9 years ago by ibboard

In [846]:

Re #27: Define unit requirements

  • Add last unit test to get more obvious behaviour equivalent to Rollcall's "-1" (can take unlimited X once one Y is taken)

comment:26 Changed 9 years ago by ibboard

In [847]:

Re #27: Define unit requirements

  • Document methods
  • Add new method that provides default "must have at least one" behaviour - "must have at least N to take unlimited" (where N is greater than 1) is probably less common

comment:27 Changed 9 years ago by ibboard

In [848]:

Re #27: Define unit requirements

  • Rebuild and add unit test for "no more than N" requirement

comment:28 Changed 9 years ago by ibboard

In [849]:

Re #27: Define unit requirements

  • Make use of default value in "Requires at least N"
  • Add initial implementation of "No more than N"

comment:29 Changed 9 years ago by ibboard

In [851]:

Re #27: Define unit requirements

  • Copy and paste first requirement that does "requirement for unit type"

comment:30 Changed 9 years ago by ibboard

In [852]:

Re #27: Define unit requirements

  • Copy and paste first requirement unit test that does "requirement for unit type"

comment:31 Changed 9 years ago by ibboard

In [858]:

Re #27: Unit requirements

  • Add unit tests for when the unit with the prerequisite doesn't exist (requirement needn't hold)

comment:32 Changed 9 years ago by ibboard

In [859]:

Re #27: Unit requirements

  • Add "is applicable" checking to army validation

comment:33 Changed 9 years ago by ibboard

In [860]:

Re #27: Unit requirements

  • Add tri-state enum (passed, failed, not applicable)

comment:34 Changed 9 years ago by ibboard

In [861]:

Re #27: Unit requirements

  • Add tri-state enum (passed, failed, not applicable) and helper class

comment:35 Changed 9 years ago by ibboard

In [862]:

Re #27: Unit requirements

  • Switch to enumeration and update tests as appropriate

comment:36 Changed 9 years ago by ibboard

In [863]:

Re #27: Unit requirements

  • Update "Requires at least" requirements to use new enum

comment:37 Changed 9 years ago by ibboard

In [864]:

Re #27: Unit requirements

  • Switch remaining unit requirement to using enum

comment:38 Changed 9 years ago by ibboard

In [865]:

Re #27: Unit requirements

  • Switch to using validation enum
  • Add tests for unit type

comment:39 Changed 9 years ago by ibboard

In [866]:

Re #27: Unit requirements

  • Correct documentation
  • Add "limit to none" method

comment:40 Changed 9 years ago by ibboard

In [867]:

Re #27: Unit requirements

  • Test limit setting for "no more than" requirement

comment:41 Changed 9 years ago by ibboard

In [868]:

Re #27: Unit requirements

  • Add test to make sure that requirement actually revalidates after change

comment:42 Changed 9 years ago by ibboard

In [869]:

Re #27: Unit requirements

  • Quick first draft of unit tests for "unit requires no more than X"

comment:43 Changed 9 years ago by ibboard

In [870]:

Re #27: Unit requirements

  • First draft of "Unit requires no more than X" requirement

comment:44 Changed 9 years ago by ibboard

In [871]:

Re #27: Unit requirements

  • Test threshold
  • Test that default setting is 0
  • Test that "No more than" requirement gives "N/A" when appropriate

comment:45 Changed 9 years ago by ibboard

In [872]:

Re #27: Unit requirements

  • Restructure "check default" tests so that we actually check the default (test before and after)
  • Add test to make sure requirement checks on each request
  • Add test to make sure that adding more prohibited units than the limit causes a failure

comment:46 Changed 9 years ago by ibboard

In [873]:

Re #27: Unit Requirements

  • Take unit being added into account

comment:47 Changed 9 years ago by ibboard

In [874]:

Re #27: Unit Requirements

  • Test base "no more than" requirement validates armies correctly

comment:48 Changed 9 years ago by ibboard

In [875]:

Re #27: Unit requirements

  • Add test for adding required unit types to satisfy requirements

comment:49 Changed 9 years ago by ibboard

In [876]:

Re #27: Unit requirements

  • Add matching test for unit type requiring at least N units

comment:50 Changed 9 years ago by ibboard

In [877]:

Re #27: Unit requirements

  • Make basic "Requires at least" requirement take into account the unit type being added
  • Make unit version of "requires at least" requirement pass execution up to the matching parent method

comment:51 Changed 9 years ago by ibboard

In [880]:

Re #27: Unit requirements

  • Add first test for getting requirements from race

comment:52 Changed 9 years ago by ibboard

In [881]:

Re #27: Unit requirements

  • Add base interface for all requirements and extend it in existing requirements
  • Add stub method for getting requirements of race (UnitTypes need to be able to add them first before testing goes further)

comment:53 Changed 9 years ago by ibboard

In [882]:

Re #27:

  • Start testing adding requirements to unit types

comment:54 Changed 9 years ago by ibboard

In [883]:

Re #27: Unit requirements

  • Obsolete methods using the old requirements system
  • Switch to new IRequirement objects

comment:55 Changed 9 years ago by ibboard

In [884]:

Re #27: Unit requirements

  • Test getting all unit requirements for race

comment:56 Changed 9 years ago by ibboard

In [885]:

Re #27: Unit requirements

  • Implement getting all requirements from unit types of race

comment:57 Changed 9 years ago by ibboard

In [886]:

Re #27: Unit requirements

  • Initial rebuild of tests so that we check for "N/A" in more of the appropriate cases for adding units

comment:58 Changed 9 years ago by ibboard

In [887]:

Re #27: Unit requirements

  • Rebuild base "at least" requirement to say "N/A" when added unit isn't constrained
  • Remove duplicate code from "unit requires at least" requirement and override where necessary

comment:59 Changed 9 years ago by ibboard

In [891]:

Re #27: Unit requirements

  • Add unit test for unit requirements in opposite order
  • Add unit test to make sure that requirement doesn't lock to first result, even after changes

Also:

  • Clean up line endings to meet policy

comment:60 Changed 9 years ago by ibboard

In [892]:

Re #27: Unit requirements

  • Start writing tests for requirement handler
  • Add mocks to support tests

Note: NA test currently fails (expect pass but get fail)

comment:61 Changed 9 years ago by ibboard

In [893]:

Re #27: Unit requirements

  • Add initial requirement handler class
  • Add method to get requirements for army (currently falls back to Race)

comment:62 Changed 9 years ago by ibboard

In [894]:

Re #27: Unit requirements

  • Tidy up line endings
  • Fix unit tests to mask (logical AND) instead of ORing

comment:63 Changed 9 years ago by ibboard

In [895]:

Re #27: Unit requirements

  • Bit mask the values with a bitwise AND rather than an OR

comment:64 Changed 9 years ago by ibboard

In [896]:

Re #27: Unit requirements

  • Add tests for mixed requirements
  • Add tests for adding units

comment:65 Changed 9 years ago by ibboard

In [897]:

Re #27: Unit requirements

  • Implement check for adding units to army

comment:66 Changed 9 years ago by ibboard

In [899]:

Re #27: Unit requirements

  • Make sure that units return their limits as requirements on the army

comment:67 Changed 9 years ago by ibboard

In [900]:

Re #27: Unit requirements

  • Initial work to try to make unit types return requirements for count limits
    • Add requirements when limits aren't defaults
    • Start adding equality/hash code methods

comment:68 Changed 9 years ago by ibboard

Blocked By: 345 added

comment:69 Changed 9 years ago by ibboard

Blocking: 344 added

comment:70 Changed 9 years ago by ibboard

Blocking: 344 removed

comment:4 Changed 9 years ago by ibboard

In [932]:

Re #27: Unit requirements

  • Remove old requirements

comment:5 Changed 9 years ago by ibboard

"-1" requirement should mainly be handled by UnitRequiresAtLeastNUnitsRequirement class (you can have any number as soon as you have N of the specified units, defaulting to 1) - OR option isn't handled yet. Schema to be added under #347.
"-2" requirement should now be handled by UnitRequiresNoMoreThanNOfUnitTypeRequirement (you can have any number as long as you have no more than N, defaulting to 0) - OR behavior isn't an important change and just requires separate requirements. Schema to be added under #348.

comment:6 Changed 9 years ago by ibboard

Blocked By: 350 added

comment:7 Changed 9 years ago by ibboard

In [934]:

Re #27: Define unit requirements

  • Remove remaining references to old Requirements namespace

comment:8 Changed 9 years ago by ibboard

Blocked By: 351 added

comment:9 Changed 8 years ago by ibboard

Blocked By: 365 added

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

In [3882b533d99d3a578dba06238c74fdfabbfcc134/IBBoard.WarFoundry.API]:

Re #27: Define unit requirements

  • Add ID to requirements so that it isn't just defined in factories
  • Make factory use ID from requirement class to avoid duplication and possible mismatch

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

In [8f512574031669bd28917a5870e19231a023d6bd/IBBoard.WarFoundry.API]:

Re #27: Define unit requirements

  • Move definition and documentation of ID up to interface to ensure it is everywhere

comment:12 Changed 8 years ago by ibboard

Blocked By: 394 added

comment:13 Changed 8 years ago by ibboard

Blocked By: 396 added

comment:14 Changed 8 years ago by ibboard

Blocked By: 397 added

comment:15 Changed 8 years ago by ibboard

Blocked By: 398 added

comment:16 Changed 8 years ago by ibboard

Some of the requirement ideas have been moved out to ticket:399 because they're related to equipment more than units.

comment:17 Changed 8 years ago by ibboard

Blocking: 271 removed

(In #271) Dupe - better explained in #396.

Note: See TracTickets for help on using tickets.