package com.dmgame.net.script;

import com.dmgame.net.server.*;
import com.dmgame.net.script.*;
import com.dmgame.net.communication.*;

return new Mode();

class Mode extends ServerCommand{

	//is this script-ception?
	CommandInterpreter modeGetter;

	Mode(){
		modeGetter = new CommandInterpreter("res/scripts/server/modeScripts/");
	}

	String getName(){return "mode"};

	public boolean perform(Scanner splitter){
		if(!splitter.hasNext()){
			System.out.println(" - additional arguments required\r\n"
			+ "type \"/mode help\" for more details")
			return false
		}
		String modeCommand = splitter.nextLine().trim()
		println("processing command: "+modeCommand)
		return modeGetter.doCommand(modeCommand)
		/*
		String modeName = splitter.next()
		if("simple".startsWith(modeName)){
			int players = 4
			if(splitter.hasNext()){
				String modifier = splitter.next()
				try{
					players = Integer.parseInt(modifier)
				}
				catch(NumberFormatException ex){
					System.out.println("- simple modifier must be an integer")
					return false
				}
			}
			CommunicationMode newMode = new SimpleCommunicationMode(players)
			if(!MainServerHandler.setMode(newMode)){
				println("Cannot change mode. Communication with clients has started.")
				return false
			}
			else{
				println("Set mode to: simple")
				println("number of players: "+players)
				return true
			}
		}
		else if("help".startsWith(modeName)){
			println("Usage: mode <mode type> [mode args]\r\n"
			+ "Available modes: \r\n"
			+ "simple - chooses a random map once all players are connected.\r\n"
			+ "       - argument: number of players to connect")
			return false
		}*/
	}
}