@Override public ResponseMode diplomacy( Player other, NegotiateType about, ApproachType approach, Object argument) { DiplomaticRelation r = w.getRelation(p, other); if (r == null || !r.full) { return ResponseMode.NO; } // PlayerStrength senderStrength = getStrength(other); PlanetStatistics ownStats = p.getPlanetStatistics(null); // PlanetStatistics senderStas = computeVisibleStats(other); double rnd = ModelUtils.random(); double rel = r.value; Trait t = other.traits.trait(TraitKind.DIPLOMACY); if (t != null) { rel = rel * (1 + t.value / 100); rel = Math.min(100, Math.max(0, rel)); } switch (about) { case DIPLOMATIC_RELATIONS: if (rnd < rel / 100 && rel < p.warThreshold + 10) { return ResponseMode.MAYBE; } else if (rnd < rel / 100) { return ResponseMode.YES; } break; case ALLY: Player p3 = (Player) argument; if (p3.group == p.group) { return ResponseMode.NO; } DiplomaticRelation r2 = w.getRelation(p, p3); if (r2 != null) { if (rnd < 0.5 && rel >= p.warThreshold + 35 && r2.value < rel) { return ResponseMode.YES; } } break; case DARGSLAN: if (rnd < rel / 100 && rel >= 75 && !p.id.equals("Dargslan")) { return ResponseMode.YES; } break; case MONEY: if (rnd < rel / 100 || p.money() < 100000) { return ResponseMode.YES; } break; case SURRENDER: if (rnd < 0.1 && ownStats.planetCount < 2 && rel < p.warThreshold) { return ResponseMode.YES; } break; case TRADE: if (rnd < rel / 100) { return ResponseMode.YES; } break; default: } return ResponseMode.NO; }
@Override public void onAutoGroundwarStart( BattleInfo battle, AttackDefense attacker, AttackDefense defender) { w.establishWar(p, battle.enemy(p)); }
@Override public void onAutoSpacewarStart(BattleInfo battle, SpaceStrengths str) { w.establishWar(p, battle.enemy(p)); }
@Override public void groundBattleInit(GroundwarWorld war) { Player e = war.battle().enemy(p); w.establishWar(p, e); }