-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a delay between automatic turn actions
- Loading branch information
Showing
10 changed files
with
153 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/io/github/haykam821/lastcard/turn/action/DrawTurnAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.github.haykam821.lastcard.turn.action; | ||
|
||
import io.github.haykam821.lastcard.game.phase.LastCardActivePhase; | ||
import io.github.haykam821.lastcard.game.player.AbstractPlayerEntry; | ||
import net.minecraft.text.Text; | ||
|
||
public class DrawTurnAction implements TurnAction { | ||
private final int value; | ||
|
||
public DrawTurnAction(int value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public void run(AbstractPlayerEntry player) { | ||
LastCardActivePhase phase = player.getPhase(); | ||
|
||
for (int index = 0; index < this.value; index++) { | ||
player.draw(); | ||
} | ||
|
||
this.sendDrawMessage(phase, player); | ||
phase.getTurnManager().cycleTurn(); | ||
} | ||
|
||
private void sendDrawMessage(LastCardActivePhase phase, AbstractPlayerEntry player) { | ||
Text cardDrewMessage = player.getCardDrewMessage(this.value); | ||
Text cardDrewManyYouMessage = player.getCardDrewManyYouMessage(this.value); | ||
|
||
phase.sendMessageWithException(cardDrewMessage, player, cardDrewManyYouMessage); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/io/github/haykam821/lastcard/turn/action/SkipTurnAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.github.haykam821.lastcard.turn.action; | ||
|
||
import io.github.haykam821.lastcard.game.phase.LastCardActivePhase; | ||
import io.github.haykam821.lastcard.game.player.AbstractPlayerEntry; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Formatting; | ||
|
||
public class SkipTurnAction implements TurnAction { | ||
public static final TurnAction INSTANCE = new SkipTurnAction(); | ||
|
||
private SkipTurnAction() { | ||
return; | ||
} | ||
|
||
@Override | ||
public void run(AbstractPlayerEntry player) { | ||
LastCardActivePhase phase = player.getPhase(); | ||
|
||
phase.sendMessageWithException(this.getTurnSkippedMessage(player), player, this.getTurnSkippedYouMessage()); | ||
phase.getTurnManager().cycleTurn(); | ||
} | ||
|
||
private Text getTurnSkippedMessage(AbstractPlayerEntry player) { | ||
return Text.translatable("text.lastcard.turn.skipped", player.getName()).formatted(Formatting.GOLD); | ||
} | ||
|
||
private Text getTurnSkippedYouMessage() { | ||
return Text.translatable("text.lastcard.turn.skipped.you").formatted(Formatting.GOLD); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/io/github/haykam821/lastcard/turn/action/TurnAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.github.haykam821.lastcard.turn.action; | ||
|
||
import io.github.haykam821.lastcard.game.player.AbstractPlayerEntry; | ||
|
||
public interface TurnAction { | ||
public void run(AbstractPlayerEntry player); | ||
|
||
public default boolean hasNextTurnEffects() { | ||
return false; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/io/github/haykam821/lastcard/turn/action/VirtualTurnAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.github.haykam821.lastcard.turn.action; | ||
|
||
import io.github.haykam821.lastcard.card.Card; | ||
import io.github.haykam821.lastcard.card.color.ColorSelector; | ||
import io.github.haykam821.lastcard.game.player.AbstractPlayerEntry; | ||
|
||
public class VirtualTurnAction implements TurnAction { | ||
public static final TurnAction INSTANCE = new VirtualTurnAction(); | ||
|
||
private VirtualTurnAction() { | ||
return; | ||
} | ||
|
||
@Override | ||
public void run(AbstractPlayerEntry player) { | ||
// Play the first playable card | ||
for (Card card : player.getCards()) { | ||
if (card.canPlay(player)) { | ||
ColorSelector selector = card.getSelector(); | ||
player.playCard(card, selector.select(0, 0)); | ||
|
||
return; | ||
} | ||
} | ||
|
||
// If no cards are playable, draw | ||
player.drawForTurn(); | ||
} | ||
|
||
@Override | ||
public boolean hasNextTurnEffects() { | ||
return true; | ||
} | ||
} |