public void unInvoke() { // undo the affects of this spell if ((affected == null) || (!(affected instanceof MOB))) return; MOB mob = (MOB) affected; super.unInvoke(); if ((canBeUninvoked()) && (mob.location() != null)) { if ((failed) || (!CMLib.flags().isSitting(mob)) || (room == null) || (title == null) || (mob.location() != room)) mob.tell("You are no longer squatting."); else if (title.landOwner().length() > 0) { mob.tell( "Your squat has succeeded. This property no longer belongs to " + title.landOwner() + "."); title.setLandOwner(""); title.updateTitle(); title.updateLot(null); } else if (title.landOwner().length() > 0) { mob.tell("Your squat has succeeded. This property now belongs to you."); title.setLandOwner(mob.Name()); title.updateTitle(); title.updateLot(new XVector(mob.name())); } } failed = false; }
public static boolean robberyCheck(LandTitle A, CMMsg msg) { if (((msg.targetMinor() == CMMsg.TYP_GET) && (!msg.isTarget(CMMsg.MASK_INTERMSG))) || (msg.targetMinor() == CMMsg.TYP_PUSH) || (msg.targetMinor() == CMMsg.TYP_PULL)) { if ((msg.target() instanceof Item) && (((Item) msg.target()).owner() == msg.source().location()) && ((!(msg.tool() instanceof Item)) || (msg.source().isMine(msg.tool()))) && (!msg.sourceMajor(CMMsg.MASK_ALWAYS)) && (A.getOwnerName().length() > 0) && (msg.source().location() != null) && (msg.othersMessage() != null) && (msg.othersMessage().length() > 0) && (!shopkeeperMobPresent(msg.source().location())) && (!CMLib.law().doesHavePriviledgesHere(msg.source(), msg.source().location()))) { final Room R = msg.source().location(); final LegalBehavior B = CMLib.law().getLegalBehavior(R); if (B != null) { for (int m = 0; m < R.numInhabitants(); m++) { final MOB M = R.fetchInhabitant(m); if (CMLib.law().doesHavePriviledgesHere(M, R)) return true; } MOB D = null; final Clan C = CMLib.clans().getClan(A.getOwnerName()); if (C != null) D = C.getResponsibleMember(); else D = CMLib.players().getLoadPlayer(A.getOwnerName()); if (D == null) return true; B.accuse( CMLib.law().getLegalObject(R), msg.source(), D, new String[] {"PROPERTYROB", "THIEF_ROBBERY"}); } } return true; } return false; }
public static int updateLotWithThisData( Room R, LandTitle T, boolean resetRoomName, boolean clearAllItems, List optPlayerList, int lastNumItems) { boolean updateItems = false; boolean updateExits = false; boolean updateRoom = false; synchronized (("SYNC" + R.roomID()).intern()) { R = CMLib.map().getRoom(R); if (T.getOwnerName().length() == 0) { Item I = null; for (int i = R.numItems() - 1; i >= 0; i--) { I = R.getItem(i); if ((I == null) || (I.Name().equalsIgnoreCase("id"))) continue; CMLib.catalog().updateCatalogIntegrity(I); if (clearAllItems) { I.destroy(); updateItems = true; } else { if (I.expirationDate() == 0) { long now = System.currentTimeMillis(); now += (TimeManager.MILI_MINUTE * CMProps.getIntVar(CMProps.Int.EXPIRE_PLAYER_DROP)); I.setExpirationDate(now); } if ((I.phyStats().rejuv() != PhyStats.NO_REJUV) && (I.phyStats().rejuv() != 0)) { I.basePhyStats().setRejuv(PhyStats.NO_REJUV); I.recoverPhyStats(); } } } Ability A = null; if (clearAllItems) for (final Enumeration<Ability> a = R.effects(); a.hasMoreElements(); ) { A = a.nextElement(); if (((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) != Ability.ACODE_PROPERTY))) { A.unInvoke(); R.delEffect(A); updateRoom = true; } } for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) { final Room R2 = R.rawDoors()[d]; Exit E = R.getRawExit(d); if ((E != null) && (E.hasALock()) && (E.isGeneric())) { E.setKeyName(""); E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false); updateExits = true; if (R2 != null) { E = R2.getRawExit(Directions.getOpDirectionCode(d)); if ((E != null) && (E.hasALock()) && (E.isGeneric())) { E.setKeyName(""); E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false); CMLib.database().DBUpdateExits(R2); R2.getArea().fillInAreaRoom(R2); } } } } if (updateExits) { CMLib.database().DBUpdateExits(R); R.getArea().fillInAreaRoom(R); } if (updateItems) CMLib.database().DBUpdateItems(R); if (updateRoom) CMLib.database().DBUpdateRoom(R); colorForSale(R, T.rentalProperty(), resetRoomName); return -1; } if ((lastNumItems < 0) && (!CMSecurity.isDisabled(CMSecurity.DisFlag.PROPERTYOWNERCHECKS)) && (optPlayerList != null)) { boolean playerExists = (CMLib.players().getPlayer(T.getOwnerName()) != null); if (!playerExists) playerExists = (CMLib.clans().getClan(T.getOwnerName()) != null); if (!playerExists) playerExists = optPlayerList.contains(T.getOwnerName()); if (!playerExists) for (int i = 0; i < optPlayerList.size(); i++) if (((String) optPlayerList.get(i)).equalsIgnoreCase(T.getOwnerName())) { playerExists = true; break; } if (!playerExists) { T.setOwnerName(""); T.updateLot(null); return -1; } } int x = R.description().indexOf(SALESTR); if (x >= 0) { R.setDescription(R.description().substring(0, x)); CMLib.database().DBUpdateRoom(R); } x = R.description().indexOf(RENTSTR); if (x >= 0) { R.setDescription(R.description().substring(0, x)); CMLib.database().DBUpdateRoom(R); } // this works on the priciple that // 1. if an item has ONLY been removed, the lastNumItems will be != current # items // 2. if an item has ONLY been added, the dispossessiontime will be != null // 3. if an item has been added AND removed, the dispossession time will be != null on the // added if ((lastNumItems >= 0) && (R.numItems() != lastNumItems)) updateItems = true; for (int i = 0; i < R.numItems(); i++) { final Item I = R.getItem(i); if ((I.expirationDate() != 0) && ((I.isSavable()) || (I.Name().equalsIgnoreCase("id"))) && ((!(I instanceof DeadBody)) || (((DeadBody) I).isPlayerCorpse()))) { I.setExpirationDate(0); updateItems = true; } if ((I.phyStats().rejuv() != Integer.MAX_VALUE) && (I.phyStats().rejuv() != 0)) { I.basePhyStats().setRejuv(PhyStats.NO_REJUV); I.recoverPhyStats(); updateItems = true; } } lastNumItems = R.numItems(); if ((!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYITEMS)) && (updateItems)) CMLib.database().DBUpdateItems(R); } return lastNumItems; }
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if ((clanID().length() > 0) && (msg.amITarget(this))) { if (msg.source().getClanRole(clanID()) == null) { if ((msg.targetMinor() == CMMsg.TYP_GET) || (msg.targetMinor() == CMMsg.TYP_PUSH) || (msg.targetMinor() == CMMsg.TYP_PULL) || (msg.targetMinor() == CMMsg.TYP_CAST_SPELL)) { final Room R = CMLib.map().roomLocation(this); if (CMLib.clans().findRivalrousClan(msg.source()) == null) { msg.source().tell(L("You must belong to an elligible clan to take a clan item.")); return false; } else if (R != null) { for (int i = 0; i < R.numInhabitants(); i++) { final MOB M = R.fetchInhabitant(i); if ((M != null) && (M.isMonster()) && (M.getClanRole(clanID()) != null) && (CMLib.flags().aliveAwakeMobileUnbound(M, true)) && (CMLib.flags().canBeSeenBy(this, M)) && (!CMLib.flags().isAnimalIntelligence(M))) { R.show( M, null, CMMsg.MSG_QUIETMOVEMENT, L("<S-NAME> guard(s) @x1 closely.", name())); return false; } } String rulingClan = ""; final LegalBehavior B = CMLib.law().getLegalBehavior(R); if (B != null) rulingClan = B.rulingOrganization(); if (msg.source().getClanRole(rulingClan) == null) { msg.source() .tell(L("You must conquer and fully control this area to take the clan flag.")); return false; } if ((B != null) && (!B.isFullyControlled())) { msg.source().tell(L("Your clan does not yet fully control the area.")); return false; } } } else if ((msg.targetMinor() == CMMsg.TYP_DROP) && (!CMath.bset(msg.targetMajor(), CMMsg.MASK_INTERMSG))) { final Room R = msg.source().location(); LandTitle T = null; Area A = null; LegalBehavior B = null; if (R != null) { A = R.getArea(); T = CMLib.law().getLandTitle(R); } if ((T == null) || ((!T.getOwnerName().equals(clanID())) && ((!T.getOwnerName().equals(msg.source().getLiegeID())) || (!msg.source().isMarriedToLiege())) && (!T.getOwnerName().equals(msg.source().Name())))) { boolean ok = false; if (A != null) { B = CMLib.law().getLegalBehavior(R); if (B != null) ok = B.controlPoints() > 0; } if (!ok) { msg.source() .tell( L("You can not place a flag here, this place is controlled by the Archons.")); return false; } } } } else if ((msg.targetMinor() == CMMsg.TYP_GET) && (msg.source().location() != null) && (msg.source().isMonster())) { boolean foundOne = false; for (int i = 0; i < msg.source().location().numInhabitants(); i++) { final MOB M = msg.source().location().fetchInhabitant(i); if ((M != null) && (!M.isMonster()) && (M.getClanRole(clanID()) != null)) { foundOne = true; break; } } if (!foundOne) { msg.source().tell(L("You are guarding @x1 too closely.", name())); return false; } } } if (StdClanItem.stdOkMessage(this, msg)) { if ((clanID().length() > 0) && (msg.amITarget(this)) && (msg.targetMinor() == CMMsg.TYP_DROP)) { final LegalBehavior B = CMLib.law().getLegalBehavior(msg.source().location()); final String rulingClan = (B != null) ? B.rulingOrganization() : ""; if (rulingClan.length() == 0) msg.source() .tell( L("Area '@x1' is presently neutral.", msg.source().location().getArea().name())); else { msg.source() .tell( L( "Area '@x1' is presently controlled by @x2.", msg.source().location().getArea().name(), rulingClan)); if (!rulingClan.equals(clanID())) { int relation = Clan.REL_WAR; final Clan C = CMLib.clans().getClan(clanID()); if (C == null) { msg.source().tell(L("This ancient relic from a lost clan fades out of existence.")); this.destroy(); return false; } relation = C.getClanRelations(rulingClan); if (relation != Clan.REL_WAR) { msg.source() .tell( L("You must be at war with this clan to put down your flag on their area.")); return false; } } } } return super.okMessage(myHost, msg); } return false; }
public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { MOB target = mob; if ((auto) && (givenTarget != null) && (givenTarget instanceof MOB)) target = (MOB) givenTarget; if (target.fetchEffect(ID()) != null) { mob.tell(target, null, null, "<S-NAME> <S-IS-ARE> already squatting."); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; if (CMLib.law().doesHavePriviledgesHere(mob, mob.location())) { mob.tell("This is your place already!"); return false; } LandTitle T = CMLib.law().getLandTitle(mob.location()); boolean confirmed = false; for (final Enumeration<Ability> a = mob.location().effects(); a.hasMoreElements(); ) { final Ability A = a.nextElement(); if (A == T) confirmed = true; } if (T == null) { mob.tell("This property is not available for sale, and cannot be squatted upon."); return false; } MOB warnMOB = null; if (T.landOwner().length() > 0) { Clan C = CMLib.clans().getClan(T.landOwner()); if (C == null) { MOB M = CMLib.players().getLoadPlayer(T.landOwner()); if (M != null) warnMOB = M; } else { for (Session S : CMLib.sessions().localOnlineIterable()) { if ((S.mob() != null) && (S.mob() != mob) && (S.mob().getClanID().equals(C.clanID()))) warnMOB = S.mob(); } } if ((warnMOB == null) || (!CMLib.flags().isInTheGame(warnMOB, true))) { mob.tell("The owners must be in the game for you to begin squatting."); return false; } } if (!confirmed) { mob.tell("You cannot squat on an area for sale."); return false; } if (!CMLib.flags().isSitting(mob)) { mob.tell("You must be sitting!"); return false; } boolean success = proficiencyCheck(mob, 0, auto); CMMsg msg = CMClass.getMsg( mob, null, this, auto ? CMMsg.MASK_ALWAYS : CMMsg.MSG_DELICATE_SMALL_HANDS_ACT, CMMsg.MSG_DELICATE_SMALL_HANDS_ACT, CMMsg.MSG_DELICATE_SMALL_HANDS_ACT, auto ? "" : "<S-NAME> start(s) squatting."); if (!success) return beneficialVisualFizzle( mob, null, auto ? "" : "<S-NAME> can't seem to get comfortable here."); else if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); failed = false; room = mob.location(); title = T; beneficialAffect(mob, target, asLevel, (CMProps.getIntVar(CMProps.SYSTEMI_TICKSPERMUDMONTH))); if (warnMOB != null) warnMOB.tell( "You've heard a rumor that someone is squatting on " + T.landOwner() + "'s property."); } return success; }