Skip to content

Commit

Permalink
Add extension treaty type
Browse files Browse the repository at this point in the history
  • Loading branch information
xdnw committed Jan 20, 2024
1 parent f700d60 commit d6d0c1e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ dependencies {

implementation('org.xerial:sqlite-jdbc:3.41.2.2')
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'org.jsoup:jsoup:1.15.3'
implementation 'org.jsoup:jsoup:1.12.1'
implementation 'org.bitbucket.cowwoc:diff-match-patch:1.2'

implementation ('net.dv8tion:JDA:5.0.0-beta.19') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public enum TreatyType {
NAP(2),

NPT(3),

EXTENSION(9, "Extension"),

;

Expand Down Expand Up @@ -46,7 +46,7 @@ public int getStrength() {

@Command(desc = "If this is a defensive treaty")
public boolean isDefensive() {
return this == MDP || this == MDOAP || this == ODP || this == ODOAP || this == PROTECTORATE;
return this == MDP || this == MDOAP || this == ODP || this == ODOAP || this == PROTECTORATE || this == EXTENSION;
}

@Command(desc = "If this is an offensive treaty")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3698,7 +3698,7 @@ public String counterSheet(@Me IMessageIO io, @Me GuildDB db,
alliesIds.addAll(protectorates);
}
if (includeMDP) {
alliesIds.addAll(Locutus.imp().getNationDB().getTreaties(aaId, TreatyType.MDP, TreatyType.MDOAP).keySet());
alliesIds.addAll(Locutus.imp().getNationDB().getTreaties(aaId, TreatyType.MDP, TreatyType.MDOAP, TreatyType.EXTENSION).keySet());
}
if (includeODP) {
alliesIds.addAll(Locutus.imp().getNationDB().getTreaties(aaId, TreatyType.ODP, TreatyType.ODOAP).keySet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public String onCommand(Guild guild, IMessageIO channel, User author, DBNation m
allies.addAll(protectorates);
}
if (includeMDP) {
allies.addAll(Locutus.imp().getNationDB().getTreaties(aaId, TreatyType.MDP, TreatyType.MDOAP).keySet());
allies.addAll(Locutus.imp().getNationDB().getTreaties(aaId, TreatyType.MDP, TreatyType.MDOAP, TreatyType.EXTENSION).keySet());
}
if (includeODP) {
allies.addAll(Locutus.imp().getNationDB().getTreaties(aaId, TreatyType.ODP, TreatyType.ODOAP).keySet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public String onCommand(List<String> args, Set<Character> flags, DBNation me, Gu
Map<Integer, Treaty> treaties = Locutus.imp().getNationDB().getTreaties(allianceId);
for (Map.Entry<Integer, Treaty> aaTreatyEntry : treaties.entrySet()) {
switch (aaTreatyEntry.getValue().getType()) {
case EXTENSION:
case MDP:
case MDOAP:
case PROTECTORATE:
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/link/locutus/discord/db/GuildDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,7 @@ public boolean isAllyOfRoot(boolean checkWhitelist) {
return isAllyOfRoot(type -> {
if (type == null) return false;
switch (type) {
case EXTENSION:
case MDP:
case MDOAP:
case ODP:
Expand Down Expand Up @@ -2617,6 +2618,7 @@ public Function<DBNation, Boolean> getCanRaid(int topX, boolean checkTreaties) {
Map<Integer, Treaty> treaties = Locutus.imp().getNationDB().getTreaties(allianceId);
for (Map.Entry<Integer, Treaty> aaTreatyEntry : treaties.entrySet()) {
switch (aaTreatyEntry.getValue().getType()) {
case EXTENSION:
case MDP:
case MDOAP:
case PROTECTORATE:
Expand Down Expand Up @@ -3020,6 +3022,7 @@ public Set<Integer> getAllies(boolean fetchTreaties) {
Map<Integer, Treaty> treaties = Locutus.imp().getNationDB().getTreaties(allianceId);
for (Map.Entry<Integer, Treaty> entry : treaties.entrySet()) {
switch (entry.getValue().getType()) {
case EXTENSION:
case MDP:
case MDOAP:
case ODP:
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/link/locutus/discord/db/WarDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,7 @@ public Map.Entry<Double, Double> getAACounterStats(int allianceId) {
for (Map.Entry<Integer, Treaty> entry : Locutus.imp().getNationDB().getTreaties(allianceId).entrySet()) {
Treaty treaty = entry.getValue();
switch (treaty.getType()) {
case EXTENSION:
case MDP:
case MDOAP:
case ODP:
Expand Down Expand Up @@ -1327,6 +1328,7 @@ public CounterStat updateCounter(DBWar war) {
Set<Integer> attAA = new HashSet<>(Collections.singleton(war.getAttacker_aa()));
for (Map.Entry<Integer, Treaty> entry : Locutus.imp().getNationDB().getTreaties(war.getAttacker_aa()).entrySet()) {
switch (entry.getValue().getType()) {
case EXTENSION:
case MDP:
case MDOAP:
case ODP:
Expand All @@ -1339,6 +1341,7 @@ public CounterStat updateCounter(DBWar war) {
Set<Integer> defAA = new HashSet<>(Collections.singleton(war.getDefender_aa()));
for (Map.Entry<Integer, Treaty> entry : Locutus.imp().getNationDB().getTreaties(war.getDefender_aa()).entrySet()) {
switch (entry.getValue().getType()) {
case EXTENSION:
case MDP:
case MDOAP:
case ODP:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ public static Set<DBAlliance> getTopX(int topX, boolean checkTreaty) {
Map<Integer, Treaty> treaties = Locutus.imp().getNationDB().getTreaties(allianceId);
for (Map.Entry<Integer, Treaty> aaTreatyEntry : treaties.entrySet()) {
switch (aaTreatyEntry.getValue().getType()) {
case EXTENSION:
case MDP:
case MDOAP:
case PROTECTORATE:
Expand Down Expand Up @@ -926,6 +927,7 @@ private static Set<DBAlliance> getTreaties(DBAlliance currentAA, Map<DBAlliance,
if (protector != null) continue;
getTreaties(otherAA, currentWeb, aaCache);
continue;
case EXTENSION:
case PROTECTORATE:
double score = otherAA.getScore();
double currentScore = 0;
Expand Down

0 comments on commit d6d0c1e

Please sign in to comment.