forked from MagicBane/Server
yet another attempt at mines
This commit is contained in:
@@ -19,6 +19,7 @@ import engine.workthreads.ZergMechanicThread;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -226,21 +227,16 @@ public class Mine extends AbstractGameObject {
|
||||
|
||||
// Errant mines are currently open. Set time to now.
|
||||
|
||||
LocalDateTime mineOpenTime;// = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0);
|
||||
if(mine.firstThirty == true){
|
||||
mineOpenTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(0).withSecond(0).withNano(0);
|
||||
}
|
||||
else{
|
||||
mineOpenTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(30).withSecond(0).withNano(0);
|
||||
}
|
||||
LocalDateTime mineOpenTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute);
|
||||
|
||||
LocalDateTime mineCloseTime = mineOpenTime.plusMinutes(30);
|
||||
if(LocalDateTime.now().isAfter(mineCloseTime)){
|
||||
if(LocalDateTime.now().isAfter(mineCloseTime) && mine.isActive == false){
|
||||
mineOpenTime = mineOpenTime.plusDays(1);
|
||||
mineCloseTime = mineCloseTime.plusDays(1);
|
||||
}
|
||||
writer.putLocalDateTime(mineOpenTime);
|
||||
writer.putLocalDateTime(mineCloseTime);
|
||||
|
||||
writer.put(mine.isActive ? (byte) 0x01 : (byte) 0x00);
|
||||
|
||||
Building mineTower = BuildingManager.getBuilding(mine.buildingID);
|
||||
@@ -250,9 +246,51 @@ public class Mine extends AbstractGameObject {
|
||||
|
||||
writer.putInt(mine.isExpansion() ? mine.mineType.xpacHash : mine.mineType.hash);
|
||||
|
||||
writer.putString(mine.guildName);
|
||||
GuildTag._serializeForDisplay(mine.guildTag, writer);
|
||||
writer.putString(mine.nationName);
|
||||
GuildTag._serializeForDisplay(mine.guildTag, writer);
|
||||
|
||||
boolean isPM = false;
|
||||
if(mineOpenTime.getHour() > 11)
|
||||
isPM = true;
|
||||
|
||||
int hourOpen = mineOpenTime.getHour();
|
||||
int minuteOpen = mineOpenTime.getMinute();
|
||||
int hourClose = mineCloseTime.getHour();
|
||||
int minuteClose = mineCloseTime.getMinute();
|
||||
|
||||
if(isPM){
|
||||
hourOpen -= 12;
|
||||
hourClose -= 12;
|
||||
}
|
||||
String timeString = hourOpen + ":";
|
||||
if(minuteOpen == 0){
|
||||
timeString += "00 ";
|
||||
}else{
|
||||
timeString += "30 ";
|
||||
}
|
||||
|
||||
if(isPM){
|
||||
timeString += "PM ";
|
||||
}else{
|
||||
timeString += "AM ";
|
||||
}
|
||||
|
||||
timeString += " to ";
|
||||
|
||||
timeString += hourClose + ":";
|
||||
|
||||
if(minuteClose == 0){
|
||||
timeString += "00 ";
|
||||
}else{
|
||||
timeString += "30 ";
|
||||
}
|
||||
|
||||
if(isPM){
|
||||
timeString += "PM CST";
|
||||
}else{
|
||||
timeString += "AM CST";
|
||||
}
|
||||
writer.putString(timeString);
|
||||
GuildTag._serializeForDisplay(mine.nationTag, writer);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class MineThread implements Runnable {
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
nextPulse = LocalDateTime.now().withMinute(0);
|
||||
nextPulse = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0);
|
||||
while (true) {
|
||||
if(LocalDateTime.now().isAfter(nextPulse)) {
|
||||
processMineWindows();
|
||||
@@ -33,7 +33,6 @@ public class MineThread implements Runnable {
|
||||
public static void mineWindowOpen(Mine mine) {
|
||||
|
||||
mine.setActive(true);
|
||||
ChatManager.chatSystemChannel(mine.getParentZone().getName() + "'s Mine is now Active!");
|
||||
Logger.info(mine.getParentZone().getName() + "'s Mine is now Active!");
|
||||
}
|
||||
|
||||
@@ -119,20 +118,26 @@ public class MineThread implements Runnable {
|
||||
LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).withSecond(0).withNano(0);
|
||||
if(currentTime.isAfter(openTime) && !mine.wasOpened){
|
||||
mineWindowOpen(mine); //hour and minute match, time to open the window
|
||||
ChatManager.chatSystemChannel(mine.getParentZone().getName() + " " + mine.getMineType() + "MINE is now vulnerable to attack!");
|
||||
continue;
|
||||
}
|
||||
|
||||
//check to see if the window shoul dbe closing now
|
||||
if(currentTime.isAfter(openTime.plusMinutes(29))) {
|
||||
if(currentTime.isAfter(openTime.plusMinutes(29)) && mine.isActive) {
|
||||
//check to see if the tower was destoryed
|
||||
boolean towerDestroyed = tower.getRank() < 1;
|
||||
if(towerDestroyed){
|
||||
//check if a valid claimer exists to close the window and claim the mine since the tower was destroyed
|
||||
if(mine.lastClaimer != null)
|
||||
if(mine.lastClaimer != null) {
|
||||
mineWindowClose(mine);
|
||||
ChatManager.chatSystemChannel("The fight for " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE has concluded. " + mine.lastClaimer.getName() + " has seized it in the name of " + mine.lastClaimer.getGuild().getNation());
|
||||
}else{
|
||||
ChatManager.chatSystemChannel("The " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE is still unclaimed. The battle continues.");
|
||||
}
|
||||
}else{
|
||||
//tower was not destroyed, mine window closes
|
||||
mineWindowClose(mine);
|
||||
ChatManager.chatSystemChannel(tower.getGuild().getNation().getName() + " has successfully defended the " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE, and retains their claim.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user