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); }
@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)); } }
private void determineAction(DetermineActionEvent event) { CompPlayer owner = event.getSource().getOwner(); if (event.hasAction()) { return; } if (owner == null || !owner.hasComponent(BattlefieldComponent.class)) { return; } CardZone<?> zone = event.getSource().getCurrentZone(); HasComponents currentPlayer = event.getSource().getGame().getCurrentPlayer(); if (currentPlayer == null) return; if (zone == currentPlayer.getComponent(BattlefieldComponent.class).getBattlefield()) { event.setAction( new TargetEffectComponent( TargetOptions.singleTarget((src, dst) -> dst.hasComponent(HealthComponent.class)), (src, dst) -> FightHelper.fight(src, dst.getSingleTarget()))); } }