mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Merged Hellfish HandSize code.
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -338,6 +338,7 @@ src/forge/Gui_Shops.java -text svneol=native#text/plain
|
||||
src/forge/Gui_Treasury.java -text svneol=native#text/plain
|
||||
src/forge/Gui_Welcome.java svneol=native#text/plain
|
||||
src/forge/Gui_WinLose.java svneol=native#text/plain
|
||||
src/forge/HandSizeOp.java -text svneol=native#text/plain
|
||||
src/forge/IO.java svneol=native#text/plain
|
||||
src/forge/ImageCache.java svneol=native#text/plain
|
||||
src/forge/ImagePreviewPanel.java -text svneol=native#text/plain
|
||||
|
||||
@@ -1,3 +1,75 @@
|
||||
Cursed Rack
|
||||
4
|
||||
Artifact
|
||||
As Cursed Rack enters the battlefield, choose an opponent. The chosen player's maximum hand size is four.
|
||||
HandSize = 4 Opponent
|
||||
|
||||
Gnat Miser
|
||||
B
|
||||
Creature Rat Shaman
|
||||
Each opponent's hand size is reduced by one.
|
||||
1/1
|
||||
HandSize - 1 Opponent
|
||||
|
||||
Graceful Adept
|
||||
2 U
|
||||
Creature Human Wizard
|
||||
You have no maximum hand size.
|
||||
1/3
|
||||
HandSize = INF Self
|
||||
|
||||
Locust Miser
|
||||
2 B B
|
||||
Creature Rat Shaman
|
||||
Each opponent's maximum hand size is reduced by two.
|
||||
2/2
|
||||
HandSize - 2 Opponent
|
||||
|
||||
Minamo Scrollkeeper
|
||||
1 U
|
||||
Creature Human Wizard
|
||||
Your maximum hand size is increased by one.
|
||||
2/3
|
||||
HandSize + 1 Self
|
||||
Defender
|
||||
|
||||
Reliquary Tower
|
||||
no cost
|
||||
Land
|
||||
You have no maximum hand size.
|
||||
HandSize = INF Self
|
||||
tap: add 1
|
||||
|
||||
Spellbook
|
||||
0
|
||||
Artifact
|
||||
You have no maximum hand size.
|
||||
HandSize = INF Self
|
||||
|
||||
Thought Devourer
|
||||
2 U U
|
||||
Creature Beast
|
||||
Your maximum hand size is reduced by four.
|
||||
4/4
|
||||
HandSize - 4 Self
|
||||
Flying
|
||||
|
||||
Thought Eater
|
||||
1 U
|
||||
Creature Beast
|
||||
Your maximum hand size is reduced by three.
|
||||
2/2
|
||||
HandSize - 3 Self
|
||||
Flying
|
||||
|
||||
Thought Nibbler
|
||||
U
|
||||
Creature Beast
|
||||
Your maximum hand size is reduced by two.
|
||||
1/1
|
||||
HandSize - 2 Self
|
||||
Flying
|
||||
|
||||
Sangrophage
|
||||
B B
|
||||
Creature Zombie
|
||||
|
||||
@@ -22773,6 +22773,115 @@ public class CardFactory implements NewConstants {
|
||||
}
|
||||
}//echo
|
||||
|
||||
if(hasKeyword(card,"HandSize") != -1) {
|
||||
String toParse = card.getKeyword().get(hasKeyword(card,"HandSize"));
|
||||
card.removeIntrinsicKeyword(toParse);
|
||||
|
||||
String parts[] = toParse.split(" ");
|
||||
final String Mode = parts[1];
|
||||
final int Amount;
|
||||
if(parts[2].equals("INF")) {
|
||||
Amount = -1;
|
||||
}
|
||||
else {
|
||||
Amount = Integer.parseInt(parts[2]);
|
||||
}
|
||||
final String Target = parts[3];
|
||||
|
||||
final Command entersPlay,leavesPlay, controllerChanges;
|
||||
|
||||
entersPlay = new Command() {
|
||||
private static final long serialVersionUID = 98743547743456L;
|
||||
|
||||
public void execute() {
|
||||
card.setSVar("HSStamp","" + Input_Cleanup.GetHandSizeStamp());
|
||||
if(card.getController() == Constant.Player.Human) {
|
||||
//System.out.println("Human played me! Mode(" + Mode + ") Amount(" + Amount + ") Target(" + Target + ")" );
|
||||
if(Target.equals("Self")) {
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//System.out.println("Compy played me! Mode(" + Mode + ") Amount(" + Amount + ") Target(" + Target + ")" );
|
||||
if(Target.equals("Self")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
leavesPlay = new Command() {
|
||||
private static final long serialVersionUID = -6843545358873L;
|
||||
|
||||
public void execute() {
|
||||
if(card.getController() == Constant.Player.Human) {
|
||||
if(Target.equals("Self")) {
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Target.equals("Self")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
controllerChanges = new Command() {
|
||||
private static final long serialVersionUID = 778987998465463L;
|
||||
|
||||
public void execute() {
|
||||
System.out.println("Control changed: " + card.getController());
|
||||
if(card.getController().equals(Constant.Player.Human)) {
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
|
||||
Computer_Cleanup.sortHandSizeOperations();
|
||||
}
|
||||
else if(card.getController().equals(Constant.Player.Computer)) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
|
||||
Input_Cleanup.sortHandSizeOperations();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
card.addComesIntoPlayCommand(entersPlay);
|
||||
card.addLeavesPlayCommand(leavesPlay);
|
||||
card.addChangeControllerCommand(controllerChanges);
|
||||
} //HandSize
|
||||
|
||||
if (card.getManaCost().contains("X"))
|
||||
{
|
||||
SpellAbility sa = card.getSpellAbility()[0];
|
||||
|
||||
@@ -19783,6 +19783,115 @@ public class CardFactory_Creatures {
|
||||
}
|
||||
}//echo
|
||||
|
||||
if(hasKeyword(card,"HandSize") != -1) {
|
||||
String toParse = card.getKeyword().get(hasKeyword(card,"HandSize"));
|
||||
card.removeIntrinsicKeyword(toParse);
|
||||
|
||||
String parts[] = toParse.split(" ");
|
||||
final String Mode = parts[1];
|
||||
final int Amount;
|
||||
if(parts[2].equals("INF")) {
|
||||
Amount = -1;
|
||||
}
|
||||
else {
|
||||
Amount = Integer.parseInt(parts[2]);
|
||||
}
|
||||
final String Target = parts[3];
|
||||
|
||||
final Command entersPlay,leavesPlay, controllerChanges;
|
||||
|
||||
entersPlay = new Command() {
|
||||
private static final long serialVersionUID = 98743547743456L;
|
||||
|
||||
public void execute() {
|
||||
card.setSVar("HSStamp","" + Input_Cleanup.GetHandSizeStamp());
|
||||
if(card.getController() == Constant.Player.Human) {
|
||||
//System.out.println("Human played me! Mode(" + Mode + ") Amount(" + Amount + ") Target(" + Target + ")" );
|
||||
if(Target.equals("Self")) {
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//System.out.println("Compy played me! Mode(" + Mode + ") Amount(" + Amount + ") Target(" + Target + ")" );
|
||||
if(Target.equals("Self")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
leavesPlay = new Command() {
|
||||
private static final long serialVersionUID = -6843545358873L;
|
||||
|
||||
public void execute() {
|
||||
if(card.getController() == Constant.Player.Human) {
|
||||
if(Target.equals("Self")) {
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Target.equals("Self")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
controllerChanges = new Command() {
|
||||
private static final long serialVersionUID = 778987998465463L;
|
||||
|
||||
public void execute() {
|
||||
System.out.println("Control changed: " + card.getController());
|
||||
if(card.getController().equals(Constant.Player.Human)) {
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
|
||||
Computer_Cleanup.sortHandSizeOperations();
|
||||
}
|
||||
else if(card.getController().equals(Constant.Player.Computer)) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
|
||||
Input_Cleanup.sortHandSizeOperations();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
card.addComesIntoPlayCommand(entersPlay);
|
||||
card.addLeavesPlayCommand(leavesPlay);
|
||||
card.addChangeControllerCommand(controllerChanges);
|
||||
} //HandSize
|
||||
|
||||
if(hasKeyword(card, "Level up") != -1 && hasKeyword(card, "maxLevel") != -1)
|
||||
{
|
||||
int n = hasKeyword(card, "Level up");
|
||||
|
||||
@@ -3308,6 +3308,115 @@ class CardFactory_Lands {
|
||||
}
|
||||
}//transmute
|
||||
|
||||
if(hasKeyword(card,"HandSize") != -1) {
|
||||
String toParse = card.getKeyword().get(hasKeyword(card,"HandSize"));
|
||||
card.removeIntrinsicKeyword(toParse);
|
||||
|
||||
String parts[] = toParse.split(" ");
|
||||
final String Mode = parts[1];
|
||||
final int Amount;
|
||||
if(parts[2].equals("INF")) {
|
||||
Amount = -1;
|
||||
}
|
||||
else {
|
||||
Amount = Integer.parseInt(parts[2]);
|
||||
}
|
||||
final String Target = parts[3];
|
||||
|
||||
final Command entersPlay,leavesPlay, controllerChanges;
|
||||
|
||||
entersPlay = new Command() {
|
||||
private static final long serialVersionUID = 98743547743456L;
|
||||
|
||||
public void execute() {
|
||||
card.setSVar("HSStamp","" + Input_Cleanup.GetHandSizeStamp());
|
||||
if(card.getController() == Constant.Player.Human) {
|
||||
//System.out.println("Human played me! Mode(" + Mode + ") Amount(" + Amount + ") Target(" + Target + ")" );
|
||||
if(Target.equals("Self")) {
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//System.out.println("Compy played me! Mode(" + Mode + ") Amount(" + Amount + ") Target(" + Target + ")" );
|
||||
if(Target.equals("Self")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
leavesPlay = new Command() {
|
||||
private static final long serialVersionUID = -6843545358873L;
|
||||
|
||||
public void execute() {
|
||||
if(card.getController() == Constant.Player.Human) {
|
||||
if(Target.equals("Self")) {
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Target.equals("Self")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("Opponent")) {
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
else if(Target.equals("All")) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
controllerChanges = new Command() {
|
||||
private static final long serialVersionUID = 778987998465463L;
|
||||
|
||||
public void execute() {
|
||||
System.out.println("Control changed: " + card.getController());
|
||||
if(card.getController().equals(Constant.Player.Human)) {
|
||||
Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
|
||||
Computer_Cleanup.sortHandSizeOperations();
|
||||
}
|
||||
else if(card.getController().equals(Constant.Player.Computer)) {
|
||||
Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp")));
|
||||
Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
|
||||
Input_Cleanup.sortHandSizeOperations();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
card.addComesIntoPlayCommand(entersPlay);
|
||||
card.addLeavesPlayCommand(leavesPlay);
|
||||
card.addChangeControllerCommand(controllerChanges);
|
||||
} //HandSize
|
||||
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,80 @@
|
||||
package forge;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class Computer_Cleanup extends Input {
|
||||
|
||||
private static LinkedList<HandSizeOp> handSizeOperations = new LinkedList<HandSizeOp>();
|
||||
private static int MaxHandSize = 7;
|
||||
|
||||
public static void sortHandSizeOperations() {
|
||||
if(handSizeOperations.size() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object arr[] = handSizeOperations.toArray();
|
||||
int changes = 1;
|
||||
|
||||
while(changes > 0) {
|
||||
changes = 0;
|
||||
for(int i=1;i<arr.length;i++) {
|
||||
if(((HandSizeOp)arr[i]).hsTimeStamp < ((HandSizeOp)arr[i-1]).hsTimeStamp) {
|
||||
HandSizeOp tmp = (HandSizeOp)arr[i];
|
||||
arr[i] = arr[i-1];
|
||||
arr[i-1] = tmp;
|
||||
changes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
handSizeOperations.clear();
|
||||
for(int i=0;i<arr.length;i++) {
|
||||
handSizeOperations.add((HandSizeOp)arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void calcMaxHandSize() {
|
||||
|
||||
int ret = 7;
|
||||
for(int i=0;i<handSizeOperations.size();i++)
|
||||
{
|
||||
if(handSizeOperations.get(i).Mode.equals("="))
|
||||
{
|
||||
ret = handSizeOperations.get(i).Amount;
|
||||
}
|
||||
else if(handSizeOperations.get(i).Mode.equals("+") && ret >= 0)
|
||||
{
|
||||
ret = ret + handSizeOperations.get(i).Amount;
|
||||
}
|
||||
else if(handSizeOperations.get(i).Mode.equals("-") && ret >= 0)
|
||||
{
|
||||
ret = ret - handSizeOperations.get(i).Amount;
|
||||
if(ret < 0) {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
MaxHandSize = ret;
|
||||
}
|
||||
public static void addHandSizeOperation(HandSizeOp theNew)
|
||||
{
|
||||
handSizeOperations.add(theNew);
|
||||
}
|
||||
public static void removeHandSizeOperation(int timestamp)
|
||||
{
|
||||
for(int i=0;i<handSizeOperations.size();i++)
|
||||
{
|
||||
if(handSizeOperations.get(i).hsTimeStamp == timestamp)
|
||||
{
|
||||
handSizeOperations.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final long serialVersionUID = -145924458598185438L;
|
||||
|
||||
@Override
|
||||
|
||||
19
src/forge/HandSizeOp.java
Normal file
19
src/forge/HandSizeOp.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package forge;
|
||||
|
||||
public class HandSizeOp {
|
||||
public String Mode;
|
||||
public int hsTimeStamp;
|
||||
public int Amount;
|
||||
|
||||
public HandSizeOp(String M,int A,int TS)
|
||||
{
|
||||
Mode = M;
|
||||
Amount = A;
|
||||
hsTimeStamp = TS;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Mode(" + Mode + ") Amount(" + Amount + ") Timestamp(" + hsTimeStamp + ")";
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,85 @@
|
||||
|
||||
package forge;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
|
||||
public class Input_Cleanup extends Input {
|
||||
private static final long serialVersionUID = -4164275418971547948L;
|
||||
|
||||
private static int NextHandSizeStamp = 0;
|
||||
|
||||
public static int GetHandSizeStamp() {
|
||||
return NextHandSizeStamp++;
|
||||
}
|
||||
|
||||
private static LinkedList<HandSizeOp> handSizeOperations = new LinkedList<HandSizeOp>();
|
||||
private static int MaxHandSize = 7;
|
||||
|
||||
public static void sortHandSizeOperations() {
|
||||
if(handSizeOperations.size() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object arr[] = handSizeOperations.toArray();
|
||||
int changes = 1;
|
||||
|
||||
while(changes > 0) {
|
||||
changes = 0;
|
||||
for(int i=1;i<arr.length;i++) {
|
||||
if(((HandSizeOp)arr[i]).hsTimeStamp < ((HandSizeOp)arr[i-1]).hsTimeStamp) {
|
||||
HandSizeOp tmp = (HandSizeOp)arr[i];
|
||||
arr[i] = arr[i-1];
|
||||
arr[i-1] = tmp;
|
||||
changes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
handSizeOperations.clear();
|
||||
for(int i=0;i<arr.length;i++) {
|
||||
handSizeOperations.add((HandSizeOp)arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void calcMaxHandSize() {
|
||||
|
||||
int ret = 7;
|
||||
for(int i=0;i<handSizeOperations.size();i++)
|
||||
{
|
||||
if(handSizeOperations.get(i).Mode.equals("="))
|
||||
{
|
||||
ret = handSizeOperations.get(i).Amount;
|
||||
}
|
||||
else if(handSizeOperations.get(i).Mode.equals("+") && ret >= 0)
|
||||
{
|
||||
ret = ret + handSizeOperations.get(i).Amount;
|
||||
}
|
||||
else if(handSizeOperations.get(i).Mode.equals("-") && ret >= 0)
|
||||
{
|
||||
ret = ret - handSizeOperations.get(i).Amount;
|
||||
if(ret < 0) {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
MaxHandSize = ret;
|
||||
}
|
||||
public static void addHandSizeOperation(HandSizeOp theNew)
|
||||
{
|
||||
handSizeOperations.add(theNew);
|
||||
}
|
||||
public static void removeHandSizeOperation(int timestamp)
|
||||
{
|
||||
for(int i=0;i<handSizeOperations.size();i++)
|
||||
{
|
||||
if(handSizeOperations.get(i).hsTimeStamp == timestamp)
|
||||
{
|
||||
handSizeOperations.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage() {
|
||||
ButtonUtil.disableAll();
|
||||
|
||||
@@ -104,6 +104,9 @@ public class Phase extends MyObservable
|
||||
|
||||
GameActionUtil.executeCardStateEffects();
|
||||
|
||||
Input_Cleanup.calcMaxHandSize();
|
||||
Computer_Cleanup.calcMaxHandSize();
|
||||
|
||||
//for debugging: System.out.print("this phase - " +getActivePlayer() +" " +getPhase()+", next phase - ");
|
||||
needToNextPhase = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user