<commit_before>package de.kimminich.groovy.tcg

import javax.swing.*

class Player {
    static int id = 0

    String name = "Player " + id++
    int health = 30
    int mana = 0
    int maxMana = 0
    ArrayList<Integer> deck = [0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8]
    ArrayList<Integer> hand = []

    def drawCard() {
        if (deck.isEmpty()) {
            health--
        } else {
            Collections.shuffle(deck)
            if (hand.size() < 5) {
                hand.addAll(deck.take(1))
            }
            deck = deck.drop(1)
        }
    }

    def playCard(int card, Player opponent) {
        opponent.health -= card
        hand.remove(card as Object)
    }

    def playTurn(Player opponent) {
        String input;
        while ((input = JOptionPane.showInputDialog(playerInfo() + " - Choose card to play: " + hand)) != null) {
            if (input.isInteger()) {
                Integer cardToPlay = input.toInteger()
                if (hand.contains(cardToPlay)) {
                    playCard(cardToPlay, opponent)
                } else {
                    JOptionPane.showMessageDialog(null, "You do not have this card!");
                }
            } else {
                JOptionPane.showMessageDialog(null, "Invalid input!");
            }
        }
    }

    private String playerInfo() {<commit_msg>added mana check and deduction when playing a card (also untested)<commit_after>package de.kimminich.groovy.tcg

import javax.swing.*

class Player {
    static int id = 0

    String name = "Player " + id++
    int health = 30
    int mana = 0
    int maxMana = 0
    ArrayList<Integer> deck = [0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8]
    ArrayList<Integer> hand = []

    def drawCard() {
        if (deck.isEmpty()) {
            health--
        } else {
            Collections.shuffle(deck)
            if (hand.size() < 5) {
                hand.addAll(deck.take(1))
            }
            deck = deck.drop(1)
        }
    }

    def playCard(int card, Player opponent) {
        opponent.health -= card
        mana -= card
        hand.remove(card as Object)
    }

    def playTurn(Player opponent) {
        String input;
        while ((input = JOptionPane.showInputDialog(playerInfo() + " - Choose card to play: " + hand)) != null) {
            if (input.isInteger()) {
                Integer cardToPlay = input.toInteger()
                if (hand.contains(cardToPlay)) {
                    if (mana >= cardToPlay) {
                        playCard(cardToPlay, opponent)
                    } else {
                        JOptionPane.showMessageDialog(null, "You do not have enough mana to play this card!");
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "You do not have this card!");
                }
            } else {
                JOptionPane.showMessageDialog(null, "Invalid input!");
            }
        }
    }

    private String playerInfo() {
{'fraction_non_alphanumeric': 0.1152832674571805, 'fraction_numerical': 0.01844532279314888, 'mean_word_length': 1.5308333333333333, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3396755', 'n_tokens_mistral': 949, 'n_tokens_neox': 866, 'n_words': 243}