Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. import com.megacrit.cardcrawl.actions.AbstractGameAction;
  2. import com.megacrit.cardcrawl.cards.AbstractCard;
  3. import com.megacrit.cardcrawl.cards.CardGroup;
  4. import com.megacrit.cardcrawl.characters.AbstractPlayer;
  5. import com.megacrit.cardcrawl.core.CardCrawlGame;
  6. import com.megacrit.cardcrawl.core.Settings;
  7. import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
  8.  
  9. import java.util.ArrayList;
  10.  
  11. // Organizes card by alphabet for better UX.
  12. public class BetterDrawPileToHandAction extends AbstractGameAction {
  13.  
  14. // TODO: Use your own strings. My json looked like this:
  15. //"TEXT": [
  16. // "Choose a Card to Put into Your Hand.",
  17. // "Choose ",
  18. // " Cards to Put into Your Hand."
  19. //]
  20. public static final String[] TEXT = CardCrawlGame.languagePack.getUIString("").TEXT;
  21. private AbstractPlayer player;
  22. private int numberOfCards;
  23. private boolean optional;
  24.  
  25. public BetterDrawPileToHandAction(int numberOfCards, boolean optional) {
  26. this.actionType = ActionType.CARD_MANIPULATION;
  27. this.duration = this.startDuration = Settings.ACTION_DUR_FAST;
  28. this.player = AbstractDungeon.player;
  29. this.numberOfCards = numberOfCards;
  30. this.optional = optional;
  31. }
  32.  
  33. public BetterDrawPileToHandAction(int numberOfCards) {
  34. this(numberOfCards, false);
  35. }
  36.  
  37. public void update() {
  38. if (this.duration == this.startDuration) {
  39. if (this.player.drawPile.isEmpty()) {
  40. this.isDone = true;
  41. return;
  42. }
  43. else if (this.player.drawPile.size() <= this.numberOfCards) {
  44. ArrayList<AbstractCard> cardsToMove = new ArrayList<>();
  45. for (AbstractCard c : this.player.drawPile.group) {
  46. cardsToMove.add(c);
  47. }
  48. for (AbstractCard c : cardsToMove) {
  49. this.player.drawPile.moveToHand(c, this.player.drawPile);
  50. }
  51. this.isDone = true;
  52. return;
  53. }
  54. else {
  55. CardGroup temp = new CardGroup(CardGroup.CardGroupType.UNSPECIFIED);
  56. for (AbstractCard c : this.player.drawPile.group) {
  57. temp.addToTop(c);
  58. }
  59. temp.sortAlphabetically(true);
  60. temp.sortByRarityPlusStatusCardType(false);
  61. if (this.numberOfCards == 1) {
  62. if (this.optional) {
  63. AbstractDungeon.gridSelectScreen.open(temp, this.numberOfCards, true, TEXT[0]);
  64. }
  65. else {
  66. AbstractDungeon.gridSelectScreen.open(temp, this.numberOfCards, TEXT[0], false);
  67. }
  68. }
  69. else {
  70. if (this.optional) {
  71. AbstractDungeon.gridSelectScreen.open(temp, this.numberOfCards, true, TEXT[1] + this.numberOfCards + TEXT[2]);
  72. }
  73. else {
  74. AbstractDungeon.gridSelectScreen.open(temp, this.numberOfCards, TEXT[1] + this.numberOfCards + TEXT[2], false);
  75. }
  76. }
  77. tickDuration();
  78. return;
  79. }
  80. }
  81. if (!AbstractDungeon.gridSelectScreen.selectedCards.isEmpty()) {
  82. for (AbstractCard c : AbstractDungeon.gridSelectScreen.selectedCards) {
  83. this.player.drawPile.moveToHand(c, this.player.drawPile);
  84. }
  85. AbstractDungeon.gridSelectScreen.selectedCards.clear();
  86. AbstractDungeon.player.hand.refreshHandLayout();
  87. }
  88. tickDuration();
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement