Tabnine Logo
ActionComponent.getAction
Code IndexAdd Tabnine to your IDE (free)

How to use
getAction
method
in
com.cardshifter.modapi.actions.ActionComponent

Best Java code snippets using com.cardshifter.modapi.actions.ActionComponent.getAction (Showing top 7 results out of 315)

origin: Cardshifter/Cardshifter

public static ECSAction getAction(Entity performer, String actionName) {
  ActionComponent actionComponent = actions.get(performer);
  if (actionComponent == null) {
    return null;
  }
  
  return actionComponent.getAction(actionName);
}

origin: Cardshifter/Cardshifter

@Test
public void testPerformAllowedAction() {
  game.startGame();
  ActionComponent actions = retriever.get(entity);
  assertEquals(Collections.<String>emptySet(), actions.getActions());
  @SuppressWarnings("unchecked")
  Consumer<ECSAction> perform = (Consumer<ECSAction>) mock(Consumer.class);
  String name = "Use";
  actions.addAction(new ECSAction(entity, name, action -> true, perform));
  actions.getAction(name).copy().perform(entity);
  verify(perform).accept(Mockito.any(ECSAction.class));
}
origin: Cardshifter/Cardshifter

protected ECSAction getAction(Entity entity, String actionName) {
  if (actions == null) {
    throw new AssertionError("actions is null");
  }
  ActionComponent available = Objects.requireNonNull(actions.get(entity), "Entity does not have any action component");
  return available.getAction(actionName);
}

origin: Cardshifter/Cardshifter

@Test
public void deniedActionWithSystem() {
  String name = "Use";
  game.addSystem(new SpecificActionSystem(name) {
    @Override
    protected void isAllowed(ActionAllowedCheckEvent event) {
      event.setAllowed(false);
    }
    @Override
    protected void onPerform(ActionPerformEvent event) {
    }
  });
  game.startGame();
  ActionComponent actions = retriever.get(entity);
  assertEquals(Collections.<String>emptySet(), actions.getActions());
  @SuppressWarnings("unchecked")
  Consumer<ECSAction> perform = (Consumer<ECSAction>) mock(Consumer.class);
  actions.addAction(new ECSAction(entity, name, action -> true, perform));
  actions.getAction(name).copy().perform(entity);
  verifyNoMoreInteractions(perform);
  assertFalse(actions.getAction(name).isAllowed(entity));
}
origin: Cardshifter/Cardshifter

private ECSAction actionFor(Entity player0) {
  return player0.getComponent(ActionComponent.class).getAction("Mulligan");
}
origin: Cardshifter/Cardshifter

private void performMulligan(Entity player, int[] cardsToChange) {
  HandComponent zone = player.get(hand);
  ECSAction action = player.getComponent(ActionComponent.class).getAction("Mulligan");
  assertNotNull("Action not found on " + player);
  TargetSet targets = action.getTargetSets().get(0);
  Stream<Entity> chosenTargets = Arrays.stream(cardsToChange).mapToObj(i -> zone.stream().filter(e -> standardRetr.getFor(e) == i).findAny().get());
  chosenTargets.forEach(e -> targets.addTarget(e));
  assertTrue("Mulligan was not performed", action.perform(player));
}
origin: Cardshifter/Cardshifter

@Test
public void removeSystemTest() {
  ECSGame game = new ECSGame();
  ActionComponent act = new ActionComponent();
  Entity entity = game.newEntity().addComponent(act);
  act.addAction(new ECSAction(entity, "Test", e -> true, e -> {}));
  system = new SpecificActionSystem("Test") {
    @Override
    protected void onPerform(ActionPerformEvent event) {
      value.getAndIncrement();
      event.getEntity().getGame().removeSystem(system);
    }
  };
  game.addSystem(system);
  
  game.startGame();
  
  assertEquals(0, value.get());
  act.getAction("Test").perform(entity);
  assertEquals(1, value.get());
  act.getAction("Test").perform(entity);
  assertEquals(1, value.get());
  
  game.addSystem(system);
  act.getAction("Test").perform(entity);
  assertEquals(2, value.get());
}
com.cardshifter.modapi.actionsActionComponentgetAction

Popular methods of ActionComponent

  • <init>
  • addAction
  • getECSActions
  • getActions
  • removeAction

Popular in Java

  • Making http requests using okhttp
  • requestLocationUpdates (LocationManager)
  • getSystemService (Context)
  • setRequestProperty (URLConnection)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Collectors (java.util.stream)
  • ImageIO (javax.imageio)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now