congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
ActionComponent.addAction
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: Cardshifter/Cardshifter

@Override
public Component copy(Entity copyTo) {
  ActionComponent copy = new ActionComponent();
  for (Entry<String, ECSAction> entry : actions.entrySet()) {
    copy.addAction(entry.getValue().copy(copyTo));
  }
  return copy;
}
origin: Cardshifter/Cardshifter

private void createCards(ZoneComponent hand) {
  for (int i = 0; i < 5; i++) {
    Entity entity = hand.getOwner().getGame().newEntity();
    ECSResourceMap.createFor(entity)
        .set(CyborgChroniclesGame.CyborgChroniclesResources.HEALTH, 3)
        .set(CyborgChroniclesGame.CyborgChroniclesResources.MAX_HEALTH, 3);
    ECSAttributeMap.createFor(entity).set(Attributes.NAME, "Test");
    ActionComponent action = new ActionComponent();
    entity.addComponent(action);
    action.addAction(moveAction("Field", entity, BattlefieldComponent.class, false));
    action.addAction(moveAction("Hand", entity, HandComponent.class, false));
    action.addAction(moveAction("Deck", entity, DeckComponent.class, false));
    action.addAction(moveAction("2-Field", entity, BattlefieldComponent.class, true));
    action.addAction(moveAction("2-Hand", entity, HandComponent.class, true));
    action.addAction(moveAction("2-Deck", entity, DeckComponent.class, true));
    action.addAction(damageAction(entity));
    hand.addOnBottom(entity);
  }
}
origin: Cardshifter/Cardshifter

private void giveReplayControls(Entity player) {
  ActionComponent actions = player.getComponent(ActionComponent.class);
  if (actions == null) {
    actions = new ActionComponent();
    player.addComponent(actions);
  }
  actions.addAction(new ECSAction(player, NEXT_STEP, e -> true, this::nextStep));
}

origin: Cardshifter/Cardshifter

@Override
public void startGame(ECSGame game) {
  ComponentRetriever<ActionComponent> actions = ComponentRetriever.retreiverFor(ActionComponent.class);
  game.getEvents().registerHandlerAfter(this, TargetableCheckEvent.class, this::targetAllowed);
  game.getEvents().registerHandlerAfter(this, ActionAllowedCheckEvent.class, this::actionAllowed);
  
  Set<Entity> players = game.getEntitiesWithComponent(PlayerComponent.class);
  remainingPerforms.set(players.size());
  for (Entity player : players) {
    ActionComponent playerActions = player.get(actions);
    if (playerActions == null) {
      playerActions = new ActionComponent();
      player.addComponent(playerActions);
    }
    playerActions.addAction(createMulliganAction(player));
  }
}
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

@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

@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());
}
origin: Cardshifter/Cardshifter

actions.addAction(endTurnAction);
com.cardshifter.modapi.actionsActionComponentaddAction

Popular methods of ActionComponent

  • <init>
  • getAction
  • getECSActions
  • getActions
  • removeAction

Popular in Java

  • Creating JSON documents from java classes using gson
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSupportFragmentManager (FragmentActivity)
  • runOnUiThread (Activity)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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