<commit_before>package net.hearthstats;

import net.hearthstats.util.Rank;
import org.json.simple.JSONObject;

public class HearthstoneMatch {

	private String _mode;
	private String _userClass;
	private String _opponentClass;
	private boolean _coin = false;
	private String _result;
	private int _deckSlot;
	private String _opponentName;
	private Rank rankLevel;
	private int _numTurns = 0;
	private int _duration;
	private String _notes;
	private Integer _id;
	
	public HearthstoneMatch() {
		
	}
	public int getDeckSlot() {
		return _deckSlot;
	}
	
	public int getDuration() {
		return _duration;
	}
	
	public String getMode() {
		return _mode;
	}
	
	public int getNumTurns() {
		return _numTurns;
	}

	public void setMode(String mode) {
		_mode = mode;
	}
	
	public void setNumTurns(int numTurns) {
		_numTurns = numTurns;
	}

	public String getUserClass() {
		return _userClass;
	}

	public void setUserClass(String userClass) {
		_userClass = userClass;
	}

	public String getOpponentClass() {
		return _opponentClass;
	}

	public void setOpponentClass(String opponentClass) {
		_opponentClass = opponentClass;
	}
	
	public void setOpponentName(String opponentName) {
		_opponentName = opponentName;
	}
	
	public String getOpponentName() {
		return _opponentName;
	}

	public boolean hasCoin() {
		return _coin;
	}

	public void setCoin(boolean coin) {
		_coin = coin;
	}
	
	public void setDeckSlot(int deckSlot) {
		_deckSlot = deckSlot;
	}
	
	public void setDuration(int duration) {
		_duration = duration;
	}

	public Rank getRankLevel() {
		return rankLevel;
	}
	public String getResult() {
		return _result;
	}

	public void setRankLevel(Rank rankLevel) {
		this.rankLevel = rankLevel;
	}
	
	public void setResult(String result) {
		_result = result;
	}
	
	private String _propertyOrUnknown(String propertyVal) {
		return propertyVal == null ? "[undetected]" : propertyVal;
	}
	public String toString() {
		JSONObject deck = DeckSlotUtils.getDeckFromSlot(getDeckSlot());
		
		return _propertyOrUnknown(getMode()) + 
				("Ranked".equals(getMode()) ? " level " + getRankLevel() : "") +
				" " +
				(hasCoin() ? "" : "no ") + "coin " + 
				_propertyOrUnknown(getUserClass()) + " vs. " +
				_propertyOrUnknown(getOpponentClass()) + " " +
				"(" + _propertyOrUnknown(getOpponentName()) + ") " +
				getResult() + " " +
				(deck == null ? "" : " deck: " + deck.get("name")) +
				" (" + getNumTurns() + " turns)";
				
	}

	@SuppressWarnings("unchecked")
	public JSONObject toJsonObject() {
		String result = null;
		switch(getResult()) {
			case "Victory": case "Win":
				result = "Win";
				break;
			case "Defeat": case "Loss":
				result = "Loss";
				break;
			case "Draw":
				result = "Draw";
				break;
		}
		JSONObject obj = new JSONObject();

		obj.put("mode", getMode());
        if ("Ranked".equals(getMode())) {
            if (getRankLevel() == Rank.LEGEND) {
                obj.put("legend", "true");
            } else {
                obj.put("ranklvl", getRankLevel().number);
                obj.put("legend", "false");
            }
        }

        obj.put("slot", getDeckSlot());
		obj.put("class", getUserClass());
		obj.put("oppclass", getOpponentClass());
		obj.put("oppname", getOpponentName());
		obj.put("coin", hasCoin() ? "true" : "false");
        obj.put("result", result);
		obj.put("notes", getNotes());
		obj.put("numturns", getNumTurns());
		obj.put("duration", getDuration());
		
		return obj;
	}

	public String getNotes() {
		return _notes;
	}
	public void setNotes(String text) {
		_notes = text;
	}
	
	public String getEditUrl() {
		return "http://hearthstats.net/constructeds/" + getId() + "/edit";		<commit_msg>Initial support for submitting legend rank to HearthStats<commit_after>package net.hearthstats;

import net.hearthstats.util.Rank;
import org.json.simple.JSONObject;

public class HearthstoneMatch {

	private String _mode;
	private String _userClass;
	private String _opponentClass;
	private boolean _coin = false;
	private String _result;
	private int _deckSlot;
	private String _opponentName;
	private Rank rankLevel;
	private int _numTurns = 0;
	private int _duration;
	private String _notes;
	private Integer _id;
	
	public HearthstoneMatch() {
		
	}
	public int getDeckSlot() {
		return _deckSlot;
	}
	
	public int getDuration() {
		return _duration;
	}
	
	public String getMode() {
		return _mode;
	}
	
	public int getNumTurns() {
		return _numTurns;
	}

	public void setMode(String mode) {
		_mode = mode;
	}
	
	public void setNumTurns(int numTurns) {
		_numTurns = numTurns;
	}

	public String getUserClass() {
		return _userClass;
	}

	public void setUserClass(String userClass) {
		_userClass = userClass;
	}

	public String getOpponentClass() {
		return _opponentClass;
	}

	public void setOpponentClass(String opponentClass) {
		_opponentClass = opponentClass;
	}
	
	public void setOpponentName(String opponentName) {
		_opponentName = opponentName;
	}
	
	public String getOpponentName() {
		return _opponentName;
	}

	public boolean hasCoin() {
		return _coin;
	}

	public void setCoin(boolean coin) {
		_coin = coin;
	}
	
	public void setDeckSlot(int deckSlot) {
		_deckSlot = deckSlot;
	}
	
	public void setDuration(int duration) {
		_duration = duration;
	}

	public Rank getRankLevel() {
		return rankLevel;
	}
	public String getResult() {
		return _result;
	}

	public void setRankLevel(Rank rankLevel) {
		this.rankLevel = rankLevel;
	}
	
	public void setResult(String result) {
		_result = result;
	}
	
	private String _propertyOrUnknown(String propertyVal) {
		return propertyVal == null ? "[undetected]" : propertyVal;
	}
	public String toString() {
		JSONObject deck = DeckSlotUtils.getDeckFromSlot(getDeckSlot());
		
		return _propertyOrUnknown(getMode()) + 
				("Ranked".equals(getMode()) ? " level " + getRankLevel() : "") +
				" " +
				(hasCoin() ? "" : "no ") + "coin " + 
				_propertyOrUnknown(getUserClass()) + " vs. " +
				_propertyOrUnknown(getOpponentClass()) + " " +
				"(" + _propertyOrUnknown(getOpponentName()) + ") " +
				getResult() + " " +
				(deck == null ? "" : " deck: " + deck.get("name")) +
				" (" + getNumTurns() + " turns)";
				
	}

	@SuppressWarnings("unchecked")
	public JSONObject toJsonObject() {
		String result = null;
		switch(getResult()) {
			case "Victory": case "Win":
				result = "Win";
				break;
			case "Defeat": case "Loss":
				result = "Loss";
				break;
			case "Draw":
				result = "Draw";
				break;
		}
		JSONObject obj = new JSONObject();

		obj.put("mode", getMode());
        if ("Ranked".equals(getMode())) {
            if (getRankLevel() == Rank.LEGEND) {
                obj.put("ranklvl", 26);     // 26 currently represents legend on HearthStats
                obj.put("legend", "true");
            } else {
                obj.put("ranklvl", getRankLevel().number);
                obj.put("legend", "false");
            }
        }

        obj.put("slot", getDeckSlot());
		obj.put("class", getUserClass());
		obj.put("oppclass", getOpponentClass());
		obj.put("oppname", getOpponentName());
		obj.put("coin", hasCoin() ? "true" : "false");
        obj.put("result", result);
		obj.put("notes", getNotes());
		obj.put("numturns", getNumTurns());
		obj.put("duration", getDuration());
		
		return obj;
	}

	public String getNotes() {
		return _notes;
	}
	public void setNotes(String text) {
		_notes = text;
	}
	
	public String getEditUrl() {
		return "http://hearthstats.net/constructeds/" + getId() + "/edit";		
{'fraction_non_alphanumeric': 0.1346436689396978, 'fraction_numerical': 0.0008022462896109105, 'mean_word_length': 3.369158878504673, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, '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': '935624', 'n_tokens_mistral': 2810, 'n_tokens_neox': 2462, 'n_words': 571}