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.

75 lines
2.6 KiB

  1. export default class Style{
  2. constructor(gameInstanz) {
  3. this._game = gameInstanz;
  4. $('#drawCard').on('click', ()=>{
  5. this.game.currentPlayerInstanz.drawCard(1);
  6. this.refreshDebug();
  7. });
  8. let firstDraw = $('#first-draw');
  9. firstDraw.on('mouseenter', ()=>{
  10. firstDraw.css('transition', 'min-width 0.3s, top 0.5s');
  11. firstDraw.css('min-width', '27vh');
  12. firstDraw.css('top', '50vh');
  13. });
  14. firstDraw.on('mouseleave', ()=>{
  15. firstDraw.css('transition', 'min-width 1s, top 0.5s');
  16. firstDraw.css('top', '47vh');
  17. firstDraw.css('min-width', '20vh');
  18. });
  19. firstDraw.on('click', ()=>{
  20. this.game.currentPlayerInstanz.drawCard(1);
  21. this.refreshDebug();
  22. this.refreshHtml();
  23. firstDraw.css('transition', 'min-width 1s, top 0.5s');
  24. firstDraw.css('top', '47vh');
  25. firstDraw.css('min-width', '20vh');
  26. });
  27. }
  28. refreshHtml(){
  29. $('#first-put').attr('src', './img/stackCards/' + this.game.cardOnDeck.color + '/' + this.game.cardOnDeck.name + '.png');
  30. }
  31. refreshDebug(){
  32. $('#drawCard').css('background-color', 'white');
  33. $("#player").html("Spieler: " + this.game.currentPlayerInstanz.name);
  34. $("#playerCards").html("Karten: ");
  35. for (let i = 0; i < this.game.currentPlayerInstanz.hand.length; i++){
  36. $('#playerCards').append(this.game.currentPlayerInstanz.hand[i].name + " - " + this.game.currentPlayerInstanz.hand[i].color);
  37. $('#playerCards').append('<button id="button' + i + '">+</button> | ');
  38. $('#button' + i).on('click', () =>{
  39. this.game.currentPlayerInstanz.putCard(i);
  40. this.refreshDebug();
  41. this.refreshHtml();
  42. });
  43. if (this.game.currentPlayerInstanz.hand[i].canPut)
  44. $('#button' + i).css('background-color', 'green');
  45. }
  46. $('#playerCards').append("" + this.game.currentPlayerInstanz.hand.length)
  47. $("#cardOnDeck").html("Karte auf dem Tisch: " + this.game.cardOnDeck.name + " - " + this.game.cardOnDeck.color);
  48. $("#playerInGame").html("Spieler im Spiel: " + this.game.players.length);
  49. if(!this.game.currentPlayerInstanz.canPlay)
  50. $('#drawCard').css('background-color', 'red');
  51. }
  52. showDebug(){
  53. $('#debug').show();
  54. this.refreshDebug();
  55. }
  56. hideDebug(){
  57. $('#debug').hide();
  58. }
  59. get game(){
  60. return this._game;
  61. }
  62. }