Skip to content
Snippets Groups Projects

fix assign

Closed lowercasedonkey requested to merge lowercasedonkey/fc-pregmod:fix-assign into pregmod-master
2 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
331 331 /** Number of already hosted slaves
332 332 * @returns {number} */
333 333 get hostedSlaves() {
334 return State.variables[this.desc.baseName + "Slaves"];
334 switch (this.desc.baseName) {
  • It's a bad design. This switch contradicts basic principles of the OOP model. Never ever a class should know about ancestor-related details, especially related to their implementation.

    1. Replace with return State.variables[capFirstChar(this.desc.baseName) + "iIDs"].length;
    2. Provide overrides for the special cases (brother, cellblock, HGSuite, master suite, servants' quaters)

    You may want to look at App.Entity.Facilities.FacilitySingleJob._employeeIDsVariableName.

  • P.S. You forgot about the schoolroom in this switch.

  • I'll add schoolroom. I'm not quite sure I follow what else you are saying. I'm sure it seems simple to you but it adds a lot of complexity. I can try though.

    Edited by lowercasedonkey
  • See the comment below, please. Almost everything is already in place! We need just a tiny function to patch that in the facility class.

  • I'll look.

  • Please register or sign in to reply
  • ezsh
    ezsh @ezsh started a thread on the diff
  • 331 331 /** Number of already hosted slaves
    332 332 * @returns {number} */
    333 333 get hostedSlaves() {
    334 return State.variables[this.desc.baseName + "Slaves"];
    334 switch (this.desc.baseName) {
    • Given the available job classes and all definitions inside them, get hostedSlaves() can be implemented using the job objects:

      get hostedSlaves() {
           return this.job().employeesIds.length;
      }

      You just need to split the first three lines out of App.Entity.Facilities.FacilitySingleJob.employeesIndices() into this new function get employeesIds().

      Edited by ezsh
    • Ok, so you want me to take

      	/** @returns {number[]} */
      	employeesIndices() {
      		const V = State.variables;
      		const si = V.slaveIndices;
      		const ids = V[this._employeeIDsVariableName]; // updated by assignJob()/removeJob()
      		return ids.map(id => si[id]);
      	}

      and either use or remove the first three lines. Then make a function called employeesIds and do something with it.

      I can see how

      /** @private */
      	get _employeeIDsVariableName() {
      		return this.facility.genericName + "iIDs";
      	}

      is helpful and could set up something automatic, but I'm not quite getting how this comes together. It's probably something with scope.

      Edit: forked off what I think you are saying in !5281 (merged) for better discussion and to keep this ready to merge.

      Edited by lowercasedonkey
    • Please register or sign in to reply
  • added 1 commit

    Compare with previous version

  • If you have a way you want to structure this ez let's not hold up the merge over it, since this way is functional and does indeed fix an important bug.

  • lowercasedonkey mentioned in merge request !5281 (merged)

    mentioned in merge request !5281 (merged)

  • Please register or sign in to reply
    Loading