@Test public void greenStartHasFourStones() { Ludo game = new Ludo(); Square red = game.getStartSquare(Color.GREEN); assertEquals(4, Length.of(red.occupants())); for (Stone each : red.occupants()) { assertEquals(Color.GREEN, each.color); assertEquals(true, each.atStart()); } }
@Test public void redPlayerHasFourStonesAtStart() { Game game = new Ludo(); Player red = game.addPlayer(); assertEquals(4, Length.of(red.stones())); for (Stone each : red.stones()) { assertEquals(Color.RED, each.color); assertEquals(true, each.atStart()); } }
@Test public void greenPlayerHasFourStonesAtStart() { Game game = new Ludo(); game.addPlayer(); Player green = game.addPlayer(); assertEquals(4, Length.of(green.stones())); for (Stone each : green.stones()) { assertEquals(Color.GREEN, each.color); assertEquals(true, each.atStart()); } }
@Override public void stoneInteract(Stone stone) { int comesFrom = stone.getFromWhere(); int furtherTo = (comesFrom + 3) % 6; this.nbField = this.field.getNeighbour(furtherTo); if (this.nbField.getItem() == null) { this.dereg(); this.reg(); stone.push(); } }
public List<ChainOfStone> getChainsOfStones() { List<Stone> stones = getStonesByPoint(point); List<ChainOfStone> chainOfStones = new ArrayList<>(); ChainOfStone tmpChainOfStone; for (Stone s : stones) { tmpChainOfStone = s.getChainOfStone(); if (tmpChainOfStone != null) { chainOfStones.add(tmpChainOfStone); } } GameLogger.getInstance().logg("dlugosc listy "); return chainOfStones.stream().distinct().collect(Collectors.toCollection(ArrayList::new)); }
public boolean onDrag(View v, DragEvent event) { int dragEvent = event.getAction(); switch (dragEvent) { case DragEvent.ACTION_DRAG_STARTED: View draggedView = (View) event.getLocalState(); draggedView.setVisibility(View.INVISIBLE); break; case DragEvent.ACTION_DRAG_ENTERED: Log.i("Drag Event", "Entered"); break; case DragEvent.ACTION_DRAG_EXITED: Log.i("Drag Event", "Exited"); break; case DragEvent.ACTION_DROP: Log.i("Drag Event", "Dropped"); ImageView view = (ImageView) event.getLocalState(); ViewGroup owner = (ViewGroup) view.getParent(); FrameLayout container = (FrameLayout) v; if ((container.getChildCount() > 0)) { Log.d("V", "Already stone in spot"); view.setVisibility(view.VISIBLE); } else { owner.removeView(view); Stone thisstone = (Stone) view.getTag(); int id = thisstone.get_id(); int spot = container.getId(); dbHandler.update(id, spot); container.addView(view); view.setVisibility(View.VISIBLE); Log.d("V", "drop success"); } break; case DragEvent.ACTION_DRAG_ENDED: ImageView oldview = (ImageView) event.getLocalState(); oldview.setVisibility(oldview.VISIBLE); break; default: break; } return true; }