Exemplo n.º 1
0
 @Override
 public void affectCharStats(MOB affected, CharStats affectableStats) {
   super.affectCharStats(affected, affectableStats);
   final int[] breatheables = affectableStats.getBreathables();
   if (breatheables.length == 0) return;
   if ((lastSet != breatheables) || (newSet == null)) {
     newSet =
         Arrays.copyOf(
             affectableStats.getBreathables(), affectableStats.getBreathables().length + 2);
     newSet[newSet.length - 1] = RawMaterial.RESOURCE_SALTWATER;
     newSet[newSet.length - 2] = RawMaterial.RESOURCE_FRESHWATER;
     Arrays.sort(newSet);
     lastSet = breatheables;
   }
   affectableStats.setBreathables(newSet);
 }
Exemplo n.º 2
0
  @Override
  public void addItemDeficiency(final String zapperMask) {
    final DoubleFilterer<Item>[] newerArray =
        Arrays.copyOf(this.proficiencies, this.proficiencies.length + 1);
    newerArray[newerArray.length - 1] =
        new DoubleFilterer<Item>() {
          final MaskingLibrary.CompiledZMask mask = CMLib.masking().getPreCompiledMask(zapperMask);

          @Override
          public DoubleFilterer.Result getFilterResult(Item obj) {
            return CMLib.masking().maskCheck(mask, obj, true)
                ? DoubleFilterer.Result.REJECTED
                : DoubleFilterer.Result.NOTAPPLICABLE;
          }
        };
    this.proficiencies = newerArray;
  }
Exemplo n.º 3
0
 @Override
 public Collection<CharClass> getCharClasses() {
   return Arrays.asList(myClasses);
 }
Exemplo n.º 4
0
/*
   Copyright 2003-2015 Bo Zimmerman

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

	   http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
public class Swamp extends StdRoom implements Drink {
  @Override
  public String ID() {
    return "Swamp";
  }

  public Swamp() {
    super();
    name = "the swamp";
    basePhyStats.setWeight(3);
    recoverPhyStats();
    climask = Places.CLIMASK_WET;
  }

  @Override
  public int domainType() {
    return Room.DOMAIN_OUTDOORS_SWAMP;
  }

  @Override
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    if ((msg.amITarget(this)
            || (msg.targetMinor() == CMMsg.TYP_ADVANCE)
            || (msg.targetMinor() == CMMsg.TYP_RETREAT))
        && (!msg.source().isMonster())
        && (msg.source().curState().getHitPoints() < msg.source().maxState().getHitPoints())
        && (CMLib.dice().rollPercentage() == 1)
        && (CMLib.dice().rollPercentage() == 1)
        && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
      Ability A = null;
      if (CMLib.dice().rollPercentage() > 50) A = CMClass.getAbility("Disease_Chlamydia");
      else A = CMClass.getAbility("Disease_Malaria");
      if ((A != null) && (msg.source().fetchEffect(A.ID()) == null))
        A.invoke(msg.source(), msg.source(), true, 0);
    }
    if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) {
      final MOB mob = msg.source();
      final boolean thirsty = mob.curState().getThirst() <= 0;
      final boolean full =
          !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight()));
      if (thirsty) mob.tell(L("You are no longer thirsty."));
      else if (full) mob.tell(L("You have drunk all you can."));
      if (CMLib.dice().rollPercentage() < 10) {
        Ability A = CMClass.getAbility("Disease_Malaria");
        if ((A != null) && (msg.source().fetchEffect(A.ID()) == null))
          A.invoke(msg.source(), msg.source(), true, 0);
      }
    }
    super.executeMsg(myHost, msg);
  }

  public static final Integer[] resourceList = {
    Integer.valueOf(RawMaterial.RESOURCE_JADE),
    Integer.valueOf(RawMaterial.RESOURCE_SCALES),
    Integer.valueOf(RawMaterial.RESOURCE_COCOA),
    Integer.valueOf(RawMaterial.RESOURCE_COAL),
    Integer.valueOf(RawMaterial.RESOURCE_PIPEWEED),
    Integer.valueOf(RawMaterial.RESOURCE_BAMBOO),
    Integer.valueOf(RawMaterial.RESOURCE_REED),
    Integer.valueOf(RawMaterial.RESOURCE_SUGAR),
    Integer.valueOf(RawMaterial.RESOURCE_CLAY),
  };

  @Override
  protected int baseThirst() {
    return 0;
  }

  @Override
  public long decayTime() {
    return 0;
  }

  @Override
  public void setDecayTime(long time) {}

  @Override
  public int thirstQuenched() {
    return 500;
  }

  @Override
  public int liquidHeld() {
    return Integer.MAX_VALUE - 1000;
  }

  @Override
  public int liquidRemaining() {
    return Integer.MAX_VALUE - 1000;
  }

  @Override
  public int liquidType() {
    return RawMaterial.RESOURCE_FRESHWATER;
  }

  @Override
  public void setLiquidType(int newLiquidType) {}

  @Override
  public void setThirstQuenched(int amount) {}

  @Override
  public void setLiquidHeld(int amount) {}

  @Override
  public void setLiquidRemaining(int amount) {}

  @Override
  public boolean disappearsAfterDrinking() {
    return false;
  }

  @Override
  public boolean containsDrink() {
    return true;
  }

  @Override
  public int amountTakenToFillMe(Drink theSource) {
    return 0;
  }

  public static final List<Integer> roomResources =
      new Vector<Integer>(Arrays.asList(resourceList));

  @Override
  public List<Integer> resourceChoices() {
    return Swamp.roomResources;
  }
}