Advertisement
ITE_Man

Untitled

Dec 5th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package project;
  7.  
  8. import java.util.ArrayList;
  9. import javafx.util.Pair;
  10.  
  11. /**
  12. *
  13. * @author MoHaMaD
  14. */
  15. public class Square {
  16.  
  17. //private int i = 0;
  18. int x, y;
  19. private ArrayList<Pair<Champion, Player>> ChampionsInSquare = new ArrayList<>();
  20.  
  21. public Square(int x, int y) {
  22. this.x = x;
  23. this.y = y;
  24. }
  25.  
  26. ArrayList<Pair<Champion, Player>> GetChampionInSquare() {
  27. return ChampionsInSquare;
  28. }
  29.  
  30. int GetNumberChampionInSquare() {
  31.  
  32. return ChampionsInSquare.size();
  33. }
  34.  
  35. boolean IsEmpty() {
  36. return (ChampionsInSquare.isEmpty());
  37. }
  38.  
  39. void SetXandY(int x, int y) {
  40. this.x = x;
  41. this.y = y;
  42.  
  43. }
  44.  
  45. int GetX() {
  46. return x;
  47. }
  48.  
  49. int GetY() {
  50. return y;
  51. }
  52.  
  53. void AddChampionOnSquare(Champion Object) {
  54. for (Pair<Champion, Player> PP : ChampionsInSquare) {
  55. if (PP.getValue() == Move.staticCurrentPlayer) {
  56. Object.SetPosition(x + 1, y + 1);
  57. Arena.OneSquare[x + 1][y + 1].AddChampionOnSquare(Object);
  58. return;
  59. }
  60. }
  61. ChampionsInSquare.add(new Pair<>(Object, Move.staticCurrentPlayer));
  62. }
  63.  
  64. void RemoveChampionFromSquare(Champion Object) {
  65. for (int i = 0; i < ChampionsInSquare.size(); i++) {
  66. if (ChampionsInSquare.get(i).getKey() == Object) {
  67. ChampionsInSquare.remove(i);
  68. break;
  69. }
  70. }
  71. }
  72.  
  73. @Override
  74. public String toString() {
  75. return x + " - " + y;
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement