<commit_before>package com.nestedworld.nestedworld.data.network.socket.models.message.combat;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.nestedworld.nestedworld.data.database.entities.Combat;
import com.nestedworld.nestedworld.data.database.implementation.NestedWorldDatabase;
import com.nestedworld.nestedworld.data.network.socket.implementation.SocketMessageType;
import com.nestedworld.nestedworld.data.network.socket.models.message.DefaultMessage;

import org.msgpack.value.Value;
import org.msgpack.value.ValueFactory;

import java.util.Map;

public class AvailableMessage extends DefaultMessage {

    public String combatId;
    private String type;
    private String origin;
    private long monsterId;
    private String opponentPseudo;

    /*
    ** Constructor
     */
    public AvailableMessage(@NonNull Map<Value, Value> message,
                            @NonNull SocketMessageType.MessageKind messageKind,
                            @Nullable SocketMessageType.MessageKind idKind) {
        super(message, messageKind, idKind);
    }

    /*
    ** Utils
     */
    public Combat saveAsCombat() {
        Combat combat = new Combat();
        combat.type = this.type;
        combat.combatId = this.combatId;
        combat.origin = this.origin;
        combat.monsterId = this.monsterId;
        combat.opponentPseudo = this.opponentPseudo;

        NestedWorldDatabase.getInstance()
                .getDataBase()
                .getCombatDao()
                .insert(combat);

        return combat;
    }

    /*
    ** Getter (generated)<commit_msg>fix crash if user defy himself<commit_after>package com.nestedworld.nestedworld.data.network.socket.models.message.combat;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.nestedworld.nestedworld.data.database.entities.Combat;
import com.nestedworld.nestedworld.data.database.implementation.NestedWorldDatabase;
import com.nestedworld.nestedworld.data.network.socket.implementation.SocketMessageType;
import com.nestedworld.nestedworld.data.network.socket.models.message.DefaultMessage;

import org.msgpack.value.Value;
import org.msgpack.value.ValueFactory;

import java.util.Map;

public class AvailableMessage extends DefaultMessage {

    public String combatId;
    private String type;
    private String origin;
    private long monsterId;
    private String opponentPseudo;

    /*
    ** Constructor
     */
    public AvailableMessage(@NonNull Map<Value, Value> message,
                            @NonNull SocketMessageType.MessageKind messageKind,
                            @Nullable SocketMessageType.MessageKind idKind) {
        super(message, messageKind, idKind);
    }

    /*
    ** Utils
     */
    public Combat saveAsCombat() {
        Combat combat = new Combat();
        combat.type = this.type;
        combat.combatId = this.combatId;
        combat.origin = this.origin;
        combat.monsterId = this.monsterId;
        combat.opponentPseudo = this.opponentPseudo;

        NestedWorldDatabase.getInstance()
                .getDataBase()
                .getCombatDao()
                .insertOrReplace(combat);//Could be replace if you start a combat with yourself

        return combat;
    }

    /*
    ** Getter (generated)
{'fraction_non_alphanumeric': 0.08835820895522388, 'fraction_numerical': 0.0, 'mean_word_length': 2.856156501726122, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5049623', 'n_tokens_mistral': 906, 'n_tokens_neox': 900, 'n_words': 175}