Upgrade to latest version of WyvernMods.

This commit is contained in:
Sindusk
2018-07-22 21:33:08 -04:00
parent f59852c91b
commit ba8dde10b5
31 changed files with 1358 additions and 161 deletions

View File

@@ -22,7 +22,7 @@ public class AffinityOrbQuestion extends Question {
this.affinityOrb = orb;
}
public static HashMap<Integer, Integer> affinityMap = new HashMap<>();
public HashMap<Integer, Integer> affinityMap = new HashMap<>();
@Override
public void answer(Properties answer) {

View File

@@ -296,6 +296,33 @@ public class LeaderboardCustomQuestion extends Question {
throw new RuntimeException(e);
}
}
protected void mostCitizens(int limit){
Connection dbcon;
PreparedStatement ps;
ResultSet rs;
String name;
int skillNum;
String mayor;
double stat;
try {
dbcon = DbConnector.getZonesDbCon();
ps = dbcon.prepareStatement("SELECT name, maxcitizens, mayor FROM villages WHERE disbanded = 0 ORDER BY maxcitizens DESC LIMIT "+limit);
rs = ps.executeQuery();
while(rs.next()){
name = rs.getString(1);
stat = rs.getInt(2);
mayor = rs.getString(3);
stat++; // Add one citizen to account for mayor.
names.add(name);
values.add(stat);
extra.add(mayor);
}
DbUtilities.closeDatabaseObjects(ps, rs);
}
catch (SQLException e) {
throw new RuntimeException(e);
}
}
@Override
public void sendQuestion() {
@@ -347,24 +374,29 @@ public class LeaderboardCustomQuestion extends Question {
ignoreOpt = true;
break;
case 8:
limit = 10;
topPlayerStats("kills", limit);
limit = 100;
mostCitizens(limit);
ignoreOpt = true;
break;
case 9:
limit = 10;
topPlayerStats("deaths", limit);
topPlayerStats("kills", limit);
ignoreOpt = true;
break;
case 10:
limit = 10;
topPlayerStats("deaths", limit);
ignoreOpt = true;
break;
case 11:
limit = 10;
topPlayerStats("depots", limit);
ignoreOpt = true;
break;
}
f.addBoldText("Top "+limit+" players in "+this.getQuestion(), new String[0]);
f.addText("\n\n", new String[0]);
f.addBoldText("Top "+limit+" players in "+this.getQuestion());
f.addText("\n\n");
int i = 0;
DecimalFormat df = new DecimalFormat(".000");
if(!format){
@@ -392,11 +424,11 @@ public class LeaderboardCustomQuestion extends Question {
}
i++;
}
f.addText(" \n", new String[0]);
f.addText(" \n");
f.beginHorizontalFlow();
f.addButton("Ok", "okay");
f.endHorizontalFlow();
f.addText(" \n", new String[0]);
f.addText(" \n");
this.getResponder().getCommunicator().sendBml(400, 500, true, true, f.toString(), 150, 150, 200, this.title);
}
}

View File

@@ -144,13 +144,15 @@ public class LeaderboardQuestion extends Question {
customMap.put(6, "Most Unique Achievements");
builder = builder + ",Largest Structures";
customMap.put(7, "Largest Structures");
builder = builder + ",Most Populated Villages";
customMap.put(8, "Most Populated Villages");
if(Servers.localServer.PVPSERVER || this.getResponder().getPower() >= 5){
builder = builder + ",PvP Kills";
customMap.put(8, "PvP Kills");
customMap.put(9, "PvP Kills");
builder = builder + ",PvP Deaths";
customMap.put(9, "PvP Deaths");
customMap.put(10, "PvP Deaths");
builder = builder + ",Depots Captured";
customMap.put(10, "PvP Depots Captured");
customMap.put(11, "PvP Depots Captured");
}
return builder;
}

View File

@@ -4,8 +4,6 @@ import com.wurmonline.server.DbConnector;
import com.wurmonline.server.creatures.Creature;
import com.wurmonline.server.deities.Deities;
import com.wurmonline.server.skills.SkillList;
import com.wurmonline.server.skills.SkillSystem;
import com.wurmonline.server.skills.SkillTemplate;
import com.wurmonline.server.utils.DbUtilities;
import net.coldie.tools.BmlForm;
import org.gotti.wurmunlimited.modsupport.ModSupportDb;
@@ -36,6 +34,29 @@ public class LeaderboardSkillQuestion extends Question {
}
}
public int[] getSkilLevelColors(double skill){
int[] colors = new int[3];
colors[0] = 0; // No red value
if(skill >= 90){
double percentTowards100 = 1-((100-skill)*0.1); // Division by 10
double greenPower = 128 + (128*percentTowards100);
colors[1] = (int) Math.min(255, greenPower);
colors[2] = (int) Math.max(0, 255-greenPower);
}else if(skill >= 50){
double percentTowards90 = 1-((90-skill)*0.025); // Division by 40
double greenPower = percentTowards90*128;
colors[1] = (int) Math.max(128, greenPower);
colors[2] = (int) Math.min(255, 255-greenPower);
}else{
double percentTowards50 = 1-((50-skill)*0.02); // Division by 50
double otherPower = 255 - (percentTowards50*255);
colors[0] = (int) Math.min(255, otherPower);
colors[1] = (int) Math.min(255, Math.max(128, otherPower));
colors[2] = 255;
}
return colors;
}
protected HashMap<String, Integer> optIn = new HashMap<>();
protected void identifyOptIn(){
String name;
@@ -95,8 +116,8 @@ public class LeaderboardSkillQuestion extends Question {
catch (SQLException e) {
throw new RuntimeException(e);
}
f.addBoldText("Top 20 players in "+this.getQuestion(), new String[0]);
f.addText("\n\n", new String[0]);
f.addBoldText("Top 20 players in "+this.getQuestion());
f.addText("\n\n");
int i = 0;
DecimalFormat df = new DecimalFormat(".000");
while(i < names.size() && i < skills.size()){
@@ -109,19 +130,20 @@ public class LeaderboardSkillQuestion extends Question {
if(skillNum == SkillList.CHANNELING){
extra = " ("+ Deities.getDeityName(deities.get(i))+")";
}
int[] color = getSkilLevelColors(skills.get(i));
if(names.get(i).equals(this.getResponder().getName())){
name = names.get(i);
f.addBoldText(df.format(skills.get(i)) + " - " + name + extra);
f.addBoldColoredText(df.format(skills.get(i)) + " - " + name + extra, color[0], color[1], color[2]);
}else{
f.addText(df.format(skills.get(i)) + " - " + name + extra);
f.addColoredText(df.format(skills.get(i)) + " - " + name + extra, color[0], color[1], color[2]);
}
i++;
}
f.addText(" \n", new String[0]);
f.addText(" \n");
f.beginHorizontalFlow();
f.addButton("Ok", "okay");
f.endHorizontalFlow();
f.addText(" \n", new String[0]);
f.addText(" \n");
this.getResponder().getCommunicator().sendBml(400, 500, true, true, f.toString(), 150, 150, 200, this.title);
}
}