Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

243 rader
9.0 KiB

  1. package demo;
  2. import akka.actor.ActorRef;
  3. import commands.BasicCommands;
  4. import structures.basic.Card;
  5. import structures.basic.EffectAnimation;
  6. import structures.basic.Player;
  7. import structures.basic.Tile;
  8. import structures.basic.Unit;
  9. import structures.basic.UnitAnimationType;
  10. import utils.BasicObjectBuilders;
  11. import utils.OrderedCardLoader;
  12. import utils.StaticConfFiles;
  13. /**
  14. * This class contains an illustration of calling all of the commands provided
  15. * in the ITSD Card Game Template
  16. * @author Dr. Richard McCreadie
  17. *
  18. */
  19. public class CommandDemo {
  20. /**
  21. * This is a demo of the various commands that can be executed
  22. *
  23. * WARNING: This is a very long-running method, as it has a lot
  24. * thread sleeps in it. The back-end will not respond to commands
  25. * while this method is processing, e.g. if you refresh the game
  26. * page or try to kill the server you will get a long delay before
  27. * anything happens.
  28. */
  29. public static void executeDemo(ActorRef out) {
  30. BasicCommands.addPlayer1Notification(out, "Command Demo", 2);
  31. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();} // these cause processing to wait for a number of milliseconds.
  32. // addPlayer1Notification
  33. BasicCommands.addPlayer1Notification(out, "addPlayer1Notification", 2);
  34. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  35. //--------------------------------------------------------
  36. // Basic Draw Commands
  37. // -------------------------------------------------------
  38. // drawTile
  39. BasicCommands.addPlayer1Notification(out, "drawTile[3,2]", 2);
  40. Tile tile = BasicObjectBuilders.loadTile(3, 2);
  41. BasicCommands.drawTile(out, tile, 0);
  42. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  43. // drawUnit
  44. BasicCommands.addPlayer1Notification(out, "drawUnit", 2);
  45. Unit unit = BasicObjectBuilders.loadUnit(StaticConfFiles.humanAvatar, 0, Unit.class);
  46. unit.setPositionByTile(tile);
  47. BasicCommands.drawUnit(out, unit, tile);
  48. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  49. // setUnitAttack
  50. BasicCommands.addPlayer1Notification(out, "setUnitAttack", 2);
  51. BasicCommands.setUnitAttack(out, unit, 2);
  52. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  53. // setUnitHealth
  54. BasicCommands.addPlayer1Notification(out, "setUnitHealth", 2);
  55. BasicCommands.setUnitHealth(out, unit, 2);
  56. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  57. //--------------------------------------------------------
  58. // Playing Unit Animations
  59. // -------------------------------------------------------
  60. // playUnitAnimation [Move]
  61. BasicCommands.addPlayer1Notification(out, "playUnitAnimation [Move]", 2);
  62. BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.move);
  63. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  64. // playUnitAnimation [Attack]
  65. BasicCommands.addPlayer1Notification(out, "playUnitAnimation [Attack]", 2);
  66. BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.attack);
  67. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  68. // playUnitAnimation [Death]
  69. BasicCommands.addPlayer1Notification(out, "playUnitAnimation [Death]", 3);
  70. BasicCommands.playUnitAnimation(out, unit, UnitAnimationType.death);
  71. try {Thread.sleep(3000);} catch (InterruptedException e) {e.printStackTrace();}
  72. //--------------------------------------------------------
  73. // Deleting a Unit
  74. //-------------------------------------------------------
  75. // deleteUnit
  76. BasicCommands.addPlayer1Notification(out, "deleteUnit", 2);
  77. BasicCommands.deleteUnit(out, unit);
  78. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  79. //--------------------------------------------------------
  80. // Movement
  81. //-------------------------------------------------------
  82. // drawTile
  83. BasicCommands.addPlayer1Notification(out, "drawTile[3,2] Highlight", 2);
  84. BasicCommands.drawTile(out, tile, 1);
  85. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  86. // drawTile
  87. BasicCommands.addPlayer1Notification(out, "drawTile[3,2] Red Highlight", 2);
  88. BasicCommands.drawTile(out, tile, 2);
  89. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  90. // drawTile
  91. BasicCommands.addPlayer1Notification(out, "drawTile[3,2]", 2);
  92. BasicCommands.drawTile(out, tile, 0);
  93. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  94. // drawTile
  95. BasicCommands.addPlayer1Notification(out, "drawTile[4,2]", 2);
  96. Tile tile3 = BasicObjectBuilders.loadTile(4, 2);
  97. BasicCommands.drawTile(out, tile3, 0);
  98. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  99. // drawTile
  100. BasicCommands.addPlayer1Notification(out, "drawTile[5,2]", 2);
  101. Tile tile4 = BasicObjectBuilders.loadTile(5, 2);
  102. BasicCommands.drawTile(out, tile4, 0);
  103. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  104. // drawTile
  105. BasicCommands.addPlayer1Notification(out, "drawTile[5,3]", 2);
  106. Tile tile5 = BasicObjectBuilders.loadTile(5, 3);
  107. BasicCommands.drawTile(out, tile5, 0);
  108. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  109. BasicCommands.addPlayer1Notification(out, "drawUnit", 1);
  110. Unit unit2 = BasicObjectBuilders.loadUnit(StaticConfFiles.wraithling, 1, Unit.class);
  111. unit2.setPositionByTile(tile);
  112. BasicCommands.drawUnit(out, unit2, tile);
  113. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  114. BasicCommands.addPlayer1Notification(out, "moveUnitToTile", 3);
  115. BasicCommands.moveUnitToTile(out, unit2, tile5);
  116. try {Thread.sleep(4000);} catch (InterruptedException e) {e.printStackTrace();}
  117. BasicCommands.addPlayer1Notification(out, "moveUnitToTile (y-axis first)", 3);
  118. BasicCommands.moveUnitToTile(out, unit2, tile, true);
  119. try {Thread.sleep(4000);} catch (InterruptedException e) {e.printStackTrace();}
  120. BasicCommands.addPlayer1Notification(out, "deleteUnit", 2);
  121. BasicCommands.deleteUnit(out, unit2);
  122. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  123. //--------------------------------------------------------
  124. // Player Display Data
  125. //-------------------------------------------------------
  126. // Player Cards
  127. BasicCommands.addPlayer1Notification(out, "Player Test", 2);
  128. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  129. // setPlayer1Health
  130. BasicCommands.addPlayer1Notification(out, "setPlayer1Health", 2);
  131. Player humanPlayer = new Player(20, 0);
  132. BasicCommands.setPlayer1Health(out, humanPlayer);
  133. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  134. // setPlayer1Health
  135. BasicCommands.addPlayer1Notification(out, "setPlayer2Health", 2);
  136. Player aiPlayer = new Player(20, 0);
  137. BasicCommands.setPlayer2Health(out, aiPlayer);
  138. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  139. // Mana
  140. for (int m = 0; m<10; m++) {
  141. BasicCommands.addPlayer1Notification(out, "setPlayer1Mana ("+m+")", 1);
  142. humanPlayer.setMana(m);
  143. BasicCommands.setPlayer1Mana(out, humanPlayer);
  144. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  145. }
  146. // Mana
  147. for (int m = 0; m<10; m++) {
  148. BasicCommands.addPlayer1Notification(out, "setPlayer2Mana ("+m+")", 1);
  149. aiPlayer.setMana(m);
  150. BasicCommands.setPlayer2Mana(out, aiPlayer);
  151. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  152. }
  153. //--------------------------------------------------------
  154. // Rendering Cards
  155. //-------------------------------------------------------
  156. // Unhighlighted
  157. int handPosition = 1;
  158. for (Card card : OrderedCardLoader.getPlayer1Cards(1)) {
  159. BasicCommands.drawCard(out, card, handPosition, 0);
  160. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  161. handPosition++;
  162. if (handPosition>6) break;
  163. }
  164. // highlighted
  165. handPosition = 1;
  166. for (Card card : OrderedCardLoader.getPlayer1Cards(1)) {
  167. BasicCommands.drawCard(out, card, handPosition, 1);
  168. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  169. handPosition++;
  170. if (handPosition>6) break;
  171. }
  172. // delete card
  173. handPosition = 1;
  174. for (int i=1; i<7; i++) {
  175. BasicCommands.deleteCard(out, i);
  176. try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
  177. }
  178. //--------------------------------------------------------
  179. // Test New Stuff from the 2024 Template
  180. //-------------------------------------------------------
  181. BasicCommands.addPlayer1Notification(out, "2024 Loader Check", 2);
  182. try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
  183. Loaders_2024_Check.test(out); // moved 2024 tests in here
  184. }
  185. }