Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

162 linhas
4.1 KiB

  1. @(request: play.mvc.Http.Request, user: String)
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <title>ITSD Card Game Main Screen</title>
  6. <meta charset="utf-8">
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <link rel="stylesheet" href="@routes.Assets.at("css/uikit.css")" />
  9. <script src="@routes.Assets.at("js/jquery.3.4.1.js")"></script>
  10. <script src="@routes.Assets.at("js/uikit.js")"></script>
  11. <script src="@routes.Assets.at("js/uikit-icons.js")"></script>
  12. <script src="@routes.Assets.at("js/hexi.min.js")"></script>
  13. </head>
  14. <body id="mainBody" wsdata="@routes.GameScreenController.socket.webSocketURL(request)" onload="init()">
  15. <script src="@routes.Assets.at("js/cardgame.js")"></script>
  16. <script type="text/javascript">
  17. // // Load them google fonts before starting...!
  18. window.WebFontConfig = {
  19. google: {
  20. families: ['Roboto']
  21. },
  22. active: function() {
  23. // do something
  24. init();
  25. }
  26. };
  27. let stageWidth = 1920;
  28. let stageHeight = 1080;
  29. let moveVelocity = 2;
  30. var ws;
  31. var userDataSession;
  32. var g;
  33. var gameActorInitalized = false;
  34. var gameStart = false;
  35. var sinceLastHeartbeat = 0;
  36. // game objects
  37. let boardTiles = new Map()
  38. let spriteContainers = new Map()
  39. let sprites = new Map()
  40. let attackLabels = new Map()
  41. let healthLabels = new Map()
  42. let handContainers = [null,null,null,null,null,null]
  43. let handSprites = [null,null,null,null,null,null];
  44. let cardJSON = [null,null,null,null,null,null];
  45. let cardPreview = null;
  46. let prevewCountdown = 0;
  47. let activeMoves = new Map()
  48. let activeProjectiles = [];
  49. let drawUnitQueue = [];
  50. let drawTileQueue = [];
  51. let player1ManaIcons = new Map()
  52. let player2ManaIcons = new Map()
  53. let player1Health = null;
  54. let player2Health = null;
  55. let player1Notification = null;
  56. let player2Notification = null;
  57. let player1NotificationText = null;
  58. let player2NotificationText = null;
  59. let playingEffects = [];
  60. function init() {
  61. openWebSocketConnection();
  62. }
  63. function openWebSocketConnection() {
  64. var wsURL = document.getElementById("mainBody").getAttribute("wsdata");
  65. //alert(wsURL);
  66. ws = new WebSocket(wsURL);
  67. ws.onmessage = function (event) {
  68. var message;
  69. message = JSON.parse(event.data);
  70. console.log(message);
  71. switch (message.messagetype) {
  72. case "actorReady":
  73. initHexi(message.preloadImages);
  74. gameActorInitalized = true;
  75. break;
  76. case "drawTile":
  77. //console.log(message);
  78. drawTileQueue.push(message);
  79. break;
  80. case "drawUnit":
  81. drawUnitQueue.push(message);
  82. break;
  83. case "moveUnit":
  84. moveUnit(message.unitID,message.tilex,message.tiley);
  85. break;
  86. case "moveUnitToTile":
  87. moveUnitToTile(message);
  88. break;
  89. case "setUnitHealth":
  90. setUnitHealth(message);
  91. break;
  92. case "setUnitAttack":
  93. setUnitAttack(message);
  94. break;
  95. case "setPlayer1Health":
  96. setPlayer1Health(message);
  97. break;
  98. case "setPlayer2Health":
  99. setPlayer2Health(message);
  100. break;
  101. case "setPlayer1Mana":
  102. setPlayer1Mana(message);
  103. break;
  104. case "setPlayer2Mana":
  105. setPlayer2Mana(message);
  106. break;
  107. case "addPlayer1Notification":
  108. addPlayer1Notification(message);
  109. break;
  110. case "addPlayer2Notification":
  111. addPlayer2Notification(message);
  112. break;
  113. case "playUnitAnimation":
  114. playUnitAnimation(message);
  115. break;
  116. case "drawCard":
  117. drawCard(message);
  118. break;
  119. case "deleteCard":
  120. deleteCard(message);
  121. break;
  122. case "playEffectAnimation":
  123. playEffectAnimation(message);
  124. break;
  125. case "deleteUnit":
  126. deleteUnit(message);
  127. break;
  128. case "drawProjectile":
  129. drawProjectile(message);
  130. break;
  131. default:
  132. return console.log(message);
  133. }
  134. };
  135. }
  136. </script>
  137. </body>
  138. </html>