3.1 Config Updates Continued

This commit is contained in:
AconiteGodOfSWG
2021-03-30 03:02:28 -04:00
parent 355796dd48
commit dc9e2432ac
94 changed files with 338 additions and 311 deletions
@@ -4,6 +4,11 @@ import script.dictionary;
import script.library.fishing;
import script.obj_id;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.stream.Collectors;
public class master_object extends script.base_script {
public master_object()
@@ -39,11 +44,13 @@ public class master_object extends script.base_script {
if(!hasObjVar(self, OBJVAR_CONTROLLER_SETUP_TIME)) {
messageTo(self, "handleSetupMasterFishingObject", null, 20f, true);
}
// Update the leader board weekly, and force update if 7-days have passed since last update (in case of offline fails to trigger update)
// Reset the leaderboard period weekly and force update if 7-days have passed since last update (in case of offline fails to trigger update)
createWeeklyAlarmClock(self, "handleUpdateLeaderboards", null, DAY_OF_WEEK_THU, 19, 0,0);
if (!hasObjVar(self, OBJVAR_LEADERBOARD_UPDATE_TIME)) {
messageTo(self, "handleWeeklyUpdateLeaderboards", null, 20f, true);
}
// Update the current period board every 60 minutes
createHourlyAlarmClock(self, "handleUpdateCurrentPeriod", null, 0, 0);
if(getCalendarTime() > getIntObjVar(self, OBJVAR_LEADERBOARD_UPDATE_TIME) + 604800) {
messageTo(self, "handleWeeklyUpdateLeaderboards", null, 20f, true);
}
@@ -100,5 +107,38 @@ public class master_object extends script.base_script {
return SCRIPT_CONTINUE;
}
/*
* When fishing period starts:
* We're actively keeping track of who is in what position
*
*/
/**
* getCurrentLeadingFishingCities
* The total length of the best 25 non-collection fish caught during the Fishing Leaderboard period by the members/citizens
* of the guild/city are used to determine the guild/city Fishing Leaderboard score.
* @return dictionary containing cityId as key and a city's respective aggregate record of fish for the current period as the value
*/
public static dictionary getCurrentLeadingFishingCities() throws InterruptedException {
dictionary cityTotals = new dictionary();
float sizeAggregateCity = 0;
float size = 0;
String fishObjVar = fishing.OBJVAR_LARGEST_FISH_CAUGHT_THIS_PERIOD;
for (Integer city : getAllCityIds()) {
sizeAggregateCity = 0;
for (obj_id citizen : cityGetCitizenIds(city)) {
size = getFloatObjVar(citizen, fishObjVar);
if (size > 0) {
sizeAggregateCity += size;
}
}
if (sizeAggregateCity > 0) {
cityTotals.put(city, sizeAggregateCity);
}
}
return cityTotals;
}
}