Package game.core

Source Code of game.core.MessagePropertie

package game.core;

import beans.core.GeneralConstant;
import game.model.EmotionFactory;
import game.model.dialog.Message;
import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
* Classe servant de relation entre le programme et les fichiers de properties des messages
* @author mastersnes
*/
public class MessagePropertie {

    private static ResourceBundle messageProperties = GeneralConstant.BUNDLE;

    private MessagePropertie() {
    }

    /**
     * Retourne le message associé à l'ID passé en parametre
     * @param id
     * @return
     * @see Message
     */
    public static List<Message> getMessage(final String id) {
        final List<Message> messages = new ArrayList<Message>();
        boolean end = false;
        int cursor = 0;
        while (!end) {
            String persoName = null;
            String emotionName = null;
            String message = null;
            try {
                persoName = messageProperties.getString(id + cursor + "-perso");
            } catch (final MissingResourceException missingResourceException) {
            }

            try {
                emotionName = messageProperties.getString(id + cursor + "-emotion");
            } catch (final MissingResourceException missingResourceException) {
            }

            try {
                message = messageProperties.getString(id + cursor + "-message");
            } catch (final MissingResourceException missingResourceException) {
            }
           
            end = (persoName == null) && (emotionName == null) && (message == null);

            if (!end) {
                final Message msg = new Message(EmotionFactory.getEmotion(persoName, emotionName), message);
                messages.add(msg);
                cursor++;
            }
        }
        return messages;
    }
}
TOP

Related Classes of game.core.MessagePropertie

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.