Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Nothing is easy #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions src/main/java/code/ModFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import basemod.abstracts.DynamicVariable;
import basemod.helpers.RelicType;
import basemod.interfaces.*;
import code.cards.BaseCard;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.MathUtils;
Expand All @@ -20,14 +21,10 @@
import com.megacrit.cardcrawl.localization.RelicStrings;
import com.megacrit.cardcrawl.localization.StanceStrings;
import com.megacrit.cardcrawl.localization.UIStrings;
import com.megacrit.cardcrawl.potions.AbstractPotion;
import com.megacrit.cardcrawl.unlock.UnlockTracker;
import code.cards.AbstractEasyCard;
import code.cards.cardvars.AbstractEasyDynamicVariable;
import code.cards.cardvars.SecondDamage;
import code.cards.cardvars.SecondMagicNumber;
import code.potions.AbstractEasyPotion;
import code.relics.AbstractEasyRelic;
import code.cards.cardvars.BaseDynamicVariable;
import code.potions.BasePotion;
import code.relics.BaseRelic;
import code.util.ProAudio;
import java.nio.charset.StandardCharsets;

Expand Down Expand Up @@ -122,8 +119,8 @@ public void receiveEditCharacters() {
CHARSELECT_BUTTON, CHARSELECT_PORTRAIT, CharacterFile.Enums.THE_TODO);

new AutoAdd(modID)
.packageFilter(AbstractEasyPotion.class)
.any(AbstractEasyPotion.class, (info, potion) -> {
.packageFilter(BasePotion.class)
.any(BasePotion.class, (info, potion) -> {
if (potion.pool == null)
BaseMod.addPotion(potion.getClass(), potion.liquidColor, potion.hybridColor, potion.spotsColor, potion.ID);
else
Expand All @@ -134,8 +131,8 @@ public void receiveEditCharacters() {
@Override
public void receiveEditRelics() {
new AutoAdd(modID)
.packageFilter(AbstractEasyRelic.class)
.any(AbstractEasyRelic.class, (info, relic) -> {
.packageFilter(BaseRelic.class)
.any(BaseRelic.class, (info, relic) -> {
if (relic.color == null) {
BaseMod.addRelic(relic, RelicType.SHARED);
} else {
Expand All @@ -150,11 +147,11 @@ public void receiveEditRelics() {
@Override
public void receiveEditCards() {
new AutoAdd(modID)
.packageFilter(AbstractEasyDynamicVariable.class)
.packageFilter(BaseDynamicVariable.class)
.any(DynamicVariable.class, (info, var) ->
BaseMod.addDynamicVariable(var));
new AutoAdd(modID)
.packageFilter(AbstractEasyCard.class)
.packageFilter(BaseCard.class)
.setDefaultSeen(true)
.cards();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

import java.util.ArrayList;

public class EasyModalChoiceAction extends SelectCardsCenteredAction {
public class ModalChoiceAction extends SelectCardsCenteredAction {

public EasyModalChoiceAction(ArrayList<AbstractCard> list, int amount, String textforSelect) {
public ModalChoiceAction(ArrayList<AbstractCard> list, int amount, String textforSelect) {
super(list, amount, textforSelect, (cards) -> {
for (AbstractCard q : cards) {
q.onChoseThisOption();
}
});
}

public EasyModalChoiceAction(ArrayList<AbstractCard> list, int amount) {
public ModalChoiceAction(ArrayList<AbstractCard> list, int amount) {
this(list, amount, "Choose.");
}

public EasyModalChoiceAction(ArrayList<AbstractCard> list) {
public ModalChoiceAction(ArrayList<AbstractCard> list) {
this(list, 1, "Choose.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.util.function.BiFunction;

public class EasyXCostAction extends AbstractGameAction {
public class XCostAction extends AbstractGameAction {
public BiFunction<Integer, int[], Boolean> xActionUpdate;
public int[] params;
protected int baseValue;
Expand All @@ -21,7 +21,7 @@ public class EasyXCostAction extends AbstractGameAction {
* @param xActionUpdate A BiFunction that receives an integer for the energy amount (includes Chem X) and any number of integer parameters in the form of an array. The return value of this function is isDone.
* @param params Any number of integer parameters. These will be passed to the update function to avoid possible value changes between the creation of this action and when it is updated.
*/
public EasyXCostAction(AbstractCard card, BiFunction<Integer, int[], Boolean> xActionUpdate, int... params) {
public XCostAction(AbstractCard card, BiFunction<Integer, int[], Boolean> xActionUpdate, int... params) {
this.baseValue = card.energyOnUse;
this.freeToPlayOnce = card.freeToPlayOnce;
this.xActionUpdate = xActionUpdate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import static code.ModFile.modID;
import static code.util.Wiz.*;

public abstract class AbstractEasyCard extends CustomCard {
public abstract class BaseCard extends CustomCard {

protected final CardStrings cardStrings;

Expand All @@ -49,11 +49,11 @@ public abstract class AbstractEasyCard extends CustomCard {

private boolean needsArtRefresh = false;

public AbstractEasyCard(final String cardID, final int cost, final CardType type, final CardRarity rarity, final CardTarget target) {
public BaseCard(final String cardID, final int cost, final CardType type, final CardRarity rarity, final CardTarget target) {
this(cardID, cost, type, rarity, target, CharacterFile.Enums.TODO_COLOR);
}

public AbstractEasyCard(final String cardID, final int cost, final CardType type, final CardRarity rarity, final CardTarget target, final CardColor color) {
public BaseCard(final String cardID, final int cost, final CardType type, final CardRarity rarity, final CardTarget target, final CardColor color) {
super(cardID, "", getCardTextureString(cardID.replace(modID + ":", ""), type),
cost, "", type, color, rarity, target);
cardStrings = CardCrawlGame.languagePack.getCardStrings(this.cardID);
Expand Down Expand Up @@ -238,8 +238,8 @@ public void update() {

public AbstractCard makeStatEquivalentCopy() {
AbstractCard result = super.makeStatEquivalentCopy();
if (result instanceof AbstractEasyCard) {
AbstractEasyCard c = (AbstractEasyCard) result;
if (result instanceof BaseCard) {
BaseCard c = (BaseCard) result;
c.baseSecondDamage = c.secondDamage = baseSecondDamage;
c.baseSecondBlock = c.secondBlock = baseSecondBlock;
c.baseSecondMagic = c.secondMagic = baseSecondMagic;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/code/cards/Defend.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import static code.ModFile.makeID;

public class Defend extends AbstractEasyCard {
public class Defend extends BaseCard {
public final static String ID = makeID("Defend");
// intellij stuff skill, self, basic, , , 5, 3, ,

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/code/cards/FILE TEMPLATE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Settings -> Editor -> File and Code Templates and add the following!

import code.cards.AbstractEasyCard;
import code.cards.BaseCard;

import static code.ModFile.makeID;
import static code.util.Wiz.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import static code.ModFile.makeID;

@AutoAdd.Ignore
public class EasyModalChoiceCard extends AbstractEasyCard {
public class ModalChoiceCard extends BaseCard {

private Runnable onUseOrChosen;
private String passedName;
private String passedDesc;

public EasyModalChoiceCard(String name, String description, Runnable onUseOrChosen) {
public ModalChoiceCard(String name, String description, Runnable onUseOrChosen) {
super(makeID(name), -2, CardType.SKILL, CardRarity.SPECIAL, CardTarget.NONE, CardColor.COLORLESS);
this.name = this.originalName = passedName = name;
this.rawDescription = passedDesc = description;
Expand Down Expand Up @@ -49,6 +49,6 @@ public void upgrade() {

@Override
public AbstractCard makeCopy() {
return new EasyModalChoiceCard(passedName, passedDesc, onUseOrChosen);
return new ModalChoiceCard(passedName, passedDesc, onUseOrChosen);
}
}
2 changes: 1 addition & 1 deletion src/main/java/code/cards/Strike.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import static code.ModFile.makeID;

public class Strike extends AbstractEasyCard {
public class Strike extends BaseCard {
public final static String ID = makeID("Strike");
// intellij stuff attack, enemy, basic, 6, 3, , , ,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import basemod.abstracts.DynamicVariable;

public abstract class AbstractEasyDynamicVariable extends DynamicVariable {
public abstract class BaseDynamicVariable extends DynamicVariable {

}
24 changes: 12 additions & 12 deletions src/main/java/code/cards/cardvars/SecondBlock.java
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
package code.cards.cardvars;

import code.cards.AbstractEasyCard;
import code.cards.BaseCard;
import com.megacrit.cardcrawl.cards.AbstractCard;

import static code.ModFile.makeID;

public class SecondBlock extends AbstractEasyDynamicVariable {
public class SecondBlock extends BaseDynamicVariable {
@Override
public String key() {
return makeID("sb");
}

@Override
public boolean isModified(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).isSecondBlockModified;
if (card instanceof BaseCard) {
return ((BaseCard) card).isSecondBlockModified;
}
return false;
}

public void setIsModified(AbstractCard card, boolean v) {
if (card instanceof AbstractEasyCard) {
((AbstractEasyCard) card).isSecondBlockModified = v;
if (card instanceof BaseCard) {
((BaseCard) card).isSecondBlockModified = v;
}
}

@Override
public int value(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).secondBlock;
if (card instanceof BaseCard) {
return ((BaseCard) card).secondBlock;
}
return -1;
}

@Override
public int baseValue(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).baseSecondBlock;
if (card instanceof BaseCard) {
return ((BaseCard) card).baseSecondBlock;
}
return -1;
}

@Override
public boolean upgraded(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).upgradedSecondBlock;
if (card instanceof BaseCard) {
return ((BaseCard) card).upgradedSecondBlock;
}
return false;
}
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/code/cards/cardvars/SecondDamage.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package code.cards.cardvars;

import code.cards.BaseCard;
import com.megacrit.cardcrawl.cards.AbstractCard;
import code.cards.AbstractEasyCard;

import static code.ModFile.makeID;

public class SecondDamage extends AbstractEasyDynamicVariable {
public class SecondDamage extends BaseDynamicVariable {

@Override
public String key() {
Expand All @@ -14,38 +14,38 @@ public String key() {

@Override
public boolean isModified(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).isSecondDamageModified;
if (card instanceof BaseCard) {
return ((BaseCard) card).isSecondDamageModified;
}
return false;
}

public void setIsModified(AbstractCard card, boolean v) {
if (card instanceof AbstractEasyCard) {
((AbstractEasyCard) card).isSecondDamageModified = v;
if (card instanceof BaseCard) {
((BaseCard) card).isSecondDamageModified = v;
}
}

@Override
public int value(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).secondDamage;
if (card instanceof BaseCard) {
return ((BaseCard) card).secondDamage;
}
return -1;
}

@Override
public int baseValue(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).baseSecondDamage;
if (card instanceof BaseCard) {
return ((BaseCard) card).baseSecondDamage;
}
return -1;
}

@Override
public boolean upgraded(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).upgradedSecondDamage;
if (card instanceof BaseCard) {
return ((BaseCard) card).upgradedSecondDamage;
}
return false;
}
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/code/cards/cardvars/SecondMagicNumber.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package code.cards.cardvars;

import code.cards.BaseCard;
import com.megacrit.cardcrawl.cards.AbstractCard;
import code.cards.AbstractEasyCard;

import static code.ModFile.makeID;

public class SecondMagicNumber extends AbstractEasyDynamicVariable {
public class SecondMagicNumber extends BaseDynamicVariable {

@Override
public String key() {
Expand All @@ -14,38 +14,38 @@ public String key() {

@Override
public boolean isModified(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).isSecondMagicModified;
if (card instanceof BaseCard) {
return ((BaseCard) card).isSecondMagicModified;
}
return false;
}

@Override
public int value(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).secondMagic;
if (card instanceof BaseCard) {
return ((BaseCard) card).secondMagic;
}
return -1;
}

public void setIsModified(AbstractCard card, boolean v) {
if (card instanceof AbstractEasyCard) {
((AbstractEasyCard) card).isSecondMagicModified = v;
if (card instanceof BaseCard) {
((BaseCard) card).isSecondMagicModified = v;
}
}

@Override
public int baseValue(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).baseSecondMagic;
if (card instanceof BaseCard) {
return ((BaseCard) card).baseSecondMagic;
}
return -1;
}

@Override
public boolean upgraded(AbstractCard card) {
if (card instanceof AbstractEasyCard) {
return ((AbstractEasyCard) card).upgradedSecondMagic;
if (card instanceof BaseCard) {
return ((BaseCard) card).upgradedSecondMagic;
}
return false;
}
Expand Down
Loading