This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dropping zero minute techs - code questions
#1
With the dependents patch nearly wrapped up I have been looking into adding some way to drop zero minute techs from the repair list (I have a lot of techs and the clutter is annoying) but my first attempt did not go well.

I know that the list calls getTechs() to populate the list. My first attempt modified this to actually drop the techs with 0 time left. The problem though is when I have to bring tech teams to full strength it also drops o minute techs from the list.. So, the problem I have is what to do about it.

The best solution I see is having two getTech functions. One for normal use and one for the repair/mothball/refit(?) list taking an int or bool (depending on what is used to check if overtime is allowed).

getTechs() { code... }
getTechs(bool overtime) { code... }

Is this a good way to do it or is there a preferred way you (devs) want this done?
Reply
#2
I would go with overloading the function (basically what you've described above) in a pattern like this:

Code:
getTechs(boolean excludeZeroMinute) {
    /** do stuff **/
}

getTechs() {
    getTechs(false)
}
Reply
#3
Code:
getTechs() {
    getTechs(false)
}

?? Not sure of your meaning behind this part.
Reply
#4
(05-28-2014, 06:51 PM)pheonixstorm link Wrote:
Code:
getTechs() {
    getTechs(false)
}

?? Not sure of your meaning behind this part.

Put all the code for getting techs in the getTechs(boolean) method.  Then, in the original getTechs() method, simply call the new method with an argument of FALSE.  This way you avoid unnecessary code duplication.  For some examples of what I'm talking about, you can take a look at the Campaign.addFunds(long, String, int) and Campaign.addFunds(long) methods as well as the Campaign.buyPart(Part, int) and Campaign.buyPart(Part, double, int) methods.
Reply
#5
I have this working fine with only one hiccup. If you use up all the time on a tech (s)he will no longer be able to mothball a mech for that day. All other aspects work fine such as refits and temp astechs.
Reply
#6
Hiccups are gone now, just needed a teaspoon of sugar and all is well. Patch posted, all ready for review and hopefully inclusion into HQ.

One note. The getTechs() function is not final as i will probably have to make additional changes to it for my other tech request from 162 Repair Bay: Assigned Tech at top of list. I am thinking I will have to remove the original getTechs() and modify all existing code to use getTechs(boolean) with getTechs(boolean, techID?) as an alternate for pushing the assigned tech to the top of the list. Speculation for now anyway.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiple techs on one refit? dgorsman 1 905 06-12-2019, 10:12 PM
Last Post: Hammer
  Assigned techs kipstafoo 5 1,863 12-14-2016, 04:44 PM
Last Post: iduno
  Code review - Time in Service and Refurbishment pheonixstorm 17 4,685 02-01-2016, 01:49 PM
Last Post: BeeRockxs
  Allow Order/Selection/Assignment of Scroungs assigned Techs neilfw 0 961 02-01-2015, 07:14 AM
Last Post: neilfw
  Mek Techs making mechs inoperable HydroSqueegee 11 3,948 12-08-2014, 10:25 PM
Last Post: ralgith
  techs to mechs Ratio warhammer74 4 1,764 11-21-2014, 05:52 PM
Last Post: Question2
  Where do I find the repair bay code? pheonixstorm 12 4,319 08-01-2014, 12:59 AM
Last Post: ralgith
  Code - Large crew requirements? pheonixstorm 5 1,949 06-17-2014, 09:53 PM
Last Post: pheonixstorm
  Damn you Techs, stop breaking my Mechs! Also: You expect me to work for THAT? CookieCrumb 8 4,548 01-29-2014, 02:34 PM
Last Post: Jayof9s
  Can we improve refits, assign multiple techs? neilfw 1 1,511 11-26-2012, 08:28 PM
Last Post: Xenon54z

Forum Jump:


Users browsing this thread: 1 Guest(s)