private void onDrawCard(DrawCardEvent event) {
    if (event.isCancelled()) return;

    ZomisLog.info("DamageIncreasingWhenOutOfCardsSystem - DrawCard Event triggered");
    if (event
        .getPlayer()
        .compatibility(DeckComponent.class)
        .and(DeckSourceComponent.class)
        .failsThenWarn()) {
      return;
    }

    DeckComponent comp = event.getPlayer().getComponent(DeckComponent.class);
    if (!comp.getDeck().isEmpty()) {
      return;
    }

    CompPlayer player = (CompPlayer) event.getPlayer();
    player.getResources().changeResources(ConsecutiveDamage.DAMAGE_TAKEN, 1);
    int value = player.getResources().get(ConsecutiveDamage.DAMAGE_TAKEN);
    ZomisLog.info("Out of cards: " + player + ", taking damage: " + value);

    player.getRequiredComponent(HealthComponent.class).damage(value);
    event.setCancelled(true);
  }
Esempio n. 2
0
 @Override
 public void onStart(FirstCompGame game) {
   ZomisLog.info(this.toString());
   for (CompPlayer pl : game.getPlayers()) {
     if (pl.compatibility(DeckSourceComponent.class).failsThenWarn()) return;
     ZomisLog.info("Creating deck for " + pl);
     DeckList deck = new DeckList("Deck").add(52, "Random Card");
     DeckBuilder.createExact(pl.getComponent(DeckSourceComponent.class), deck.getCount(game));
   }
 }