001    /**
002     * Jetrix TetriNET Server
003     * Copyright (C) 2001-2003  Emmanuel Bourg
004     *
005     * This program is free software; you can redistribute it and/or
006     * modify it under the terms of the GNU General Public License
007     * as published by the Free Software Foundation; either version 2
008     * of the License, or (at your option) any later version.
009     *
010     * This program is distributed in the hope that it will be useful,
011     * but WITHOUT ANY WARRANTY; without even the implied warranty of
012     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013     * GNU General Public License for more details.
014     *
015     * You should have received a copy of the GNU General Public License
016     * along with this program; if not, write to the Free Software
017     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
018     */
019    
020    package net.jetrix.filter;
021    
022    import java.util.*;
023    
024    import net.jetrix.*;
025    import net.jetrix.messages.channel.specials.SpecialMessage;
026    
027    /**
028     * Amplifies specials sent. One line sent will turn into two lines, a tetris
029     * into eight, etc... The multiplicating factor is set to 2 by default but
030     * can be changed by adding a <tt>factor</tt> parameter to the FilterConfig.
031     *
032     * @author Emmanuel Bourg
033     * @version $Revision: 798 $, $Date: 2009-02-18 16:24:28 +0100 (Wed, 18 Feb 2009) $
034     */
035    public class AmplifierFilter extends MessageFilter
036    {
037        private int factor = 2;
038    
039        public void init()
040        {
041            // read the parameters
042            factor = config.getInt("factor", factor);
043        }
044    
045        public void process(Message m, List<Message> out)
046        {
047            if (m instanceof SpecialMessage)
048            {
049                for (int i = 0; i < factor; i++)
050                {
051                    out.add(m);
052                }
053            }
054        }
055    
056        public String getName()
057        {
058            return "Amplifier";
059        }
060    
061        public String getDescription()
062        {
063            return "Amplifies specials by sending them twice or more.";
064        }
065    
066        public String getVersion()
067        {
068            return "1.0";
069        }
070    
071        public String getAuthor()
072        {
073            return "Emmanuel Bourg";
074        }
075    
076    }