Blu3wolf/CNA-Assistant

Combat as it relates to Unit objects

Opened this issue · 3 comments

In the Combat Segment of the turn, the Phasing player (whose Combat Segment it is) must attack Enemy hexes which are exerting Zones of Control against Friendly units. They may also attack Enemy hexes which are adjacent to Friendly units (these would be units not exerting Zones of Control, either due to low size (in Stacking Points), low raw defensive stats, or due to terrain. If the Enemy unit cannot enter the hex the Friendly unit is in, it does not exert a Zone of Control, and Zones of Control do not cross Rivers or Escarpments).

In the Combat Segment, each unit may perform Barrage, Retreat Before Assault, Anti-Armor, and Close Assault (Defensive for the non-Phasing player, and Offensive for the Phasing player). Each of these is going to need separate methods, as each type of action happens for all units before the next happens for any unit.

The first interaction then needs to be informing the software the location of all Enemy-occupied hexes which are adjacent to Friendly units. Initially this will be via text entry, but finally this would be via a GUI where the user can click to select hexes while being shown their units in position on the hex map, and using the underlying graphic to indicate location. If the user is phasing (offender, attacking on their turn), they need to also indicate whether the hexes are exerting a Zone of Control on the Friendly units. This can be skipped for the non-phasing (defensive, off-turn) player.

Barrage
After determining which units are undergoing combat (any adjacent units determined above), the software lists Friendly gun-class units, grouped by hex. For each unit, the user chooses to place the unit Forward or Back. This status persists until the beginning of the next Combat Segment. Once all units are placed either Forward or Back, the software displays a confirmation button, which when clicked finalises unit positions for the Segment.

The software displays a list of hexes, which were Friendly-occupied and adjacent to the Enemy-occupied hexes selected above. Each hex can be double clicked to open the hex, and this opens a drop down menu, which contains all units in that hex. Hexes which do not contain firing units (placed Forward or Back) are highlighted in yellow, and placed at the end of the list. This list can be shown to the Enemy player, or optionally printed for that purpose (as the closed box only displays a hex number, this does not reveal tactical information to the Enemy player). The user can mark units as non-firing (usually for ammunition conservation). They may also mark an entire hex as non-firing. If all units in a hex are non-firing, that hex will change to be highlighted yellow and moved to the end of the list. If it is changed back to firing, the color will change and the hex moved ahead of all non-firing hexes.

The user can also input on this screen Targets, which are entered by selecting a target hex and a unit class. Optionally, Targets can be named, but if they are not, the software will generate a name for them: "Nr1 Inf, Nr2 Inf, Nr1 Arty, Nr1 Tank, etc". The user is provided this information by the Enemy player, based on the list of Firing hexes the user provided to the enemy player. On the same screen, the User can select hexes and designate them as 'Under Fire'. Hexes so designated are used to generate a list of Targets for the enemy player. This information is displayed on screen in a new window, which can be printed optionally. The list of Targets is similarly obfuscated, showing only the class of each target. Valid targets to display in a hex include all btn or coy sized units with Stacking Points, dummy tank units, commonwealth warships, and Facilities, including Major Cities, Fortifications, Roads, Railroads, Supply Dumps, and Air Facilities. HQ units without TOE Strength Points, or with parenthesized Assault Ratings, are not valid targets. Commonwealth Warships are historically identified targets - they are not obfuscated for presenting Target information to the Enemy, if the User is Commonwealth, and if the user is Axis targeting Commonwealth warships, they can enter the specific ship they are targeting.

Once the User has entered all Targets provided by the enemy player, and has provided the enemy player with same, they can proceed to plan their Barrages by way of a Plan Barrages button. Clicking this moves to the next window, which lists enemy Targets, grouped by hex. If the user is Phasing, and a hex has Barrage Plan(s) planned against it with more total Actual Barrage Points than there are separate, non-gun battalion-equivalent units in it, it is highlighted blue to indicate that the hex is 'held-off'. In a separate table, firing units are listed, grouped again by hex. Units which were manually marked as non-firing in the previous window are omitted. Double clicking a Target opens a Barrage Plan window. A Target may have only one Barrage Plan, so double clicking a Target which has a Barrage Plan already, opens that Barrage Plan for editing, rather than creating a new one.

The Barrage Plan window, when opened, indicates the name of the Target, and the hex the target is located in. If the Target has a custom name, the window also indicates the Type of the target. If the Barrage Plan is the cause of 'held-off' status, a status is shown saying "holding off". If the target hex is 'held-off' by another Barrage Plan(s) not requiring this one, a status is shown saying "held off". Below the target information, the window lists up to 6 Barrages.

Each Barrage indicates which (adjacent) hexes it originates from, and no two Barrages may originate from the same hex or hexes. A Barrage originates from all hexes occupied by firing units assigned to that Barrage. Each Barrage lists all firing units assigned to that Barrage - either a single unit placed Back, or one or more unit(s) placed Forward. Each Barrage displays the number of Actual Barrage Points assigned to the Barrage.

Below the list of Barrages, the window lists all adjacent firing units to the Target which are not currently assigned to this Barrage Plan (i.e., not assigned to any of the Barrages which make up the Barrage Plan). Units are color coded based on their status for assignment. They are listed in two separate tables, depending on whether they are Forward or Back.

The User may select an appropriately colored unit from the list at the bottom to create a new Barrage against the Target. The User may select a Barrage first, then select a unit to add to that Barrage. When the user selects a Barrage, the color coding for the units will change appropriately. The User may also delete a Barrage wholesale, or remove individual units from it.

Units are colored by status. The statuses for coding are unit out of ammo, unit already tasked to a different Barrage Plan, unit invalid to assign. Units may be invalid to assign for several reasons, which should be indicated by tooltip. For example, when no Barrage is selected, the color coding is to indicate either a single unit (Back), or unit(s) (Forward), to form a new Barrage. If the unit(s) selected are in a hex which a Barrage already originates from, they are invalid to select (and should be either added to that Barrage, or a different Target (and thus a different Barrage Plan) selected.

{It may prove simpler to have this work this way in the background, and in the foreground, have the User select firing units from a list, and assign those units, Targets? Having Barrage Plans and Barrages built up in that fashion, for review later. The process being select firing units from a list, assign a target to selected units, repeat. Instead of select a target, select firing units, repeat. However its done, it should be a UI consideration. The underlying model can still probably work this way, though}

Once the User has assigned targets to all firing units, they are presented the option to resolve Barrages. The Barrage Resolution window displays friendly units that were Targets for the enemy, and enemy Targets, in two separate tables. Barrages may be resolved in any order desired. The user may select a friendly unit to apply Barrage Results against, or a Barrage to determine results of fire against the enemy player (in which case the results are relayed to the enemy player by whatever means appropriate). Casualties are noted on the (friendly) target unit, but not applied until the end of the Barrage step. Friendly units are shown with both their actual designation, and the obfuscated name that was shown to the enemy player. This aids the user in locating the target the enemy player is barraging (targeting Inf nr1, etc).

Selecting a friendly unit, the window shows the possible results to apply to the unit selected (Pinned, 1 or 2 points of TOE Strength Damage, and if Trucks are attached to the unit or its parent, a number of Trucks to mark as Damage (destroyed). The unit will also (probably) expend CPA. Results are only tracked now, and applied at the end of the Barrage step.

Selecting a Target will open its Barrage Plan in a slightly different window - still listing target information and all Barrages, but now the context options are to resolve the Barrage. The user selects a Barrage to resolve. The Barrage already knows the number of Actual Barrage Points to use for resolution. The user may enter dice roll results, or determine them randomly. They may also select all Terrain Effects that apply. The software will determine the best effect (if any), and modify the combat results accordingly. The window will then display the results of the Barrage, and allow the user to confirm the effects (which include expending CPA, and ammunition). They may then move onto a different Target (friendly or enemy), or another Barrage against the same target.

The effects of all barrages are tracked during the resolution step, and at the end of the Barrage step, a confirmation dialog opens. This dialog shows all results applied to Enemy Targets, and may be printed to give the enemy player a confirmation of damage applied. The dialog also shows damage applied to friendly units, by their obfuscated name. Targets are listed by hex, and Actual Barrage Points applied are totaled per hex. If phasing, a checkbox allows the User to mark a hex as 'held-off'. If more Actual Barrage Points were applied to the hex than the number of Targets in that hex, the checkbox is automatically ticked.

The next window following the confirmation dialog prompts the user to apply damage results to their units. Pinned status' are applied automatically, but damage results of strength points and trucks need to be selected by the user. Trucks have some restrictions on how they may be selected - damage must be spread around as evenly as possible among different cargos. Additionally, any motor inf points that are removed while in trucks, also remove the trucks (the infantry can hardly be killed while the trucks are intact!!).

That concludes the barrage step. All effects noted are applied to the units affected. The Retreat Before Assault step occurs next. If the user is non-phasing, they may retreat their units, with some restrictions. If the user is phasing, they need only mark which hexes adjacent to their units no longer contain enemy units.

If the user is non-phasing, the software presents the users list of units. The user may select and retreat any unit which is not Pinned from Barrage fire and which has a Cohesion greater than -26. The units so selected may move, and may blow up supply dumps. No other actions requiring CPA expenditure are available. Units which are not adjacent to enemy units may only expend up to 4 CPs, down to a minimum of 1 hex of movement (even if that 1 hex costs more than 4 CPs). Units adjacent to an enemy unit may spend as many CPs as desired. They will have to expend CPs to Break Off from the Zone of Control of the enemy units due to either Contact or Engaged status.

They cannot Retreat Before Assault directly into another Zone of Control (of an enemy unit). They can Retreat Before Assault from one Zone of Control into another, so long as they move through uncontrolled hexes before doing so. If they move into a friendly occupied hex which is in the Zone of Control of an enemy unit, or into a hex which is attacked in the following Anti-Armor or Close Assault segments, they are affected by that combat. They may not direct fire against the enemy in that case, nor do they add their close assault ratings to that combat, but they ARE included when taking percentage losses in that hex.

The phasing user simply marks any adjacent hexes which no longer contain enemy units, and can mark formerly empty adjacent hexes as now containing enemy units (there is not really a good reason for the non-phasing player to retreat into another enemy unit, but it CAN be done).

After Retreat Before Assault is concluded, both players assign each unit in combat, to either Anti-Armor, Close Assault, or Withheld. Units in combat are all units in hexes in the Zone of Control of an enemy unit. The phasing player MUST assault all such enemy hexes containing units which were not 'held off'. They may choose to assault 'held-off' hexes anyway.

To be assigned to Anti-Armor, a unit must have an Anti-Armor Rating. Guns placed Back may not be assigned to Anti-Armor or Close Assault. Units without Ammo must be withheld. Any units that were Pinned by Artillery fire may not be assigned to Anti-Armor or Close Assault. Any unit which could be assigned to Anti-Armor which contains more than one TOE Strength Point may be split between Anti-Armor and Close Assault. Each TOE Strength Point the unit is comprised of must be assigned either to Anti-Armor or Close Assault - it is not possible to assign half a TOE Strength Point to Anti-Armor, for instance.

Like in the Barrage step, all damage results of Anti-Armor are only applied at the end of the Anti-Armor step.

To assign, the software will display a dialog, showing all hexes known to contain enemy units. Any hexes which are 'held off' are marked as such (if the User is phasing). Hexes containing only retreating units are marked separately. The software then determines which friendly units are in adjacent hexes and thus 'in combat'.

The software displays a dialogue showing friendly units in combat. The user then selects units, either collectively or singly, and assigns them to either Anti-Armor, Close Assault, or withheld.

If the user is the Phasing Player, when units are selected the dialogue will show a list of Enemy hexes the selected units may attack (either by Anti-Armor or Close Assault). The user designates an enemy-occupied hex to attack if the unit(s) are not withheld. All enemy hexes that contain units that are not 'held off' must be assaulted with a Close Assault, or a Probe if the Probe is large enough. If units from only one hex are selected, the user may designate a second adjacent hex to assault simultaneously. In this case, no other units from any other hex may assault EITHER of those hexes. Units in the same hex may assault BOTH of those hexes, but may not assault only one.

If the user is the non-Phasing (defensive) player, they need not assign a hex, as their forces are defending their own hex. Units may be 'split' in their assignment - each individual TOE Strength Point may be assigned to either Anti-Armor, or Close Assault, if the user desires.

After the user has assigned all combat units either to Anti-Armor, Close Assault, or Withheld, they may proceed to Anti-Armor combat. The user selects a hex to resolve Anti-Armor combat for (this is the decision of the Phasing player, whether or not that is the User). If the user is the phasing player, this is all the units selected to Anti-Armor against that hex. If the user is the non-phasing player, this is all the units selected to Anti-Armor IN that hex. The software totals the Actual Anti-Armor Strength Points for the user, asks the user to select any terrain modifiers that apply, then allows the player to either input the results of a dice roll or determine dice results randomly. However the results were determined, the software consults a chart to find the appropriate number of Damage Points for the Enemy player, and displays that information. It also asks the player to input the number of Damage Points applied by the Enemy player to our units. From this, the player then selects a number of TOE Strength Points, taken from units assigned to Close Assault or Anti-Armor. The sum of the selected units Armor Protection Rating must exceed the Damage Points the Enemy Player applied (unless sufficient Damage Points are applied to destroy all units involved). The selected TOE Strength Points are marked with a flag for destruction, and any Ammo used is removed. Then, the Phasing player selects a new target hex, which has not been selected so far, if any remain, or declares they have no further Anti-Armor assaults to prosecute (via a button on the dialog). This is input by the User. If the User is not the Phasing Player, they are simply inputting the decisions of the Phasing Player.

After all Anti-Armor assaults have been resolved, the software displays a dialog to confirm the results of Anti-Armor fires: listing all Damage Points applied to Enemy units (by target hex), and all losses to Friendly units (that were selected by the User). Damage Points applied to Enemy units are listed either by the hex they attacked (if the User is non-phasing), or by the hex the Enemy Units are in (if the User is Phasing).

Destroyed Tanks units will be created in each hex that TOE Strength Points were flagged in at this point, and all TOE Strength Points marked for destruction are deleted. The points in each hex deleted are added to their respective Destroyed Tanks units, as Destroyed tanks points.

Following this, Close Assault occurs.

Close Assaults are resolved one assault at a time. This may either mean resolving a single target hex, or two adjacent hexes.

If the user is the Phasing Player, the software displays a list of Assaults, being a list of target hexes that had units assigned to assault those hexes. In the case that some units were assigned to assault two hexes, this is shown as a single assault, with two target hexes.

If the user is the non-phasing player, the software displays a list of all hexes that contain friendly units in combat (determined above). The Phasing player makes the decision as to which assault to resolve, in which order. The User inputs the results of this decision, selecting an assault to resolve.

An assault is selected to be resolved by selecting the target hex that assault occurs in. If the User is the non-phasing player, they may select up to two adjacent hexes to resolve simultaneously (if the Enemy, Phasing player is assaulting from a single hex adjacent to both those hexes).

The software displays an Assault Dialog, showing all the User's units involved in the Assault. If the User is the Phasing player, this will be all the units that are attacking the target hex. If the User is non-phasing, this will be all the units that are in the target hex(es), assigned to Close Assault.

The software totals the Actual Close Assault Points, using either the Offensive Rating, or Defensive Rating, depending on whether the user is phasing or non-phasing. This Actual Close Assault Points value is displayed on the Assault Dialog. A box allows the User to input the enemy Actual Close Assault Points value, which when entered, allows the software to determine Actual Close Assault Points, and display the Basic Assault Differential (equal to the phasing players, offensive, Actual Points, minus the non-phasing players, defensive, Actual Points).

In totaling the Actual Close Assault Points, the software first determines a modifier for any unsupported tanks (the Combined Arms case 15.4). Then the Actual Close Assault Points are determined, the modifier applied, and displayed on the Assault Dialog.

To determine the modifier, the software finds the number of tank TOE Strength Points assigned per hex, and compares it to the number of 'infantry' (Infantry, Machinegun, or Heavy Weapons) units assigned to that assault from the same hex. If there are more tank TOE Strength Points, a modifier is required. Otherwise, the software totals the Actual Close Assault Points as normal.

Assuming the modifier is required, it is equal to the excess tanks (in TOE points) divided by 3 (rounding up). This modifier is then subtracted from the Actual Close Assault Points, and the modifier itself is also displayed as Tanks Unsupported.

In totaling the Actual Close Assault Points, the software iterates through all units assigned to the Assault. each unit contributes Actual Points equal to Rating (Offensive or Defensive) * TOE Strength Points * 0.1
This figure is rounded to an integer result, and the modifier (if any) applied.

If the User is Non-Phasing and did not allocate any Units to Close Assault in the target hex, all units in that hex retreat 3 hexes and lose 3 Cohesion Points (possibly more, if the movement costs more CP than their CPA). If the User is Phasing and the enemy did not allocate any Units to Close Assault, they retreat in the same fashion. A button on the Assault Dialog allows the Phasing User to skip the assault, indicating the enemy retreated in this fashion. The button does not display for the non-phasing User.

After the Basic Assault Differential is shown, the User may progress to the next 'tab' of the Assault Dialog, which determines the Modifiers that apply to the Differential (not counting the Combined Arms modifier, as that was applied above). Terrain, unit composition, unit morale, and force organisation may all apply Modifiers, which are summed with each other and the Basic Assault Differential to determine an Adjusted Differential, which is used to determine Combat Results.

On this tab, the User may select all Terrain Effects that affect the current Assault. This displays a Terrain Modifier.
The tab displays the user's Raw Assault Points, unmodified, and allows the user to input the enemy Raw Assault Points in the current Assault. Raw Points are the Rating (Offensive or Defensive) * The number of TOE Strength Points. If either is more than double the other value, a Raw Strength Modifier is displayed.
The tab also shows the largest unit size-equivalent on the User's side, and allows the user to input the largest enemy unit size-equivalent in the current Assault. If the two are not the same size-equivalent, an Organisational Size Modifier is displayed.
The tab also displays the Morale and Cohesion of the largest (size-equivalent) unit of the User which is involved in the Assault. If more than one unit is the largest (because two or more are tied for largest), Morale (and Cohesion) is determined by averaging all the tied units, rounding to the nearest integer. The software allows the user to either input the results of a dice roll, or determine the results randomly. Based on the dice roll and the Cohesion, the software determines an Adjustment. The Adjustment is added to the Morale, then capped if necessary, to an integer value between -3 and +3 inclusive. Finally, if General Rommel is in the same hex as the largest unit in the assault, Adjusted Morale is increased by 1 (making possible values -2 to +4 inclusive). The Tab also allows the user to input the Adjusted Morale of the enemy units in the assault. The Final Adjusted Morale Rating is then displayed as the final Modifier, and a total Modifier is also displayed. Final Adjusted Morale Rating is determined by subtracting the Adjusted Morale of the defending (non-phasing) units from the Adjusted Morale of the attacking (phasing) units.

The final tab of the Assault Dialog allows the user to review the Adjusted Assault Differential, and to input the results of a dice roll, or to determine the dice results randomly. With that input, the software determines the Results of that Assault. Results can include percentage losses of forces, Capture of lost friendly forces, 'Engaged' status, Retreats, Overruns, loss of Cohesion, and loss of Capability Points and Ammunition (these last two are almost guaranteed).

The results are displayed in the same tab. If a Captured result is indicated, the software allows the user to either input the results of a dice roll, or determine results automatically, to determine what percentage of their losses was Captured by the enemy. If the Adjusted Assault Differential is +11 or greater, the result is an Overrun. An Overrun modifies losses slightly and affects which units may take losses.

If the User is Phasing (Offensive), they may get an Engaged result. If they do, the software displays an option to mark the enemy units as Retreated (determined by the enemy player). Unless the enemy Retreats, all units involved in the Assault get the Engaged status (which is removed at the end of the Operations Stage).

If the User is Non-Phasing (Defensive), they may get a Retreat result. If they do not get a Retreat result, the software displays an option to mark the units as Engaged (this is determined by the Phasing players assault results roll). If they do get a Retreat result, Engaged results from the enemy player are ignored.

Retreat results include a number of hexes to retreat by. The user may enter a new hex to move the retreating units to. They may also indicate (via checkbox) that the destination hex is a Major City. The software determines the distance moved and subtracts CPs for the movement. If the checkbox is not ticked, the software subtracts the distance moved from the distance required to move to get Mandated Retreat Ignored. For each hex Mandated Retreat Ignored, the software adds an additional 10% to losses taken (not multiplicative).

For losses taken, the software totals the Raw Assault points for the User's side. If the User is non-Phasing, this includes any Pinned units and units that Retreated into that hex (Before Assault, or as a result of Assault). The Raw Assault points (offensive if phasing, defensive if non-phasing) are multiplied by the percentage losses taken, rounding up if offensive, and down if defensive - except that in an overrun, the defender rounds up also. In the case that units from multiple hexes are involved, the software determines the proportion of raw points contributed by each hex.

The user then selects TOE Strength Points to remove to satisfy the Raw Assault points lost. Each TOE Strength Point satisfies a number of Raw Assault Points lost equal to the Close Assault Rating of that TOE Point (Offensive or Defensive, depending on whether the user is Phasing or Non-Phasing). If the user's units are spread out over more than one hex, points should be taken proportionally according to contributed points (as calculated above). This will not be enforced by the software, but it will show the proportion of points taken by the currently selected losses compared to the desired proportion (calculated above). Defending gun units may be used to absorb losses in this way only in an overrun.

After these percentage losses have been taken, if the User is non-Phasing and gun units are involved, vulnerability losses are taken. The Raw Assault Points lost (calculated above) is halved, rounding up, to get Vulnerability Points Lost. The user must remove gun TOE Strength Points equal to at least this many Vulnerability Points from guns placed Forward. If there was an Overrun, the user may remove the points from guns placed Back as well.

If a percentage Captured was indicated, the software then displays a list of the TOE Strength Points they have selected to be lost (as determined above). The software also displays a target number of Raw Assault Points to be Captured. From the list, the User selects sufficient TOE Strength Points (already lost) to match or exceed that number of Raw Assault Points (which was itself a Captured percentage of lost Raw Assault Points), rounding up).

If more than 30% of the user's TOE Strength Points in the assault have been removed as losses, all the (user's) units in the assault lose 3 Cohesion.

The Assault Results report shows all the results of the combat and the user's choices, allows the user to input any Captured enemy Prisoner Points or Replacement Points (in the case of Guns and Tanks). If the user inputs Prisoner Points or Replacement Points, they can commit the Captures, in which case a dialog will appear requiring further input. For each Replacement Point, the user needs to select a destination unit the Replacement Point will be sent to join, and to select a destination hex within 3 hexes of the target hex (which the Assault took place in). If any Prisoner Points are listed, the user may select any number of Infantry TOE Strength Points from any units (including units not in the Assault), to convert to Guard Points. For each Prisoner Point, the user must select a destination hex within 3 hexes of the target hex. After all Prisoner Points and Replacement Points have been decided on, they are moved to their respective destination hexes.

The Assault Results report shows the results of the combat for the User. This lists all TOE Strength Points lost and which units the losses came from, displaying points the enemy Captured, whether the units were Engaged or Retreated, and after all Captures have been inputted, it lists also all Captured Points.

After the results have been applied, the list of Assaults is displayed again, for the user to select another Assault to resolve.

Assaults in the list may be deleted, if the user is non-phasing, and if the units in that assault have the 'held-off' flag. This is in the case that the phasing enemy player chooses not to assault the hexes the user has selected to delete.

After all Assaults have been resolved, either by the combat process or by deleting (in the case the phasing enemy player chooses not the assault the users units that were held-off), the Combat Segment is concluded. The user proceeds to the Reserve Release Segment.