forked from External/mage
[AFR] Implementing dungeon mechanic (ready for review) (#7937)
* added dungeon and dungeon room class * [AFR] Implemented Tomb of Annihilation * [AFR] Implemented Shortcut Seeker * [AFR] Implemented Gloom Stalker * [AFR] Implemented Nadaar, Selfless Paladin * added room triggers * added more venturing code, currently untested * fixed error * moved venture into dungeon from player class to game class * removed unnecessary sourceobject from dungeon * fixed npe error * added dungeon completion * fixed concurrent modification exception * added logging * added proper copy methods * added views * updated room text generation * added some missing code * finished implementing CompletedDungeonCondition * [AFR] Implemented Ellywick Tumblestrum * [AFR] Implemented Lost Mine of Phandelver * added choice dialog for dungeons * [AFR] Implemented Dungeon of the Mad Mage * small text fix * added initial dungeon test * [AFR] Implemented Cloister Gargoyle * [AFR] Implemented Dungeon Crawler * small text change for dungeon rooms * added more tests * some simplification to dungeon props * updated testing helper functions * added currently failing test for venturing on separate steps and turns * added tests for dungeon completion * fixed missing trigger visual and dungeons not persisting through turns * some text updates * added rollback test * added a test for multiple dungeons at once * added one more condition test
This commit is contained in:
parent
c6d08ce344
commit
bb591dd038
42 changed files with 2481 additions and 144 deletions
371
Mage/src/main/java/mage/game/command/Dungeon.java
Normal file
371
Mage/src/main/java/mage/game/command/Dungeon.java
Normal file
|
|
@ -0,0 +1,371 @@
|
|||
package mage.game.command;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.AbilitiesImpl;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.text.TextPart;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.game.Game;
|
||||
import mage.game.command.dungeons.DungeonOfTheMadMage;
|
||||
import mage.game.command.dungeons.LostMineOfPhandelver;
|
||||
import mage.game.command.dungeons.TombOfAnnihilation;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.players.Player;
|
||||
import mage.util.GameLog;
|
||||
import mage.util.SubTypes;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class Dungeon implements CommandObject {
|
||||
|
||||
private static final Set<String> dungeonNames = new HashSet<>();
|
||||
|
||||
static {
|
||||
dungeonNames.add("Tomb of Annihilation");
|
||||
dungeonNames.add("Lost Mine of Phandelver");
|
||||
dungeonNames.add("Dungeon of the Mad Mage");
|
||||
}
|
||||
|
||||
private static final ArrayList<CardType> emptySet = new ArrayList<>(Arrays.asList(CardType.DUNGEON));
|
||||
private static final ObjectColor emptyColor = new ObjectColor();
|
||||
private static final ManaCosts<ManaCost> emptyCost = new ManaCostsImpl<>();
|
||||
|
||||
private final String name;
|
||||
private UUID id;
|
||||
private UUID controllerId;
|
||||
private boolean copy;
|
||||
private MageObject copyFrom; // copied card INFO (used to call original adjusters)
|
||||
private FrameStyle frameStyle;
|
||||
private final Abilities<Ability> abilites = new AbilitiesImpl<>();
|
||||
private final String expansionSetCodeForImage;
|
||||
private final List<DungeonRoom> dungeonRooms = new ArrayList<>();
|
||||
private DungeonRoom currentRoom = null;
|
||||
|
||||
public Dungeon(String name, String expansionSetCodeForImage) {
|
||||
this.id = UUID.randomUUID();
|
||||
this.name = name;
|
||||
this.expansionSetCodeForImage = expansionSetCodeForImage;
|
||||
}
|
||||
|
||||
public Dungeon(final Dungeon dungeon) {
|
||||
this.id = dungeon.id;
|
||||
this.name = dungeon.name;
|
||||
this.frameStyle = dungeon.frameStyle;
|
||||
this.controllerId = dungeon.controllerId;
|
||||
this.copy = dungeon.copy;
|
||||
this.copyFrom = (dungeon.copyFrom != null ? dungeon.copyFrom : null);
|
||||
this.expansionSetCodeForImage = dungeon.expansionSetCodeForImage;
|
||||
this.copyRooms(dungeon);
|
||||
}
|
||||
|
||||
private void copyRooms(Dungeon dungeon) {
|
||||
Map<String, DungeonRoom> copyMap = new HashMap<>();
|
||||
for (DungeonRoom dungeonRoom : dungeon.dungeonRooms) {
|
||||
DungeonRoom copiedRoom = copyMap.computeIfAbsent(dungeonRoom.getName(), (s) -> dungeonRoom.copy());
|
||||
for (DungeonRoom nextRoom : dungeonRoom.getNextRooms()) {
|
||||
copiedRoom.addNextRoom(copyMap.computeIfAbsent(nextRoom.getName(), (s) -> nextRoom.copy()));
|
||||
}
|
||||
this.addRoom(copiedRoom);
|
||||
}
|
||||
this.currentRoom = copyMap.computeIfAbsent(dungeon.currentRoom.getName(), (s) -> dungeon.currentRoom.copy());
|
||||
}
|
||||
|
||||
public void addRoom(DungeonRoom room) {
|
||||
this.dungeonRooms.add(room);
|
||||
room.getRoomTriggeredAbility().setSourceId(id);
|
||||
this.abilites.add(room.getRoomTriggeredAbility());
|
||||
}
|
||||
|
||||
public void moveToNextRoom(UUID playerId, Game game) {
|
||||
if (currentRoom == null) {
|
||||
currentRoom = dungeonRooms.get(0);
|
||||
} else {
|
||||
currentRoom = currentRoom.chooseNextRoom(playerId, game);
|
||||
}
|
||||
Player player = game.getPlayer(getControllerId());
|
||||
if (player != null) {
|
||||
game.informPlayers(player.getLogName() + " has entered " + currentRoom.getName());
|
||||
}
|
||||
game.fireEvent(GameEvent.getEvent(
|
||||
GameEvent.EventType.ROOM_ENTERED, currentRoom.getId(), null, playerId
|
||||
));
|
||||
}
|
||||
|
||||
public DungeonRoom getCurrentRoom() {
|
||||
return currentRoom;
|
||||
}
|
||||
|
||||
public boolean hasNextRoom() {
|
||||
return currentRoom != null && currentRoom.hasNextRoom();
|
||||
}
|
||||
|
||||
public List<String> getRules() {
|
||||
List<String> rules = new ArrayList<>();
|
||||
rules.add("<i>(" + (
|
||||
currentRoom != null ?
|
||||
"Currently in " + currentRoom.getName() :
|
||||
"Not currently in a room"
|
||||
) + ")</i>");
|
||||
dungeonRooms.stream().map(DungeonRoom::toString).forEach(rules::add);
|
||||
return rules;
|
||||
}
|
||||
|
||||
public static Dungeon selectDungeon(UUID playerId, Game game) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
Choice choice = new ChoiceImpl(true);
|
||||
choice.setMessage("Choose a dungeon to venture into");
|
||||
choice.setChoices(dungeonNames);
|
||||
player.choose(Outcome.Neutral, choice, game);
|
||||
switch (choice.getChoice()) {
|
||||
case "Tomb of Annihilation":
|
||||
return new TombOfAnnihilation();
|
||||
case "Lost Mine of Phandelver":
|
||||
return new LostMineOfPhandelver();
|
||||
case "Dungeon of the Mad Mage":
|
||||
return new DungeonOfTheMadMage();
|
||||
default:
|
||||
throw new UnsupportedOperationException("A dungeon should have been chosen");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FrameStyle getFrameStyle() {
|
||||
return frameStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignNewId() {
|
||||
this.id = UUID.randomUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageObject getSourceObject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSourceId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getControllerId() {
|
||||
return this.controllerId;
|
||||
}
|
||||
|
||||
public void setControllerId(UUID controllerId) {
|
||||
this.controllerId = controllerId;
|
||||
this.abilites.setControllerId(controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCopy(boolean isCopy, MageObject copyFrom) {
|
||||
this.copy = isCopy;
|
||||
this.copyFrom = (copyFrom != null ? copyFrom.copy() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCopy() {
|
||||
return this.copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageObject getCopyFrom() {
|
||||
return this.copyFrom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdName() {
|
||||
return getName() + " [" + getId().toString().substring(0, 3) + ']';
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLogName() {
|
||||
return GameLog.getColoredObjectIdName(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImageName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<CardType> getCardType() {
|
||||
return emptySet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubTypes getSubtype() {
|
||||
return new SubTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubTypes getSubtype(Game game) {
|
||||
return new SubTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSubtype(SubType subtype, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<SuperType> getSuperType() {
|
||||
return EnumSet.noneOf(SuperType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Abilities<Ability> getAbilities() {
|
||||
return abilites;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAbility(Ability ability, Game game) {
|
||||
return getAbilities().contains(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectColor getColor() {
|
||||
return emptyColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectColor getColor(Game game) {
|
||||
return emptyColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectColor getFrameColor(Game game) {
|
||||
return emptyColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaCosts<ManaCost> getManaCost() {
|
||||
return emptyCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getManaValue() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageInt getPower() {
|
||||
return MageInt.EmptyMageInt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageInt getToughness() {
|
||||
return MageInt.EmptyMageInt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartingLoyalty() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartingLoyalty(int startingLoyalty) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dungeon copy() {
|
||||
return new Dungeon(this);
|
||||
}
|
||||
|
||||
public String getExpansionSetCodeForImage() {
|
||||
return expansionSetCodeForImage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZoneChangeCounter(Game game) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
|
||||
throw new UnsupportedOperationException("Unsupported operation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZoneChangeCounter(int value, Game game) {
|
||||
throw new UnsupportedOperationException("Unsupported operation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllCreatureTypes(Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsAllCreatureTypes(boolean value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsAllCreatureTypes(Game game, boolean value) {
|
||||
}
|
||||
|
||||
public void discardEffects() {
|
||||
for (Ability ability : abilites) {
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
if (effect instanceof ContinuousEffect) {
|
||||
((ContinuousEffect) effect).discard();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextPart> getTextParts() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextPart addTextPart(TextPart textPart) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePTCDA() {
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue