<commit_before>package authoring.actionslogic;

import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ListView;
import javafx.scene.layout.VBox;


/**
 * Controller for Action Logic Chart in Authoring Environment
 *
 */
public class ActionLogicController implements Initializable {

    @FXML
    private ListView<String> actionsListView;

    @FXML
    private ChoiceBox<String> actorsChoiceBox;

    @FXML
    private VBox myReceiversVBox;

    @FXML
    private Button saveButton;

    private List<String> myPieceTypes = new ArrayList<String>();
    private Map<String, Map> myLogicMap = new HashMap<String, Map>();

    @Override
    // TODO: [IMPORTANT] This constructor will need a List<String> or Set<String> that contains
    // names of Pieces as its argument
    // also, need a list of existing actions(or names of actions)
    public void initialize (URL location, ResourceBundle resources) {

        // for testing
        actionsListView.getItems().addAll("Attack");
        actionsListView.getItems().addAll("Heal");
        actionsListView.getItems().addAll("Run");
        myPieceTypes.add("Piece A");
        myPieceTypes.add("Piece B");
        myPieceTypes.add("Piece C");
        actorsChoiceBox.getItems().addAll(myPieceTypes);

        actorsChoiceBox
                .getSelectionModel()
                .selectedItemProperty()
                .addListener(
                             (observable, oldValue, selectedActor) -> updatePossibleReceivers(selectedActor));
    }

    private void updatePossibleReceivers (String selectedActor) {
        List<String> myPosReceivers = getReceivers(myPieceTypes, selectedActor);
         for (String p : myPosReceivers) {
         myReceiversVBox.getChildren().add(new CheckBox(p));
         }
    }

    private List<String> getReceivers (List<String> myPieceTypes, String actor) {
        List<String> receivers = new ArrayList<String>();
        for (String p : myPieceTypes) {
            if (!p.equals(actor)) {
                receivers.add(p);
            }
        }
        return receivers;
    }

    @FXML
    private void saveLogic () {
        String currAction = actionsListView.getSelectionModel().getSelectedItem();
        System.out.println(currAction);
        String currActor = actorsChoiceBox.getSelectionModel().getSelectedItem();
        System.out.println(currActor);

    }

}
<commit_msg>debugging saveLogic method<commit_after>package authoring.actionslogic;

import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ListView;
import javafx.scene.layout.VBox;


/**
 * Controller for Action Logic Chart in Authoring Environment
 *
 */
public class ActionLogicController implements Initializable {

    @FXML
    private ListView<String> actionsListView;

    @FXML
    private ChoiceBox<String> actorsChoiceBox;

    @FXML
    private VBox myReceiversVBox;

    @FXML
    private Button saveButton;

    private List<String> myPieceTypes = new ArrayList<String>();
    private Map<String, Map> myLogicMap = new HashMap<String, Map>();
    private List<CheckBox> myCBList = new ArrayList<CheckBox>();

    @Override
    // TODO: [IMPORTANT] This constructor will need a List<String> or Set<String> that contains
    // names of Pieces as its argument
    // also, need a list of existing actions(or names of actions)
    public void initialize (URL location, ResourceBundle resources) {

        // for testing
        actionsListView.getItems().addAll("Attack");
        actionsListView.getItems().addAll("Heal");
        actionsListView.getItems().addAll("Run");
        myPieceTypes.add("Piece A");
        myPieceTypes.add("Piece B");
        myPieceTypes.add("Piece C");
        actorsChoiceBox.getItems().addAll(myPieceTypes);

        actorsChoiceBox
                .getSelectionModel()
                .selectedItemProperty()
                .addListener(
                             (observable, oldValue, selectedActor) -> updatePossibleReceivers(selectedActor));
    }

    private void updatePossibleReceivers (String selectedActor) {
        List<String> myPosReceivers = getReceivers(myPieceTypes, selectedActor);
        for (String p : myPosReceivers) {
            CheckBox receiverCB = new CheckBox(p);
            myCBList.add(receiverCB);
            myReceiversVBox.getChildren().add(receiverCB);
        }
    }

    private List<String> getReceivers (List<String> myPieceTypes, String actor) {
        List<String> receivers = new ArrayList<String>();
        for (String p : myPieceTypes) {
            if (!p.equals(actor)) {
                receivers.add(p);
            }
        }
        return receivers;
    }

    @FXML
    private void saveLogic () {
        String currAction = actionsListView.getSelectionModel().getSelectedItem();
        String currActor = actorsChoiceBox.getSelectionModel().getSelectedItem();
        List<String> receiverList = new ArrayList<String>();
        for (CheckBox cb : myCBList) {
            if(cb.isSelected()){
                receiverList.add(cb.getText());
            }
        }
        Map<String,List<String>> actionReceiver = myLogicMap.get(currActor);
        actionReceiver.put(currAction, receiverList);
        myLogicMap.put(currActor, actionReceiver);
        System.out.println(myLogicMap);
        

    }

}

{'fraction_non_alphanumeric': 0.10220713073005093, 'fraction_numerical': 0.0, 'mean_word_length': 2.909090909090909, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '1212498', 'n_tokens_mistral': 1690, 'n_tokens_neox': 1639, 'n_words': 371}