forked from MagicBane/Server
				
			Compare commits
	
		
			No commits in common. 'lakebane-new' and 'master' have entirely different histories. 
		
	
	
		
			lakebane-n
			...
			master
		
	
		
	
				 49 changed files with 1030 additions and 1645 deletions
			
			
		@ -0,0 +1,77 @@
				@@ -0,0 +1,77 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
package engine.devcmd.cmds; | 
				
			||||
 | 
				
			||||
import engine.devcmd.AbstractDevCmd; | 
				
			||||
import engine.gameManager.ZoneManager; | 
				
			||||
import engine.objects.AbstractGameObject; | 
				
			||||
import engine.objects.PlayerCharacter; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * ./hotzone                      <- display the current hotzone & time remaining | 
				
			||||
 * ./hotzone random               <- change hotzone to random new zone | 
				
			||||
 */ | 
				
			||||
 | 
				
			||||
public class HotzoneCmd extends AbstractDevCmd { | 
				
			||||
 | 
				
			||||
    public HotzoneCmd() { | 
				
			||||
        super("hotzone"); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected void _doCmd(PlayerCharacter playerCharacter, String[] words, | 
				
			||||
                          AbstractGameObject target) { | 
				
			||||
 | 
				
			||||
        StringBuilder data = new StringBuilder(); | 
				
			||||
        String outString; | 
				
			||||
 | 
				
			||||
        for (String s : words) { | 
				
			||||
            data.append(s); | 
				
			||||
            data.append(' '); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        String input = data.toString().trim(); | 
				
			||||
 | 
				
			||||
        if (input.length() == 0) { | 
				
			||||
            outString = "Current hotZone: " + ZoneManager.hotZone.getName() + "\r\n"; | 
				
			||||
            outString += "Available hotZones: " + ZoneManager.availableHotZones(); | 
				
			||||
            throwbackInfo(playerCharacter, outString); | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        if (input.equalsIgnoreCase("random")) { | 
				
			||||
            ZoneManager.generateAndSetRandomHotzone(); | 
				
			||||
            outString = "New hotZone: " + ZoneManager.hotZone.getName() + "\r\n"; | 
				
			||||
            outString += "Available hotZones: " + ZoneManager.availableHotZones(); | 
				
			||||
            throwbackInfo(playerCharacter, outString); | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        if (input.equalsIgnoreCase("reset")) { | 
				
			||||
            ZoneManager.resetHotZones(); | 
				
			||||
            throwbackInfo(playerCharacter, "Available hotZones: " + ZoneManager.availableHotZones()); | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        return; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected String _getHelpString() { | 
				
			||||
        return "Use no arguments to see the current hotzone or \"random\" to change it randomly."; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected String _getUsageString() { | 
				
			||||
        return "'./hotzone [random]"; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
 | 
				
			||||
} | 
				
			||||
@ -1,92 +0,0 @@
				@@ -1,92 +0,0 @@
					 | 
				
			||||
package engine.gameManager; | 
				
			||||
import engine.objects.Guild; | 
				
			||||
public class ZergManager { | 
				
			||||
 | 
				
			||||
    public static float getCurrentMultiplier(int count, int maxCount){ | 
				
			||||
        switch(maxCount) { | 
				
			||||
            case 3: | 
				
			||||
                return getMultiplier3Man(count); | 
				
			||||
            case 5: | 
				
			||||
                return getMultiplier5Man(count); | 
				
			||||
            case 10: | 
				
			||||
                return getMultiplier10Man(count); | 
				
			||||
            default: | 
				
			||||
                return getMultiplier20Man(count); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static float getMultiplier3Man(int count) { | 
				
			||||
        if(count < 4) | 
				
			||||
            return 1.0f; | 
				
			||||
 | 
				
			||||
        if(count > 6) | 
				
			||||
            return 0.0f; | 
				
			||||
 | 
				
			||||
        switch(count){ | 
				
			||||
            case 4: | 
				
			||||
                return 0.75f; | 
				
			||||
            case 5: | 
				
			||||
                return 0.60f; | 
				
			||||
            case 6: | 
				
			||||
                return 0.37f; | 
				
			||||
 | 
				
			||||
        } | 
				
			||||
        return 1.0f; | 
				
			||||
    } | 
				
			||||
    public static float getMultiplier5Man(int count) { | 
				
			||||
        if(count < 6) | 
				
			||||
            return 1.0f; | 
				
			||||
 | 
				
			||||
        if(count > 10) | 
				
			||||
            return 0.0f; | 
				
			||||
 | 
				
			||||
        switch(count){ | 
				
			||||
            case 6: | 
				
			||||
                return 0.75f; | 
				
			||||
            case 7: | 
				
			||||
                return 0.67f; | 
				
			||||
            case 8: | 
				
			||||
                return 0.56f; | 
				
			||||
            case 9: | 
				
			||||
                return 0.43f; | 
				
			||||
            case 10: | 
				
			||||
                return 0.25f; | 
				
			||||
 | 
				
			||||
        } | 
				
			||||
        return 1.0f; | 
				
			||||
    } | 
				
			||||
    public static float getMultiplier10Man(int count) { | 
				
			||||
        if(count < 11) | 
				
			||||
            return 1.0f; | 
				
			||||
 | 
				
			||||
        if(count > 20) | 
				
			||||
            return 0.0f; | 
				
			||||
 | 
				
			||||
        switch(count){ | 
				
			||||
            case 11: | 
				
			||||
                return 0.75f; | 
				
			||||
            case 12: | 
				
			||||
                return 0.71f; | 
				
			||||
            case 13: | 
				
			||||
                return 0.67f; | 
				
			||||
            case 14: | 
				
			||||
                return 0.62f; | 
				
			||||
            case 15: | 
				
			||||
                return 0.56f; | 
				
			||||
            case 16: | 
				
			||||
                return 0.50f; | 
				
			||||
            case 17: | 
				
			||||
                return 0.43f; | 
				
			||||
            case 18: | 
				
			||||
                return 0.35f; | 
				
			||||
            case 19: | 
				
			||||
                return 0.25f; | 
				
			||||
            case 20: | 
				
			||||
                return 0.14f; | 
				
			||||
 | 
				
			||||
        } | 
				
			||||
        return 1.0f; | 
				
			||||
    } | 
				
			||||
    public static float getMultiplier20Man(int count) { | 
				
			||||
        return getMultiplier10Man(count * 2); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -1,166 +0,0 @@
				@@ -1,166 +0,0 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
package engine.workthreads; | 
				
			||||
 | 
				
			||||
import engine.Enum; | 
				
			||||
import engine.InterestManagement.WorldGrid; | 
				
			||||
import engine.db.archive.DataWarehouse; | 
				
			||||
import engine.db.archive.MineRecord; | 
				
			||||
import engine.gameManager.*; | 
				
			||||
import engine.net.DispatchMessage; | 
				
			||||
import engine.net.MessageDispatcher; | 
				
			||||
import engine.net.client.msg.chat.ChatSystemMsg; | 
				
			||||
import engine.objects.*; | 
				
			||||
import engine.server.world.WorldServer; | 
				
			||||
import org.pmw.tinylog.Logger; | 
				
			||||
 | 
				
			||||
import java.time.LocalDateTime; | 
				
			||||
import java.util.ArrayList; | 
				
			||||
import java.util.concurrent.ConcurrentHashMap; | 
				
			||||
 | 
				
			||||
import static engine.server.MBServerStatics.MINE_LATE_WINDOW; | 
				
			||||
 | 
				
			||||
public class HalfHourlyJobThread implements Runnable { | 
				
			||||
 | 
				
			||||
    public HalfHourlyJobThread() { | 
				
			||||
 | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
 | 
				
			||||
    public static void processMineWindow() { | 
				
			||||
 | 
				
			||||
        try { | 
				
			||||
 | 
				
			||||
            ArrayList<Mine> mines = Mine.getMines(); | 
				
			||||
 | 
				
			||||
            for (Mine mine : mines) { | 
				
			||||
                try { | 
				
			||||
 | 
				
			||||
                    //handle mines opening on server reboot weird time interval
 | 
				
			||||
                    if(LocalDateTime.now().isAfter(LocalDateTime.now().withHour(mine.openHour).withMinute(mine.openMinute))) { | 
				
			||||
                        if (LocalDateTime.now().isBefore(LocalDateTime.now().withHour(mine.openHour).withMinute(mine.openMinute).plusMinutes(30))) { | 
				
			||||
                            HalfHourlyJobThread.mineWindowOpen(mine); | 
				
			||||
                            continue; | 
				
			||||
                        } | 
				
			||||
                    } | 
				
			||||
 | 
				
			||||
                    // set to the current mine window.
 | 
				
			||||
 | 
				
			||||
                    if (mine.openHour == LocalDateTime.now().getHour() && mine.openMinute == LocalDateTime.now().getMinute() && !mine.wasClaimed) { | 
				
			||||
                        HalfHourlyJobThread.mineWindowOpen(mine); | 
				
			||||
                        continue; | 
				
			||||
                    } | 
				
			||||
 | 
				
			||||
                    // Close the mine if it reaches this far
 | 
				
			||||
                    LocalDateTime openTime = LocalDateTime.now().withHour(mine.openHour).withMinute(mine.openMinute); | 
				
			||||
                    if(LocalDateTime.now().plusMinutes(1).isAfter(openTime.plusMinutes(30))) | 
				
			||||
                        mineWindowClose(mine); | 
				
			||||
 | 
				
			||||
                } catch (Exception e) { | 
				
			||||
                    Logger.error("mineID: " + mine.getObjectUUID(), e.toString()); | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
        } catch (Exception e) { | 
				
			||||
            Logger.error(e.toString()); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static void mineWindowOpen(Mine mine) { | 
				
			||||
 | 
				
			||||
        mine.setActive(true); | 
				
			||||
        ChatManager.chatSystemChannel(mine.getZoneName() + "'s Mine is now Active!"); | 
				
			||||
        Logger.info(mine.getZoneName() + "'s Mine is now Active!"); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static boolean mineWindowClose(Mine mine) { | 
				
			||||
 | 
				
			||||
        // No need to end the window of a mine which never opened.
 | 
				
			||||
 | 
				
			||||
        if (mine.isActive == false) | 
				
			||||
            return false; | 
				
			||||
 | 
				
			||||
        Building mineBuilding = BuildingManager.getBuildingFromCache(mine.getBuildingID()); | 
				
			||||
 | 
				
			||||
        if (mineBuilding == null) { | 
				
			||||
            Logger.debug("Null mine building for Mine " + mine.getObjectUUID() + " Building " + mine.getBuildingID()); | 
				
			||||
            return false; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        // Mine building still stands; nothing to do.
 | 
				
			||||
        // We can early exit here.
 | 
				
			||||
 | 
				
			||||
        if (mineBuilding.getRank() > 0) { | 
				
			||||
            mine.setActive(false); | 
				
			||||
            mine.lastClaimer = null; | 
				
			||||
            ChatSystemMsg chatMsg = new ChatSystemMsg(null, mine.guildName + " has defended the mine in " + mine.getParentZone().getParent().getName() + ". The mine is no longer active."); | 
				
			||||
            chatMsg.setMessageType(10); | 
				
			||||
            chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); | 
				
			||||
            DispatchMessage.dispatchMsgToAll(chatMsg); | 
				
			||||
            return true; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        // This mine does not have a valid claimer
 | 
				
			||||
        // we will therefore set it to errant
 | 
				
			||||
        // and keep the window open.
 | 
				
			||||
 | 
				
			||||
        if (!Mine.validateClaimer(mine.lastClaimer)) { | 
				
			||||
            mine.lastClaimer = null; | 
				
			||||
            mine.updateGuildOwner(null); | 
				
			||||
            mine.setActive(true); | 
				
			||||
            ChatSystemMsg chatMsg = new ChatSystemMsg(null, mine.getParentZone().getParent().getName() + " Was not claimed, the battle rages on!"); | 
				
			||||
            chatMsg.setMessageType(10); | 
				
			||||
            chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); | 
				
			||||
            DispatchMessage.dispatchMsgToAll(chatMsg); | 
				
			||||
            return false; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        //Update ownership to map
 | 
				
			||||
 | 
				
			||||
        mine.guildName = mine.getOwningGuild().getName(); | 
				
			||||
        mine.guildTag = mine.getOwningGuild().getGuildTag(); | 
				
			||||
        Guild nation = mine.getOwningGuild().getNation(); | 
				
			||||
        mine.nationName = nation.getName(); | 
				
			||||
        mine.nationTag = nation.getGuildTag(); | 
				
			||||
 | 
				
			||||
        mineBuilding.rebuildMine(); | 
				
			||||
        WorldGrid.updateObject(mineBuilding); | 
				
			||||
 | 
				
			||||
        ChatSystemMsg chatMsg = new ChatSystemMsg(null, mine.lastClaimer.getName() + " has claimed the mine in " + mine.getParentZone().getParent().getName() + " for " + mine.getOwningGuild().getName() + ". The mine is no longer active."); | 
				
			||||
        chatMsg.setMessageType(10); | 
				
			||||
        chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); | 
				
			||||
        DispatchMessage.dispatchMsgToAll(chatMsg); | 
				
			||||
 | 
				
			||||
        // Warehouse this claim event
 | 
				
			||||
 | 
				
			||||
        MineRecord mineRecord = MineRecord.borrow(mine, mine.lastClaimer, Enum.RecordEventType.CAPTURE); | 
				
			||||
        DataWarehouse.pushToWarehouse(mineRecord); | 
				
			||||
 | 
				
			||||
        mineBuilding.setRank(mineBuilding.getRank()); | 
				
			||||
        mine.lastClaimer = null; | 
				
			||||
        mine.setActive(false); | 
				
			||||
        mine.wasClaimed = true; | 
				
			||||
        for(Integer id : mine._playerMemory){ | 
				
			||||
            PlayerCharacter pc = PlayerCharacter.getFromCache(id); | 
				
			||||
            if(pc != null) | 
				
			||||
                pc.ZergMultiplier = 1.0f; | 
				
			||||
        } | 
				
			||||
        return true; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void run() { | 
				
			||||
 | 
				
			||||
        Logger.info("Half-Hourly job is now running."); | 
				
			||||
 | 
				
			||||
        // Open or Close mines for the current mine window.
 | 
				
			||||
 | 
				
			||||
        processMineWindow(); | 
				
			||||
 | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue