You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Loaders_2024_Check.java 6.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package demo;
  2. import java.io.File;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import akka.actor.ActorRef;
  6. import commands.BasicCommands;
  7. import structures.basic.Card;
  8. import structures.basic.EffectAnimation;
  9. import structures.basic.Tile;
  10. import structures.basic.Unit;
  11. import structures.basic.UnitAnimationType;
  12. import utils.BasicObjectBuilders;
  13. import utils.OrderedCardLoader;
  14. import utils.StaticConfFiles;
  15. public class Loaders_2024_Check {
  16. /**
  17. * This is a test of the loading and rendering for the 2024 unit
  18. * set. It exists as a convenient way for Richard to check that he
  19. * has not broken anything when he updated the template to add the
  20. * new 2024 decks.
  21. */
  22. public static void test(ActorRef out) {
  23. // drawTile
  24. Tile tile = BasicObjectBuilders.loadTile(3, 2);
  25. BasicCommands.drawTile(out, tile, 0);
  26. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();} // these cause processing to wait for a number of milliseconds.
  27. //--------------------------------------------------------
  28. // Test Cards and their Units
  29. // -------------------------------------------------------
  30. BasicCommands.addPlayer1Notification(out, "Test Cards / Units", 2);
  31. List<Card> cards = new ArrayList<Card>();
  32. cards.addAll(OrderedCardLoader.getPlayer1Cards(1));
  33. cards.addAll(OrderedCardLoader.getPlayer2Cards(1));
  34. // Run test for all cards
  35. for (Card card : cards) {
  36. BasicCommands.addPlayer1Notification(out, card.getCardname(), 2);
  37. // drawCard [1]
  38. BasicCommands.drawCard(out, card, 1, 0);
  39. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  40. // drawCard [1] Highlight
  41. BasicCommands.drawCard(out, card, 1, 1);
  42. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  43. int unitID = 0;
  44. if (card.isCreature()) {
  45. Unit unit = BasicObjectBuilders.loadUnit(card.getUnitConfig(), unitID, Unit.class);
  46. unit.setPositionByTile(tile);
  47. BasicCommands.drawUnit(out, unit, tile);
  48. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  49. // playUnitAnimation [Move] and wait for a period until the animation does one cycle
  50. try {Thread.sleep(BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.move));} catch (InterruptedException e) {e.printStackTrace();}
  51. // playUnitAnimation [Attack] and wait for a period until the animation does one cycle
  52. try {Thread.sleep(BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.attack));} catch (InterruptedException e) {e.printStackTrace();}
  53. // playUnitAnimation [Attack] and wait for a period until the animation does one cycle
  54. try {Thread.sleep(BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.hit));} catch (InterruptedException e) {e.printStackTrace();}
  55. // playUnitAnimation [Attack] and wait for a period until the animation does one cycle
  56. try {Thread.sleep(BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.channel));} catch (InterruptedException e) {e.printStackTrace();}
  57. // playUnitAnimation [Death] and wait for a period until the animation does one cycle
  58. try {Thread.sleep(BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.death));} catch (InterruptedException e) {e.printStackTrace();}
  59. // deleteUnit
  60. BasicCommands.deleteUnit(out, unit);
  61. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  62. unitID++;
  63. }
  64. BasicCommands.deleteCard(out, 1);
  65. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  66. }
  67. //--------------------------------------------------------
  68. // Test Avatars and Tokens
  69. // -------------------------------------------------------
  70. BasicCommands.addPlayer1Notification(out, "Test Avatars and Tokens", 1);
  71. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  72. // As avatars and tokens do not have cards, we need to directly load the unit
  73. // StaticConfFiles tells us where the associated conf file is
  74. List<String> avatarsAndTokens = new ArrayList<String>();
  75. avatarsAndTokens.add(StaticConfFiles.humanAvatar);
  76. avatarsAndTokens.add(StaticConfFiles.aiAvatar);
  77. avatarsAndTokens.add(StaticConfFiles.wraithling);
  78. for (String unitConf : avatarsAndTokens) {
  79. Unit unit = BasicObjectBuilders.loadUnit(unitConf, 1, Unit.class);
  80. unit.setPositionByTile(tile);
  81. BasicCommands.drawUnit(out, unit, tile);
  82. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  83. // playUnitAnimation [Move] and wait for a period until the animation does one cycle
  84. try {Thread.sleep(BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.move));} catch (InterruptedException e) {e.printStackTrace();}
  85. // playUnitAnimation [Attack] and wait for a period until the animation does one cycle
  86. try {Thread.sleep(BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.attack));} catch (InterruptedException e) {e.printStackTrace();}
  87. // playUnitAnimation [Attack] and wait for a period until the animation does one cycle
  88. try {Thread.sleep(BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.hit));} catch (InterruptedException e) {e.printStackTrace();}
  89. // playUnitAnimation [Attack] and wait for a period until the animation does one cycle
  90. try {Thread.sleep(BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.channel));} catch (InterruptedException e) {e.printStackTrace();}
  91. // playUnitAnimation [Death] and wait for a period until the animation does one cycle
  92. try {Thread.sleep(BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.death));} catch (InterruptedException e) {e.printStackTrace();}
  93. // deleteUnit
  94. BasicCommands.deleteUnit(out, unit);
  95. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  96. }
  97. //--------------------------------------------------------
  98. // Test Effects
  99. // -------------------------------------------------------
  100. BasicCommands.addPlayer1Notification(out, "Test Effects", 1);
  101. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  102. // Now check all of the loaded effects
  103. String effectsDIR = "conf/gameconfs/effects/";
  104. for (String filename : new File(effectsDIR).list()) {
  105. EffectAnimation effect = BasicObjectBuilders.loadEffect(effectsDIR+filename);
  106. try {Thread.sleep(BasicCommands.playEffectAnimation(out, effect, tile));} catch (InterruptedException e) {e.printStackTrace();}
  107. }
  108. }
  109. }