public boolean shutdown() { // int numTicks=tickGroup.size(); int which = 0; while (ticks.size() > 0) { // Log.sysOut("ServiceEngine","Shutting down all tick "+which+"/"+numTicks+"..."); Tick tock = ticks.getFirst(); if (tock != null) { CMProps.setUpAllLowVar( CMProps.SYSTEM_MUDSTATUS, "Shutting down...shutting down Service Engine: killing Tick#" + tock.getCounter() + ": " + tock.getStatus()); tock.shutdown(); } try { Thread.sleep(100); } catch (Exception e) { } which++; } CMProps.setUpAllLowVar( CMProps.SYSTEM_MUDSTATUS, "Shutting down...shutting down Service Engine: " + ID() + ": thread shutdown"); thread.shutdown(); // force final time tick! Vector timeObjects = new Vector(); for (Enumeration e = CMLib.map().areas(); e.hasMoreElements(); ) { Area A = ((Area) e.nextElement()); if (!timeObjects.contains(A.getTimeObj())) timeObjects.addElement(A.getTimeObj()); } CMProps.setUpAllLowVar( CMProps.SYSTEM_MUDSTATUS, "Shutting down...shutting down Service Engine: " + ID() + ": saving time objects"); for (int t = 0; t < timeObjects.size(); t++) ((TimeClock) timeObjects.elementAt(t)).save(); Log.sysOut("ServiceEngine", "Shutdown complete."); return true; }
@Override public boolean tick(Tickable ticking, int tickID) { if (!super.tick(ticking, tickID)) return false; if (affected == null) return false; if (!(affected instanceof MOB)) return true; final MOB mob = (MOB) affected; if (mob.amDead()) return true; if (!changed) { if (mob.location() == null) return true; final Area A = mob.location().getArea(); if (((A.getTimeObj().getTODCode() == TimeClock.TimeOfDay.DUSK) || (A.getTimeObj().getTODCode() == TimeClock.TimeOfDay.NIGHT)) && (A.getTimeObj().getMoonPhase() == TimeClock.MoonPhase.FULL)) { changed = true; mob.location() .show( mob, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> turn(s) into a @x1!", lycanRace().name())); mob.recoverCharStats(); mob.recoverPhyStats(); mob.recoverMaxState(); mob.location().recoverRoomStats(); } } else { if (mob.location() == null) return true; final Area A = mob.location().getArea(); if (((A.getTimeObj().getTODCode() != TimeClock.TimeOfDay.DUSK) && (A.getTimeObj().getTODCode() != TimeClock.TimeOfDay.NIGHT)) || (A.getTimeObj().getMoonPhase() != TimeClock.MoonPhase.FULL)) { changed = false; mob.location().show(mob, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> revert(s) to normal.")); mob.recoverCharStats(); mob.recoverPhyStats(); mob.recoverMaxState(); mob.location().recoverRoomStats(); return true; } tickLycanthropically(mob); } return true; }
public static boolean doRentalProperty(Area A, String ID, String owner, int rent) { if (!CMProps.getBoolVar(CMProps.Bool.MUDSTARTED)) return false; final int month = A.getTimeObj().getMonth(); final int day = A.getTimeObj().getDayOfMonth(); final int year = A.getTimeObj().getYear(); final Object O = Resources.getResource("RENTAL INFO/" + owner); List<PlayerData> pDataV = null; if (O instanceof List) pDataV = (List<PlayerData>) O; else pDataV = CMLib.database().DBReadData(owner, "RENTAL INFO"); if (pDataV == null) pDataV = new Vector(); DatabaseEngine.PlayerData pData = null; if (pDataV.size() == 0) { pData = new DatabaseEngine.PlayerData(); pData.who = owner; pData.section = "RENTAL INFO"; pData.key = "RENTAL INFO/" + owner; pData.xml = ID + "|~>|" + day + " " + month + " " + year + "|~;|"; CMLib.database().DBCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, pData.xml); pDataV.add(pData); Resources.submitResource("RENTAL INFO/" + owner, pDataV); return false; } else if (pDataV.get(0) != null) { pData = pDataV.get(0); String parse = pData.xml; int x = parse.indexOf("|~;|"); final StringBuffer reparse = new StringBuffer(""); boolean changesMade = false; boolean needsToPay = false; while (x >= 0) { String thisOne = parse.substring(0, x); if (thisOne.startsWith(ID + "|~>|")) { thisOne = thisOne.substring((ID + "|~>|").length()); final Vector dateV = CMParms.parse(thisOne); if (dateV.size() == 3) { int lastYear = CMath.s_int((String) dateV.lastElement()); int lastMonth = CMath.s_int((String) dateV.elementAt(1)); final int lastDay = CMath.s_int((String) dateV.firstElement()); while (!needsToPay) { if (lastYear < year) needsToPay = true; else if ((lastYear == year) && (lastMonth < month) && (day >= lastDay)) needsToPay = true; if (needsToPay) { if (CMLib.beanCounter() .modifyLocalBankGold( A, owner, CMLib.utensils().getFormattedDate(A) + ":Withdrawal of " + rent + ": Rent for " + ID, CMLib.beanCounter().getCurrency(A), (-rent))) { lastMonth++; if (lastMonth > A.getTimeObj().getMonthsInYear()) { lastMonth = 1; lastYear++; } changesMade = true; needsToPay = false; } } else break; } if (changesMade) reparse.append(ID + "|~>|" + lastDay + " " + lastMonth + " " + lastYear + "|~;|"); if (needsToPay && (!changesMade)) return true; } } else reparse.append(thisOne + "|~;|"); parse = parse.substring(x + 4); x = parse.indexOf("|~;|"); } if (changesMade) { CMLib.database() .DBReCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, reparse.toString()); pData = new DatabaseEngine.PlayerData(); pData.who = owner; pData.section = "RENTAL INFO"; pData.key = "RENTAL INFO/" + owner; pData.xml = reparse.toString(); pDataV.set(0, pData); Resources.removeResource("RENTAL INFO/" + owner); Resources.submitResource("RENTAL INFO/" + owner, pDataV); } return needsToPay; } return false; }