title: Object oriented design of game in Java: How to handle a party of NPCs?
body: <p>I'm making a very simple 2D RPG in Java. My goal is to do this in as simple code as possible. Stripped down to basics, my class structure at the moment is like this:</p>
  
  <ul>
  <li>Physical objects have an x and y
  dimension.
  
  <ul>
  <li>Roaming objects are physical objects
  that can move().
  
  <ul>
  <li>Humanoid objects are roaming objects
  that have inventories of GameItems.
  
  <ul>
  <li>The Player is a singleton humanoid
  object that can hire up to 4 NPC Humanoids
  to join his or her party, and do other actions, such as fight non-humanoid objects.</li>
  <li>NPC Humanoids can be hired by the
  Player object to join his or her
  party, and once hired can fight for the Player.</li>
  </ul></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>So far I have given the Player class a "party" ArrayList of NPC Humanoids, and the NPC Humanoids class a "hired" Boolean. </p>
  
  <p>However, my fight method is clunky, using an if to check the party size before implementing combat, e.g. </p>
  
  <pre><code>public class Player extends Humanoids {
     private ArrayList&lt;Humanoids&gt; party;
     // GETTERS AND SETTERS for party here
     //...
  
     public void fightEnemy(Enemy eneObj) {
        if (this.getParty().size() == 0)
          // Do combat without party issues
        else if (this.getParty().size() == 1)
          // Do combat with party of 1
        else if (this.getParty().size() == 2)
          // Do combat with party of 2
        // etc. 
  </code></pre>
  
  <p>My question is, thinking in object oriented design, am I on the right track to do this in as simple code as possible? Is there a better way?</p>