use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class DamageHeuristicAnalyzer method getTotalHealths.
public int getTotalHealths(MoveResult result) {
int totalHealth = 0;
String currentUID = result.getMove().getPlayerUID();
String opponentUID = result.getState().getOtherProfile(currentUID);
for (Card card : result.getState().activeEntities.get(opponentUID)) {
totalHealth += card.getHealth();
totalHealth += card.getArmor();
}
totalHealth += result.getState().computers.get(opponentUID).getHealth();
return totalHealth;
}
use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class OpenPackScreen method show.
@Override
public void show() {
this.camera = new OrthographicCamera(1920 / 4, 1080 / 4);
this.stage = ComputerCombatGame.makeNewStage(camera);
this.skin = game.getAssetManager().get(Assets.SKIN);
this.collections = SQLAPI.getSingleton().getCollections();
List<Integer> collectionIDs = new ArrayList<>();
collectionIDs.add(collection.getID());
if (collection.getID() == 0) {
for (Collection c : collections) {
collectionIDs.add(c.getID());
}
}
collectionIDs.remove((Integer) 0);
this.collectionCards = SQLAPI.getSingleton().getCardsInCollection(collectionIDs, game.getCurrentProfile().getUID());
System.out.println(collectionCards);
this.pack = new CollectionPackActor(game, skin, collection);
pack.setScale(1.25f);
Gdx.input.setInputProcessor(stage);
Table table = new Table();
table.setFillParent(true);
table.defaults().space(20);
TextButton openButton = new TextButton("Open!", skin);
openButton.setTouchable(Touchable.disabled);
List<Card> openCards = new ArrayList<>();
openCards.add(roll());
openCards.add(roll());
openCards.add(roll());
end = new TextButton("Okay", skin);
end.setVisible(false);
end.setPosition(10, 10);
end.setSize(100, 30);
end.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Map<Integer, Integer> added = new HashMap<>();
for (Card openCard : openCards) {
added.put(openCard.getID(), added.getOrDefault(openCard.getID(), 0) + 1);
}
SQLAPI.getSingleton().addCardsToProfile(added, game.getCurrentProfile());
SQLAPI.getSingleton().saveProfile(game.getCurrentProfile());
game.popScreen();
}
});
table.add(pack).row();
table.add(openButton).width(100).row();
Action cardAction = Actions.sequence(Actions.visible(false), Actions.delay(1), Actions.moveBy(0, -stage.getHeight() * 2), Actions.visible(true), Actions.moveBy(0, stage.getHeight() * 2, 2, Interpolation.fastSlow), Actions.delay(2));
Action buttonAction = Actions.sequence(Actions.fadeOut(0), Actions.delay(3), Actions.fadeIn(1), Actions.touchable(Touchable.enabled));
openButton.addAction(buttonAction);
pack.addAction(cardAction);
cardActors = new ArrayList<>();
openButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
pack.open();
openButton.setVisible(false);
Action open = Actions.sequence(Actions.moveBy(0, -200, 1), Actions.run(() -> {
confetti();
for (CollectionCard openCard : cardActors) {
openCard.setPosition(pack.getX(), pack.getY());
openCard.setSize(pack.getWidth() - 4, pack.getHeight());
openCard.addAction(Actions.parallel(Actions.moveBy(0, 200, 1, Interpolation.circleOut), Actions.moveBy((cardActors.indexOf(openCard) - 1) * 150, 0, 1, Interpolation.circleIn)));
}
}), Actions.run(() -> {
end.setVisible(true);
}));
pack.addAction(open);
}
});
for (Card openCard : openCards) {
CollectionCard c = new CollectionCard(game, skin, openCard, 1);
cardActors.add(c);
stage.addActor(c);
}
stage.addActor(table);
stage.addActor(end);
table.layout();
}
use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class OpenPackScreen method roll.
public Card roll() {
int r = (int) (Math.random() * 5 * 5 * 5) + 1;
int selectedRarity = 1;
for (int i = 1; i <= 5; i++) {
selectedRarity = i;
if (i * i * i >= r) {
break;
}
}
List<Card> pool = new ArrayList<>();
for (Card card : collectionCards) {
if (card.getRarity() == selectedRarity) {
pool.add(card);
}
}
Collections.shuffle(pool);
return pool.get(0);
}
use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class CollectionScreen method buildCollection.
public void buildCollection() {
Profile profile = game.getCurrentProfile();
Map<Card, Integer> playerCards = new HashMap<>();
Map<Card, Integer> allCards = new HashMap<>();
List<Card> ac = SQLAPI.getSingleton().getCardsInfo(null, null);
playerCards = SQLAPI.getSingleton().getPlayerOwnedCards(profile.getUID());
for (Card card : ac) {
for (Card c : playerCards.keySet()) {
if (card.getID() == c.getID()) {
card.setOwnerUID(profile.getUID());
break;
}
}
}
for (Card card : ac) {
allCards.put(card, 0);
}
for (Card card : playerCards.keySet()) {
allCards.put(card, playerCards.get(card));
}
collection.clearChildren();
int row = 0;
for (Card card : allCards.keySet()) {
CollectionCard cc = new CollectionCard(game, skin, card, allCards.get(card));
if (allCards.get(card) == 0) {
cc.setColor(1, 1, 1, 0.5f);
}
if (filterWindow.getFilter().filter(card, null, null)) {
cards.add(cc);
collection.add(cc);
row++;
if (row % 4 == 0) {
collection.row();
row = 0;
}
}
}
}
use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class DecksScreen method buildCollection.
public void buildCollection() {
Profile profile = game.getCurrentProfile();
software = SQLAPI.getSingleton().getPlayerOwnedCards(profile.getUID());
collection.clearChildren();
int row = 0;
for (Card card : software.keySet()) {
Table cardTable = new Table();
CollectionCard cc = new CollectionCard(game, skin, card, software.get(card));
cardTable.add(cc).colspan(3).grow().row();
TextButton addButton = new TextButton("+", skin) {
@Override
public void act(float delta) {
// To change body of generated methods, choose Tools | Templates.
super.act(delta);
if (selectedDeck != null && selectedDeck.getDeck().getCardCount(card.getID()) >= software.get(card)) {
this.setColor(Color.RED);
} else {
this.setColor(Color.WHITE);
}
}
};
addButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (selectedDeck != null) {
if (selectedDeck.getDeck().getCardCount(card.getID()) < software.get(card)) {
selectedDeck.getDeck().addCard(card, 1);
updateDeckCards();
}
}
}
});
TextButton removeButton = new TextButton("-", skin);
removeButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (selectedDeck != null) {
selectedDeck.getDeck().removeCard(card, 1);
updateDeckCards();
}
}
});
Label amountInDeck = new Label("-", skin) {
@Override
public void act(float delta) {
super.act(delta);
if (selectedDeck != null) {
this.setText("" + selectedDeck.getDeck().getCardCount(card.getID()));
} else {
this.setText("-");
}
}
};
cardTable.add(removeButton).expandX().width(30);
cardTable.add(amountInDeck);
cardTable.add(addButton).expandX().width(30);
if (filterWindow.getFilter().filter(card, null, null)) {
collection.add(cardTable);
collectionToDeckDragAndDrop.addSource(new Source(cc) {
@Override
public Payload dragStart(InputEvent ie, float f, float f1, int i) {
Payload payload = new Payload();
payload.setObject(card);
BorderedArea dragActor = new BorderedArea(skin);
dragActor.setWidth(48);
dragActor.setHeight(48);
dragActor.add(new Image(game.getAssetManager().get("texture_packs/" + card.getCollection().getTextureName() + ".atlas", TextureAtlas.class).findRegion(card.getTextureName()))).width(46).height(46);
payload.setDragActor(dragActor);
return payload;
}
});
row++;
if (row % 2 == 0) {
collection.row();
row = 0;
}
}
}
}
Aggregations