/**
  * Whether we are disguised as a particular creature...
  *
  * @param cr a creature to test (in the case of multiple matches, their birthday is used to
  *     determine which one they're disguised as).
  * @return A CreatureType, or null.
  */
 static CreatureType inCharacter(final Creature cr) {
   final List<CreatureType> valid = new ArrayList<CreatureType>();
   for (final CreatureType c : Game.type.creature.values()) {
     if (!c.hasUniform()) {
       continue;
     }
     if (c.uniform != null && c.uniform.inCharacter(cr)) {
       valid.add(c);
     }
   }
   if (valid.size() == 0) {
     return cr.type();
   }
   return valid.get(cr.birthDay() % valid.size());
 }
 @Override
 void apply(final Creature cr, final CreatureType ct) {
   if (i.rng.chance(10)) {
     // Thief
     cr.skill().setSkill(SECURITY, i.rng.nextInt(5) + 3);
     cr.skill().setSkill(DISGUISE, i.rng.nextInt(5) + 3);
     cr.skill().setSkill(STEALTH, i.rng.nextInt(5) + 3);
     // cr.set_skill(THEFT,i.rng.getInt(5)+3);
     cr.type(CreatureType.valueOf("THIEF"));
     cr.age(Age.MATURE.age());
   } else {
     switch (i.rng.nextInt(5)) {
       default:
         // Gang member
         cr.skill().setSkill(PISTOL, i.rng.nextInt(2) + 1);
         cr.skill().setSkill(SHOTGUN, i.rng.nextInt(2) + 1);
         cr.skill().setSkill(RIFLE, i.rng.nextInt(2) + 1);
         cr.type(CreatureType.valueOf("GANGMEMBER"));
         cr.age(Age.YOUNGADULT.age());
         break;
       case 1:
         // Prostitute
         cr.skill().setSkill(PERSUASION, i.rng.nextInt(4) + 2);
         cr.skill().setSkill(SEDUCTION, i.rng.nextInt(4) + 2);
         cr.type(CreatureType.valueOf("PROSTITUTE"));
         cr.age(Age.YOUNGADULT.age());
         break;
       case 2:
         // Crack head
         cr.skill().setSkill(Skill.SHOOTINGUP, 10);
         cr.type(CreatureType.valueOf("CRACKHEAD"));
         cr.age(Age.YOUNGADULT.age());
         break;
       case 3:
         // Teenager
         cr.age(Age.TEENAGER.age());
         cr.type(CreatureType.valueOf("TEENAGER"));
         break;
       case 4:
         // HS Dropout
         cr.age(Age.TEENAGER.age());
         cr.type(CreatureType.valueOf("HSDROPOUT"));
         break;
     }
   }
 }
 /**
  * Create a Creature with a given type.
  *
  * @param template the CreatureType to create.
  * @return a Creature.
  */
 public static Creature withType(final CreatureType template) {
   CreatureType modifiedTemplate = template;
   if (modifiedTemplate == CreatureType.valueOf("COP")
       && i.issue(Issue.POLICEBEHAVIOR).law() == Alignment.ELITELIBERAL
       && template.alignment == Alignment.LIBERAL
       && i.rng.likely(3)) {
     modifiedTemplate = CreatureType.valueOf("POLICE_NEGOTIATOR");
   }
   if (modifiedTemplate == CreatureType.valueOf("DEATHSQUAD")
       && i.issue(Issue.DEATHPENALTY).law() != Alignment.ARCHCONSERVATIVE
       && i.issue(Issue.POLICEBEHAVIOR).law() != Alignment.ARCHCONSERVATIVE) {
     if (i.issue(Issue.POLICEBEHAVIOR).lawLT(Alignment.CONSERVATIVE) && i.rng.chance(2)) {
       modifiedTemplate = CreatureType.valueOf("GANGUNIT");
     } else {
       modifiedTemplate = CreatureType.valueOf("SWAT");
     }
   }
   if (modifiedTemplate == CreatureType.valueOf("FIREFIGHTER") && !i.freeSpeech()) {
     modifiedTemplate = CreatureType.valueOf("FIREMAN");
   }
   final Creature cr = new Creature(modifiedTemplate.animalGloss, modifiedTemplate);
   cr.squad(null);
   cr.type(modifiedTemplate);
   if (modifiedTemplate.names.size() > 0) {
     cr.name(i.rng.randFromList(modifiedTemplate.names));
   } else if (modifiedTemplate.ccs && i.mode() == GameMode.SITE) {
     cr.nameCCSMember();
   } else {
     cr.name(modifiedTemplate.toString());
   }
   if (modifiedTemplate.armorTypes.size() > 0) {
     cr.giveArmor(i.rng.randFromList(modifiedTemplate.armorTypes));
   } else {
     cr.giveArmor("CLOTHES");
   }
   if (modifiedTemplate.weapontypes.size() > 0) {
     cr.weapon().giveCreatureWeapon(i.rng.randFromList(modifiedTemplate.weapontypes));
   }
   cr.juice(modifiedTemplate.juice.aValue());
   cr.money(modifiedTemplate.money.aValue());
   final int mood = Politics.publicmood();
   cr.conservatise();
   if (i.rng.nextInt(100) < mood) {
     cr.alignment(cr.alignment().next());
   }
   if (i.rng.nextInt(100) < mood) {
     cr.alignment(cr.alignment().next());
   }
   if (modifiedTemplate.animalGloss == Animal.TANK) {
     cr.specialAttack(SpecialAttacks.CANNON);
   }
   if (modifiedTemplate.verifyworklocation(i.site.current())) {
     cr.workLocation(i.site.current());
   } else {
     cr.workLocation(modifiedTemplate.workLocation());
   }
   cr.age(modifiedTemplate.age.age());
   final boolean traditionalgenderroles =
       i.issue(Issue.WOMEN).law() == Alignment.ARCHCONSERVATIVE
           || i.issue(Issue.WOMEN).law() == Alignment.CONSERVATIVE && i.rng.likely(25)
           || i.issue(Issue.WOMEN).law() == Alignment.MODERATE && i.rng.likely(10)
           || i.issue(Issue.WOMEN).law() == Alignment.LIBERAL && i.rng.likely(4);
   if (traditionalgenderroles) {
     if (modifiedTemplate.gender == Gender.MALE) {
       cr.gender(Gender.MALE);
     } else if (modifiedTemplate.gender == Gender.FEMALE) {
       cr.gender(Gender.FEMALE);
     }
   }
   cr.alignment(modifiedTemplate.alignment);
   for (final Entry<Skill, Range> e : modifiedTemplate.skills.entrySet()) {
     cr.skill().setSkill(e.getKey(), e.getValue().aValue());
   }
   for (final Entry<Attribute, Range> e : modifiedTemplate.attribute.entrySet()) {
     cr.skill().attribute(e.getKey(), e.getValue().aValue());
   }
   if (modifiedTemplate.offences.size() > 0) {
     final Crime lf = i.rng.randFromList(modifiedTemplate.offences);
     cr.crime().criminalize(lf);
   }
   for (final Specials s : modifiedTemplate.specials) {
     s.apply(cr, modifiedTemplate);
   }
   doAttributes(cr, modifiedTemplate);
   if (modifiedTemplate.stub) {
     return cr;
   }
   doInfiltration(cr, modifiedTemplate);
   doRandomSkills(cr);
   // ALIENATION
   if (i.site.alienate() != Alienation.NONE && cr.alignment() == Alignment.MODERATE) {
     cr.conservatise();
   }
   if (i.site.alienate() == Alienation.ALL && cr.alignment() == Alignment.LIBERAL) {
     cr.conservatise();
   }
   return cr;
 }