Player.ts 793 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. export class Player {
  2. private currentPos;
  3. private nbHash;
  4. private nbkey;
  5. public constructor() {
  6. this.nbHash = 0;
  7. this.nbkey = 0;
  8. this.currentPos = this.randomInt(1,16);
  9. }
  10. public randomInt (low, high) {
  11. return Math.floor(Math.random() * (high - low) + low);
  12. }
  13. public getCurrentPos() {
  14. return this.currentPos;
  15. }
  16. public setCurrentPos(pos) {
  17. this.currentPos = pos;
  18. }
  19. public addHash() {
  20. this.nbHash++;
  21. }
  22. public buyHash() {
  23. this.nbHash -= 2;
  24. }
  25. public buyKey() {
  26. this.nbkey -= 2;
  27. }
  28. public addKey() {
  29. this.nbkey++;
  30. }
  31. public getNbHash() {
  32. return this.nbHash;
  33. }
  34. public getNbKey() {
  35. return this.nbkey;
  36. }
  37. }