Skip to content

Commit

Permalink
Ditching the last implementation of the Arena (which was way too comp…
Browse files Browse the repository at this point in the history
…lex and not much different from the base game) and starting a hopefully much more interesting minigame loosely based on MOBAs.
  • Loading branch information
tukkek committed Feb 10, 2018
1 parent 291b677 commit dfcdfb3
Show file tree
Hide file tree
Showing 26 changed files with 229 additions and 1,443 deletions.
4 changes: 4 additions & 0 deletions javelin/controller/action/ai/AiMovement.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.awt.Image;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
Expand Down Expand Up @@ -60,6 +61,9 @@ private AiMovement() {

@Override
public List<List<ChanceNode>> getoutcomes(Combatant c, BattleState s) {
if (c.source.gettopspeed() == 0) {
return Collections.emptyList();
}
HashSet<Point> destinations = getdestinations(c, s);
ArrayList<List<ChanceNode>> outcomes = new ArrayList<List<ChanceNode>>(
Math.min(destinations.size(), MOVES));
Expand Down
10 changes: 8 additions & 2 deletions javelin/controller/action/world/minigame/EnterArena.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.awt.event.KeyEvent;

import javelin.model.world.location.unique.minigame.Arena;
import javelin.Javelin;
import javelin.controller.exception.battle.StartBattle;
import javelin.controller.fight.minigame.ArenaFight;
import javelin.view.screen.WorldScreen;

/**
Expand All @@ -11,6 +13,8 @@
* @author alex
*/
public class EnterArena extends EnterMinigame {
private static final String PROMPT = "Start an arena match?\n\nPress ENTER start or any other key to cancel...";

/** Constructor. */
public EnterArena() {
super("Arena (mini-game)", new int[] { KeyEvent.VK_A },
Expand All @@ -20,6 +24,8 @@ public EnterArena() {
@Override
public void perform(WorldScreen screen) {
super.perform(screen);
Arena.get().interact();
if (Javelin.DEBUG || Javelin.prompt(PROMPT) == '\n') {
throw new StartBattle(new ArenaFight());
}
}
}
24 changes: 15 additions & 9 deletions javelin/controller/challenge/CrCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,20 @@ CLASS_LEVEL_FACTOR, new QualitiesFactor(), new BreathFactor(),
*
* Will also update {@link Monster#challengerating}.
*
* @param monster
* @param m
* Unit to rate.
* @return The calculated CR.
*/
static public float calculatecr(final Monster monster) {
float[] r = calculaterawcr(monster);
static public float calculatecr(final Monster m) {
if (m.passive) {
return 0;
}
float[] r = calculaterawcr(m);
float goldenrule = r[1];
float base = goldenrule >= 4 ? Math.round(goldenrule)
: roundfraction(goldenrule);
float cr = translatecr(base);
monster.challengerating = cr;
m.challengerating = cr;
log(" total: " + r[0] + " golden rule: " + goldenrule + " final: " + cr
+ "\n");
return cr;
Expand All @@ -106,17 +109,20 @@ static public float calculatecr(final Monster monster) {
* {@link #roundfraction(float)} or {@link #translatecr(float)}, making it
* more suitable for more precise calculations.
*
* @param monster
* @param m
* Unit whose CR is to be calculated.
* @return An array where index 0 is the sum of all {@link #CR_FACTORS} and
* 1 is the same after the golden rule has been applied.
*/
public static float[] calculaterawcr(final Monster monster) {
log(monster.toString());
public static float[] calculaterawcr(final Monster m) {
if (m.passive) {
return new float[] { 0, 0 };
}
log(m.toString());
final TreeMap<CrFactor, Float> factorHistory = new TreeMap<CrFactor, Float>();
float cr = 0;
for (final CrFactor f : CR_FACTORS) {
final float result = f.calculate(monster);
final float result = f.calculate(m);
if (log != null) {
log(" " + f + ": " + result);
}
Expand Down Expand Up @@ -480,7 +486,7 @@ public static int crtoel(final float cr) {
throw new RuntimeException("Expand EL conversion: " + cr);
}

public static float calculatepositive(final List<Combatant> group) {
public static float calculatepositiveel(final List<Combatant> group) {
return calculateel(group) + Math.abs(MINIMUM_EL) + 1;
}

Expand Down
5 changes: 4 additions & 1 deletion javelin/controller/challenge/factor/SpellsFactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ public void registerupgrades(UpgradeHandler handler) {
*/
static public void init() {
for (Monster m : Javelin.ALLMONSTERS) {
UpgradeHandler.singleton.schoolsummoning.add(new Summon(m.name, 1));
if (!m.passive) {
UpgradeHandler.singleton.schoolsummoning
.add(new Summon(m.name, 1));
}
}
}
}
17 changes: 0 additions & 17 deletions javelin/controller/db/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import javelin.model.world.Season;
import javelin.model.world.World;
import javelin.model.world.location.unique.Haxor;
import javelin.model.world.location.unique.minigame.Arena;
import javelin.view.KeysScreen;
import javelin.view.frame.keys.BattleKeysScreen;
import javelin.view.frame.keys.PreferencesScreen;
Expand Down Expand Up @@ -101,10 +100,6 @@ public class Preferences {
/** Debug option. */
public static boolean DEBUGLABOR;
/** Debug option. */
public static Integer DEBUGCOINS;
// /** Debug option. */
// public static boolean DEBUGCLEARGARRISON;
/** Debug option. */
public static String DEBUGFOE;
/** Debug option. */
public static String DEBUGPERIOD;
Expand Down Expand Up @@ -265,7 +260,6 @@ static void readdebug() {
DEBUGRUBIES = javelin.controller.db.Preferences
.getinteger("cheat.rubies", null);
DEBUGLABOR = getboolean("cheat.labor");
DEBUGCOINS = getinteger("cheat.coins", null);
DEBUGFOE = getstring("cheat.monster");
DEBUGPERIOD = getstring("cheat.period");
DEBUGMAPTYPE = getstring("cheat.map");
Expand Down Expand Up @@ -298,17 +292,6 @@ static void initdebug() {
if (DEBUGRUBIES != null && Haxor.singleton != null) {
Haxor.singleton.rubies = DEBUGRUBIES;
}
if (DEBUGCOINS != null && Arena.get() != null) {
Arena.get().coins = DEBUGCOINS;
}
// if (DEBUGLABOR != null) {
// for (WorldActor a : Town.getall(Town.class)) {
// Town t = (Town) a;
// if (!t.ishostile()) {
// t.turn(time, screen);
// }
// }
// }
if (DEBUGWEATHER != null) {
DEBUGWEATHER = DEBUGWEATHER.toLowerCase();
Weather.read(0); // tests cheat.weather value
Expand Down
8 changes: 8 additions & 0 deletions javelin/controller/db/reader/MonsterReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public void startElement(final String uri, final String localName,
if (disabled != null && disabled.equals("true")) {
errorhandler.setInvalid("disabled");
}
String passive = attributes.getValue("passive");
monster.passive = passive != null && Boolean.parseBoolean(passive);
if (monster.passive) {
monster.challengerating = 0f;
}
} else if ("feats".equals(localName.toLowerCase())) {
section = "Feats";
} else if (localName.equals("Skills")) {
Expand Down Expand Up @@ -357,6 +362,9 @@ public void endDocument() throws SAXException {
postprocessspells();
int nMonsters = 0;
for (Monster m : Javelin.ALLMONSTERS) {
if (m.passive) {
continue;
}
List<Monster> list = Javelin.MONSTERSBYCR.get(m.challengerating);
if (list == null) {
list = new ArrayList<Monster>();
Expand Down
6 changes: 1 addition & 5 deletions javelin/controller/db/reader/fields/Speed.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public void read(String value) throws PropertyVetoException {
speedType = speedType.replaceAll("\\(", " \\(");
}
if (speedType.contains("climb ")) {
// speed.setClimb(Long.parseLong(speedType.replace("climb ",
// "")));
// ignore
} else if (speedType.contains("fly ")) {
final String maneuverability = speedType.substring(
speedType.indexOf("(") + 1, speedType.indexOf(")"));
Expand All @@ -64,9 +63,6 @@ public void read(String value) throws PropertyVetoException {
m.walk = Integer.parseInt(reader.cleanArmor(speedType));
}
}
if (m.fly == 0 && m.walk == 0) {
reader.errorhandler.setInvalid("Cannot move out of water!");
}
if (m.fly > 0) {
m.walk = 0;
}
Expand Down
Loading

0 comments on commit dfcdfb3

Please sign in to comment.