Monday, March 23, 2015

WFMC - After 3 Weeks Continuing to Come Together… Now With Configuration Selection Capabilities [Part 3/11]

It has been another 3 weeks of squeezing in 30 minutes to 1 hour a night - literally coding myself to sleep, trying to make more progress on WFMC (WotR Formation Movement Calculator). Over that time, there has been a lot of refining happening to the core functionality - and it continues to get better-and-better. There really is a pleasure that comes with creating something from scratch and seeing it come together.

WHERE WE LEFT OFF WITH PART 2/10

Here is what the application looked like on the 6th of March 2015. Where we left off with it from the Part 2/10 post is shown below:


To recap the state of WFMC on the 6th of March, I had created the workflow by disabling controls and then re-opening them as other controls were populated. I also had the OpenGL View displaying a generic formation of configuration 3x2 comprised of 6 companies. However, there were several controls that were hard coded (for example the number of companies) and the checkboxes that adjust move value were functional - but did not provide their bonus or penalty to the Remaining Move Value. I had set a goal to get the Formation Configuration combo box operational and use that to draw to the view. About 2 to 3 days into work, I ran into a problem where the OpenGL View was not getting any of the information from my controls (e.g., "Infantry" vs "Cavalry" or the number of companies). After working on it for several days, I finally figured out that the problem was that the view from an Xcode perspective wanted the initializer to be - (id) initWithCoder: for the view, where OpenGL wanted the initializer to be - (id) initWithFrame: for the view. I tried every variation of those two, with calls out to "super", and finally after spamming my NSLog with "self's", I realized that the view was actually getting double initialized (one with the global variables and a second without them). Once I got them both in code and called both of them - it miraculously started working and I was able to continue with making progress.

PROGRESS THAT HAS BEEN MADE

First off, having the fields disabled really helped with the workflow; however, the dialog still had "Label" in place for the Unit Type and the Move Values, and not only that but the default 3x2 Infantry Configuration was displayed in the view on the right. I went through and cleaned that up first - to make sure that when nothing was selected it looked "clean and nice".


The Desired Faction combo box is still the starting field, and the only one that is enabled at the start. Clicking on any of the others will result in no functionality. The list still contains the full set of Armies in WotR.


Once an army is selected from the Desired Faction combo box, the Desired Unit combo box is enabled and allows the selection of the company unit. All the units that have been covered on the blog so far are included in the list as well as several user defined units from SBG (as discussed in the previous post).


As soon as the Desired Unit is selected, the remaining fields begin to open up. The Unit's Type ("Infantry" vs "Cavalry") is populated based upon the selection, as well as the profile's default Move Value and the maximum number of companies that are allowed for the unit. The number of companies that are included within the formation is initially set to the maximum number of companies that are allowed for the unit (because who wants to take less than the maximum number, right). Likewise, all the checkboxes that have been implemented are now open and available to be checked as well (and as I'll show later apply the appropriate bonus to the Remaining Move Value). The "Hornblower" checkbox is currently enabled for everyone, regardless of Good/Bad affiliation (i.e., the Bad side should have a "Taskmaster" as appropriate) and the rules specify which units can support the upgrade - and that database column has not yet been added ... I suspect this will be one of the next changes that gets implemented.

The Formation Configuration combo box was disabled 3 weeks ago, but now it is enabled and is populated with the appropriate permutations based upon the current number of companies that are included within the formation (from 2 companies up to 9 companies in the formation). As seen in the image below, the formation of Feral Uruk-hai Warband has 4 companies in the formation (the maximum allowed), so as we have seen in previous posts about reconfiguration, the valid permutations of reconfiguration are 1x4 (column), 2x2 (compact1), 3x2 (compact 2), and 4x1 (line). Finally, the Expended Move Value is set to 0.00", since there has been no adjustment made to the formation's rotation or translation, yet; and the Remaining Move Value is set to the maximum Move Value Characteristic, since none of the modifiers have been checked.


As I mentioned above, when I selected the Desired Unit and the Unit Type was populated, I was expecting the OpenGL View to get the type ("Infantry" vs "Cavalry"), so that I could draw in the correct dimensions of the "tray" within the view (e.g., 110mm x 60mm for Infantry). I was also using the selection of the Formation Configuration to draw the formation in the proper configuration with the companies within their appropriate locations; however, due to the double initialization of the view, I was getting nothing but a blank view. Once things got working, I was able to draw the formation based upon selection. Below is the formation of Feral Uruk-hai Warband in 1x4 Configuration. I also made it where changing the selection of the Formation Configuration will update the view to the newly selected configuration. So as seen, the formation went from 1x4 configuration, to 3x2 configuration, and finally to 4x1 configuration.


I haven't put in the math to reconfigure the formation, yet - so as of right now, the reconfiguration costs are "free" (which will be "the way" when the "Use Vanilla WotR Move Limit Rules" is implemented and checked). Everything else is still fully functional - the formation can still rotate, and translate. One other thing that has changed is the math to calculate the distance for translational movement. The Expended Move Value used to use the full x-translation and full y-translation values for calculating - and not the resultant hypotenuse of the right triangle. This made translations usually 2x as expensive as they should have been, so the math has been updated to use the square-root of the sum of the squares. (/pushUpNerdGlasses) LOL!

Another thing you can see in the following image is the "At the Double" checkbox is checked. If you look under the view at the Remaining Move Value - you will notice that it now has been updated to include a successful "At the Double" being executed. The others perform their expected adjustment of doubling, tripling, halving, or modifying the base Move Value as appropriate.


As soon as I began testing all the implemented functionality, I quickly exposed a pretty substantial problem. I could enter the number of companies to be large than the maximum number of companies supported by the selected unit! (oops). When Update was clicked - it drew a nice 4x2 formation comprised of 6 companies ... so at least the View was accepting it - but it still didn't make sense.


In code I did a check to ensure that the entered value was not larger than the maximum number of companies that the rules specified for the unit. I made it so that when this case is entered and the Update button is clicked, then a warning dialog will pop-up that indicates that the entered value is not valid. Once the OK button is clicked on the warning dialog, then the number of companies is automatically changed back to be the maximum allowed by the unit.


Similarly, I added a check to make sure that anything less than 1 could not be entered, either. There is another warning dialog that indicates that the minimum number of companies that can be in the formation must be 1 - and if anything less than 1 is entered, when OK is clicked on the pop-up, the number of companies is then automatically changed to be 1.


Something to note about the number of companies being 1 ... Notice that there is technically no Formation Configuration associated with a single company in the formation; hence, the combo box is blanked out and disabled and the View, of course, is updated with the single company.


Similarly, when the Reset Round button (on the bottom right) was clicked, the intent of this button was to return all the checkboxes, combo boxes, number of companies and movement slider positions back to the value that was committed at the end of the previous round. If there was a substantial amount of changes that were made during the round, and the Reset Round button was accidently clicked (instead of say the End Round button - which would commit the changes for the current round), it could be really frustrating to have to recreate all the modifications again ... Because of that reason, I added a warning dialog on the button to confirm the "delete" - to make sure that this was truly the intended operation. The Cancel button doesn't make the changes, and the OK button resets everything back to the previous round's end state.


Everything else works as expected. Here are a few other screenshots of various units in various configurations:




WHERE TO GO FROM HERE

So, there we have it. The goals that I have for the next few weeks include:
  • Hornblower/Taskmaster applicability to units based upon upgrade capabilities.
  • Add the math to do the reconfigurations
  • Add the math for rotation based upon configuration dimensions
Stay tuned, I'll post more updates as it continues along.



    LINKS TO OTHER PARTS OF THE WFMC PROGRESS SERIES


      LINKS TO OTHER PARTS OF MOVEMENT TYPES AND LIMITS SERIES




      • Movement Types and Limits Series - Reconfiguration Movement of Cavalry Formations Comprised of 2-3 Companies [Part 11/23]
      • Movement Types and Limits Series - Reconfiguration Movement of Cavalry Formations Comprised for 4 Companies [Part 12/23]
      • Movement Types and Limits Series - Reconfiguration Movement of Cavalry Formations Comprised of 5 Companies [Part 13/23]
      • Movement Types and Limits Series - Reconfiguration Movement of Cavalry Formations Comprised of 6 Companies [Part 14/23]
      • Movement Types and Limits Series - Reconfiguration Movement of Cavalry Formations Comprised of 7 Companies [Part 15/23]
      • Movement Types and Limits Series - Reconfiguration Movement of Cavalry Formations Comprised of 8 Companies [Part 16/23]
      • Movement Types and Limits Series - Reconfiguration Movement of Infantry Formations Comprised of 9 Companies [Part 17/23]
      • Movement Types and Limits Series - Cavalry Movement Example 1 from Page 33 of WotR Rulebook Analysis [Part 18/23]
      • Movement Types and Limits Series - Cavalry Movement Example 2 from Page 33 of WotR Rulebook Analysis [Part 19/23]
      • Movement Types and Limits Series - Cavalry Movement Example 3 from Page 33 of WotR Rulebook Analysis [Part 20/23]
      • Movement Types and Limits Series - Reconfiguration Summary of Cavalry Formations by Company Size [Part 21/23]
      • Movement Types and Limits Series - Cavalry Restrictions of Reconfiguration by Formation Name Summary [Part 22/23]
      • Using WFMC to Verify Movement Examples [Part 23/23]



      No comments:

      Post a Comment