Skip to content

Commit

Permalink
implemented encryption/decrption cards
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Fic committed Apr 6, 2022
1 parent d0bb2e3 commit eabc047
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public Card getSoftware() {

public void setSoftware(Card software) {
this.software = software;

}

public boolean activatedAbility() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ public int recieveDamage(int damage) {
*/
public int changeArmor(int armor) {
this.armor += armor;
if (this.armor < 0) {
armor = 0;
}
if (this.armor > maxArmor) {
maxArmor = armor;
}
return armor;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.janfic.games.computercombat.model.abilities;

import com.janfic.games.computercombat.model.Ability;
import com.janfic.games.computercombat.model.Card;
import com.janfic.games.computercombat.model.animations.ChangeStatAnim;
import com.janfic.games.computercombat.model.match.MatchState;
import com.janfic.games.computercombat.model.moves.Move;
import com.janfic.games.computercombat.model.moves.MoveAnimation;
import com.janfic.games.computercombat.model.moves.MoveResult;
import com.janfic.games.computercombat.util.CardFilter;
import com.janfic.games.computercombat.util.Filter;
import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -17,6 +21,10 @@ public class ChangeDefenseAbility extends Ability {
CardFilter cardFilter;
StateAnalyzer<Integer> amount;

public ChangeDefenseAbility() {
super(new ArrayList<>());
}

public ChangeDefenseAbility(List<Filter> selectFilters, CardFilter cardFilter, StateAnalyzer<Integer> amount) {
super(selectFilters);
this.cardFilter = cardFilter;
Expand All @@ -25,7 +33,25 @@ public ChangeDefenseAbility(List<Filter> selectFilters, CardFilter cardFilter, S

@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
//STUBBED
return null;
List<MoveResult> results = new ArrayList<>();
String currentUID = move.getPlayerUID();
String opponentUID = state.getOtherProfile(state.currentPlayerMove).getUID();

List<MoveAnimation> animation = new ArrayList<>();
MoveAnimation consume = Ability.consumeCardProgress(state, move);
animation.add(consume);

for (Card card : state.getAllCards()) {
if (cardFilter.filter(card, state, move)) {
int amount = this.amount.analyze(state, move);
card.changeArmor(amount);
animation.add(new ChangeStatAnim("armor", amount, card, card.getOwnerUID()));
}
}

state.currentPlayerMove = state.getOtherProfile(state.currentPlayerMove);
MoveResult result = new MoveResult(move, MatchState.record(state), animation);
results.add(result);
return results;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public List<MoveResult> doAbility(MatchState state, Move move) {
}
results.addAll(abilityResults);
if (i < abilities.size() - 1) {
if (state.currentPlayerMove.getUID() != move.getPlayerUID()) {
if (state.currentPlayerMove.getUID().equals(move.getPlayerUID())) {
state.currentPlayerMove = state.getOtherProfile(state.currentPlayerMove);
}
}
Expand Down
Loading

0 comments on commit eabc047

Please sign in to comment.