public void Fight(ref Organism[,] arrOrganism, Organism opponentOrganism, ref Logboek logbook) { var xPosition = this.Position.xPosition; var yPosition = this.Position.yPosition; if (this.Life == opponentOrganism.Life) { if (opponentOrganism is Human) { // defeat, add life to opponent opponentOrganism.Life += this.Life; // destroy yourself, make terrain at this location arrOrganism[xPosition, yPosition] = new Terrain(xPosition, yPosition); // opponent moves to this location ((Animal)opponentOrganism).MoveTo(ref arrOrganism, xPosition, yPosition); logbook.numberOfCarnivores--; logbook.DiedCarnivores++; } // do nothing since opponent organism is carnivore } else if (this.Life > opponentOrganism.Life) { // victory // add opponent's life to yours this.Life += opponentOrganism.Life; // destroy opponent, make terrain at his location arrOrganism[opponentOrganism.Position.xPosition, opponentOrganism.Position.yPosition] = new Terrain(opponentOrganism.Position.xPosition, opponentOrganism.Position.yPosition); // move to opponent's location this.MoveTo(ref arrOrganism, opponentOrganism.Position.xPosition, opponentOrganism.Position.yPosition); // if carnivore, adjust logbook appropriately, if human, adjust appropriately if (opponentOrganism is Carnivore) { logbook.numberOfCarnivores--; logbook.DiedCarnivores++; } else // is human { logbook.numberOfHumans--; logbook.DiedHumans++; } } else { // lose, add life to opponent opponentOrganism.Life += this.Life; // destroy yourself, make terrain at this location arrOrganism[xPosition, yPosition] = new Terrain(xPosition, yPosition); // opponent moves to this location ((Animal)opponentOrganism).MoveTo(ref arrOrganism, xPosition, yPosition); logbook.numberOfCarnivores--; logbook.DiedCarnivores++; } // reduce moves by 1 for both organisms // set last move to fight for both organisms this.LastMove = OrganismMoves.Fight; opponentOrganism.LastMove = OrganismMoves.Fight; this.Moves--; opponentOrganism.Moves--; }